all repos — caroster @ 6ecc26e122629b91742372a29216299adec71362

[Octree] Group carpool to your event https://caroster.io

🐛 Fixes after UX review on administrators management
Simon Mulquin simon@octree.ch
Thu, 22 Feb 2024 11:57:40 +0000
commit

6ecc26e122629b91742372a29216299adec71362

parent

a9547860ccc77ad9735f07bda93f9234d41251f1

M backend/src/graphql/event/administrators.tsbackend/src/graphql/event/administrators.ts

@@ -27,7 +27,7 @@ }),

], resolvers: { Event: { - administrators: async (event) => event.administrators?.split(/, ?/), + administrators: (event) => event.administrators?.split(/, ?/).filter(Boolean) || [], }, Mutation: { addEventAdmin: {

@@ -39,7 +39,7 @@ args.eventId

); if (!event) throw new errors.NotFoundError(`Event not found`); - const currentAdmins = event.administrators?.split(/, ?/) || []; + const currentAdmins = event.administrators?.split(/, ?/).filter(Boolean) || []; // Check if user is authorized to add event admin const user = context.state.user;

@@ -105,9 +105,12 @@ if (user.email !== event.email && !currentAdmins.includes(user.email))

throw new errors.ForbiddenError(); // Remove email from event's administrators list - const administrators = currentAdmins - .filter((email) => email !== args.email) - .join(", "); + const administratorsArray = currentAdmins.filter( + (email) => email !== args.email + ); + + const administrators = administratorsArray.join(", "); + const updatedEvent = await strapi.entityService.update( "api::event.event", args.eventId,
M frontend/containers/CarosterPlusSettings/index.tsxfrontend/containers/CarosterPlusSettings/index.tsx

@@ -71,7 +71,6 @@ email,

}, }); addToast(t('options.plus.adminDeleted')); - toggleAddAdminDialog(); } catch (e) { console.error(e); addToast(t('options.plus.deleteAdminError'));
M frontend/containers/DrawerMenu/DrawerMenuItem.tsxfrontend/containers/DrawerMenu/DrawerMenuItem.tsx

@@ -58,7 +58,6 @@ color="inherit"

sx={{ ml: 1, position: 'relative', - fontSize: '11px', lineHeight: '1.1em', height: 'auto', display: 'inline-block',
M frontend/pages/e/[uuid]/details.tsxfrontend/pages/e/[uuid]/details.tsx

@@ -7,8 +7,6 @@ import Card from '@mui/material/Card';

import Container from '@mui/material/Container'; import TextField from '@mui/material/TextField'; import Typography from '@mui/material/Typography'; -import PlaceOutlinedIcon from '@mui/icons-material/PlaceOutlined'; -import EventIcon from '@mui/icons-material/Event'; import TuneIcon from '@mui/icons-material/Tune'; import CheckCircleOutlineIcon from '@mui/icons-material/CheckCircleOutline'; import {useTheme} from '@mui/material/styles';

@@ -136,7 +134,7 @@ <Typography variant="h4" pb={2}>

{t('event.details')} </Typography> {canEditEventDetails() && modifyButton} - <Box pt={2} pr={1.5}> + {(isEditing || event.name) && <Box pt={2} pr={1.5}> <Typography variant="overline">{t('event.fields.name')}</Typography> <Typography> {isEditing ? (

@@ -150,12 +148,12 @@ id="EditEventName"

/> ) : ( <Typography id="EventName"> - {event.name ?? t('event.fields.empty')} + {event.name} </Typography> )} </Typography> - </Box> - <Box pt={2} pr={1.5}> + </Box>} + {(isEditing || event.address) && <Box pt={2} pr={1.5}> <Typography variant="overline">{t('event.fields.date')}</Typography> {isEditing ? ( <Typography>

@@ -180,42 +178,32 @@ </Typography>

) : ( <Box position="relative"> <Typography id="EventDate"> - {event.date - ? moment(event.date).format('DD/MM/YYYY') - : t('event.fields.empty')} + {moment(event.date).format('DD/MM/YYYY')} </Typography> - <EventIcon - color="action" - sx={{ - position: 'absolute', - right: theme.spacing(-0.5), - top: 0, - }} - /> </Box> )} - </Box> - <Box pt={2} pr={1.5}> - <Typography variant="overline"> - {t('event.fields.address')} - </Typography> - {isEditing ? ( - <PlaceInput - place={event.address} - latitude={event.latitude} - longitude={event.longitude} - onSelect={({place, latitude, longitude}) => - setEventUpdate({ - address: place, - latitude, - longitude, - }) - } - /> - ) : ( - <Box position="relative"> - <Typography id="EventAddress" sx={{pr: 3}}> - {event.address ? ( + </Box>} + {(isEditing || event.address) && ( + <Box pt={2} pr={1.5}> + <Typography variant="overline"> + {t('event.fields.address')} + </Typography> + {isEditing ? ( + <PlaceInput + place={event.address} + latitude={event.latitude} + longitude={event.longitude} + onSelect={({place, latitude, longitude}) => + setEventUpdate({ + address: place, + latitude, + longitude, + }) + } + /> + ) : ( + <Box position="relative"> + <Typography id="EventAddress" sx={{pr: 3}}> <Link target="_blank" rel="noreferrer"

@@ -226,59 +214,55 @@ onClick={e => e.preventDefault}

> {event.address} </Link> - ) : ( - t('event.fields.empty') - )} - </Typography> - <PlaceOutlinedIcon - color="action" - sx={{ - position: 'absolute', - right: theme.spacing(-0.5), - top: 0, - }} - /> - </Box> - )} - </Box> - <Box pt={2} pr={1.5}> - <Typography variant="overline"> - {t('event.fields.description')} - </Typography> - {isEditing ? ( - <Typography> - <TextField - fullWidth - multiline - maxRows={4} - inputProps={{maxLength: 250}} - value={event.description || ''} - onChange={e => setEventUpdate({description: e.target.value})} - id={`EditEventDescription`} - name="description" - /> + </Typography> + </Box> + )} + </Box> + )} + {(isEditing || event.description) && ( + <Box pt={2} pr={1.5}> + <Typography variant="overline"> + {t('event.fields.description')} </Typography> - ) : ( - <Typography id="EventDescription" sx={{pr: 3}}> - {event.description ?? t('event.fields.empty')} - </Typography> - )} - </Box> - <Box pt={2} pr={1.5}> - <Typography variant="overline">{t('event.fields.lang')}</Typography> - {isEditing ? ( - <LangSelector - value={event.lang} - onChange={lang => setEventUpdate({lang})} - /> - ) : ( - <Typography id="EventLang" sx={{pr: 3}}> - {event.lang - ? t(`PROTECTED.languages.${event.lang}`) - : t('event.fields.empty')} + {isEditing ? ( + <Typography> + <TextField + fullWidth + multiline + maxRows={4} + inputProps={{maxLength: 250}} + value={event.description || ''} + onChange={e => + setEventUpdate({description: e.target.value}) + } + id={`EditEventDescription`} + name="description" + /> + </Typography> + ) : ( + <Typography id="EventDescription" sx={{pr: 3}}> + {event.description} + </Typography> + )} + </Box> + )} + {(isEditing || event.lang) && ( + <Box pt={2} pr={1.5}> + <Typography variant="overline"> + {t('event.fields.lang')} </Typography> - )} - </Box> + {isEditing ? ( + <LangSelector + value={event.lang} + onChange={lang => setEventUpdate({lang})} + /> + ) : ( + <Typography id="EventLang" sx={{pr: 3}}> + {t(`PROTECTED.languages.${event.lang}`)} + </Typography> + )} + </Box> + )} {!isEditing && ( <ShareEvent title={`Caroster ${event.name}`}