fix: 🐛 Fix tour language & reorder onboarding steps
Simon Mulquin simon@octree.ch
Mon, 21 Mar 2022 16:47:44 +0000
6 files changed,
27 insertions(+),
25 deletions(-)
M
frontend/.gitignore
→
frontend/.gitignore
@@ -25,6 +25,7 @@ yarn-debug.log*
yarn-error.log* # local env files +.env .env.local .env.development.local .env.test.local
M
frontend/containers/EventBar/index.tsx
→
frontend/containers/EventBar/index.tsx
@@ -225,9 +225,8 @@ const fromTo = (step1: number, step2: number) =>
prev === step1 && step === step2; if (isCreator) { - if (fromTo(1, 0) || fromTo(0, 1) || fromTo(3, 2) || fromTo(2, 3)) - toggleDetails(); - } else if (fromTo(2, 3) || fromTo(3, 2)) toggleDetails(); + if (fromTo(3, 2) || fromTo(2, 3) || fromTo(4, 5)) toggleDetails(); + } else if (fromTo(2, 3) || fromTo(3, 2) || fromTo(3, 4)) toggleDetails(); }; const useStyles = makeStyles(theme => ({
M
frontend/containers/OnBoardingTour/index.tsx
→
frontend/containers/OnBoardingTour/index.tsx
@@ -9,11 +9,15 @@ const OnBoardingTour = (props: Props) => {
const theme = useTheme(); const {t} = useTranslation(); const {run, steps, step, onTourChange} = useTour(); + const translateStep = ({content, ...step}) => ({ + content: t(content), + ...step, + }); return ( <Joyride run={run} - steps={steps} + steps={steps.map(translateStep)} stepIndex={step} callback={onTourChange} locale={t('joyride', {returnObjects: true})}
M
frontend/hooks/useTour.ts
→
frontend/hooks/useTour.ts
@@ -1,5 +1,4 @@
import {useEffect, useMemo} from 'react'; -import {useTranslation} from 'react-i18next'; import {CallBackProps, STATUS, EVENTS, ACTIONS} from 'react-joyride'; import {useUpdateMeMutation} from '../generated/graphql'; import useOnboardingStore from '../stores/useOnboardingStore';@@ -23,7 +22,6 @@ },
}; const useTour = () => { - const {t} = useTranslation(); const isCreator = useTourStore(s => s.isCreator); const run = useTourStore(s => s.run); const step = useTourStore(s => s.step);@@ -51,17 +49,17 @@ const steps = useMemo(() => {
if (isCreator === null) return []; return isCreator ? [ - {content: t`tour.creator.step1`, target: '.tour_event_infos'}, - {content: t`tour.creator.step2`, target: '.tour_event_edit'}, - {content: t`tour.creator.step3`, target: '.tour_event_share'}, - {content: t`tour.creator.step4`, target: '.tour_waiting_list'}, - {content: t`tour.creator.step5`, target: '.tour_travel_add'}, + {content: 'tour.creator.step1', target: '.tour_travel_add'}, + {content: 'tour.creator.step2', target: '.tour_waiting_list'}, + {content: 'tour.creator.step3', target: '.tour_event_infos'}, + {content: 'tour.creator.step4', target: '.tour_event_edit'}, + {content: 'tour.creator.step5', target: '.tour_event_share'}, ].map(currentStep => ({...currentStep, ...STEP_SETTINGS})) : [ - {content: t`tour.user.step1`, target: '.tour_travel_add'}, - {content: t`tour.user.step2`, target: '.tour_waiting_list'}, - {content: t`tour.user.step3`, target: '.tour_event_infos'}, - {content: t`tour.user.step4`, target: '.tour_event_share'}, + {content: 'tour.user.step1', target: '.tour_travel_add'}, + {content: 'tour.user.step2', target: '.tour_waiting_list'}, + {content: 'tour.user.step3', target: '.tour_event_infos'}, + {content: 'tour.user.step4', target: '.tour_event_share'}, ].map(currentStep => ({...currentStep, ...STEP_SETTINGS})); }, [isCreator]);
M
frontend/locales/en.json
→
frontend/locales/en.json
@@ -35,11 +35,11 @@ "nope": "Later",
"onboard": "OK, let's go!" }, "creator": { - "step1": "The event information can be modified from this menu.", - "step2": "The event can be edited by clicking on the edit button.", - "step3": "Share the event now by copying the link and sharing it by email or in a messaging group.", - "step4": "The waiting list includes passengers who do not yet have a seat in a car.", - "step5": "A new car can also be added directly from the floating action button." + "step1": "A new car can also be added directly from the floating action button.", + "step2": "The waiting list includes passengers who do not yet have a seat in a car.", + "step3": "The event information can be modified from this menu.", + "step4": "The event can be edited by clicking on the edit button.", + "step5": "Share the event now by copying the link and sharing it by email or in a messaging group." }, "user": { "step1": "A new car can be added directly from the floating action button.",
M
frontend/locales/fr.json
→
frontend/locales/fr.json
@@ -35,11 +35,11 @@ "nope": "Pas maintenant",
"onboard": "OK, c'est parti!" }, "creator": { - "step1": "Vous pouvez voir et modifier les informations de l'événement depuis ce menu.✨", - "step2": "Editez l'événement en cliquant sur le bouton d'édition.", - "step3": "Copiez le lien de l'événement dès maintenant pour le partager par email, whatsapp, telegram, etc.. ", - "step4": "La liste d'attente regroupe les personnes qui n'ont pas encore été placées dans une voiture.", - "step5": "Ajoutez une nouvelle voiture en cliquant directement sur ce bouton." + "step1": "Ajoutez une nouvelle voiture en cliquant directement sur ce bouton.", + "step2": "La liste d'attente regroupe les personnes qui n'ont pas encore été placées dans une voiture.", + "step3": "Vous pouvez voir et modifier les informations de l'événement depuis ce menu.✨", + "step4": "Editez l'événement en cliquant sur le bouton d'édition.", + "step5": "Copiez le lien de l'événement dès maintenant pour le partager par email, whatsapp, telegram, etc.. " }, "user": { "step1": "Ajoutez une nouvelle voiture en cliquant directement sur ce bouton.",