From 03bb83c3497f41da040c60bc140a1e3311c5c675 Mon Sep 17 00:00:00 2001 From: Neo Ryo Date: Wed, 10 Apr 2024 17:55:32 +0200 Subject: [PATCH] WIP --- src/components/Steps.tsx | 5 +---- src/contexts/activityContext.tsx | 7 +++++-- src/pages/admin/newportal/contenulibre/3.tsx | 3 ++- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/components/Steps.tsx b/src/components/Steps.tsx index f5748364b..19f943dc5 100644 --- a/src/components/Steps.tsx +++ b/src/components/Steps.tsx @@ -2,11 +2,8 @@ import { useRouter } from 'next/router'; import React from 'react'; import CheckIcon from '@mui/icons-material/Check'; -import Step from '@mui/material/Step'; -import StepConnector from '@mui/material/StepConnector'; +import { Step, StepConnector, StepLabel, Stepper } from '@mui/material/'; import type { StepIconProps } from '@mui/material/StepIcon'; -import StepLabel from '@mui/material/StepLabel'; -import Stepper from '@mui/material/Stepper'; import { ActivityContext } from 'src/contexts/activityContext'; import { primaryColor, primaryColorLight2, successColor, warningColor } from 'src/styles/variables.const'; diff --git a/src/contexts/activityContext.tsx b/src/contexts/activityContext.tsx index 2e4e354a1..48aa8b4d0 100644 --- a/src/contexts/activityContext.tsx +++ b/src/contexts/activityContext.tsx @@ -11,7 +11,7 @@ import { getActivityPhase } from 'src/components/activities/utils'; import { primaryColor } from 'src/styles/variables.const'; import { serializeToQueryUrl, debounce, getQueryString } from 'src/utils'; import { axiosRequest } from 'src/utils/axiosRequest'; -import type { Activity, AnyData, ActivityContentType, ActivityContent } from 'types/activity.type'; +import type { ActivityContentType, ActivityContent, Activity, AnyData } from 'types/activity.type'; import { ActivityType, ActivityStatus } from 'types/activity.type'; type ActivitySaveResponse = { success: false } | { success: true; activity: Activity }; @@ -33,6 +33,7 @@ interface ActivityContextValue { deleteContent(index: number): void; save(publish?: boolean): Promise; createActivityIfNotExist(type: number, selectedPhase: number, subType?: number, initialData?: AnyData, isVillageActivity?: boolean): Promise; + setDraft(draft: Activity | null): void; } export const ActivityContext = React.createContext({ @@ -44,6 +45,7 @@ export const ActivityContext = React.createContext({ deleteContent: () => {}, save: async () => ({ success: false }), createActivityIfNotExist: async () => {}, + setDraft: () => {}, }); function getInitialActivity(): Activity | null { @@ -387,6 +389,7 @@ export const ActivityContextProvider = ({ children }: React.PropsWithChildren {draftStep === 1 && } - {draftStep === 2 && Brouillon enregistré} + {draftStep === 2 &&

Brouillon enregistré

}
)} diff --git a/src/pages/admin/newportal/contenulibre/3.tsx b/src/pages/admin/newportal/contenulibre/3.tsx index ad04c21a3..4fa29f20c 100644 --- a/src/pages/admin/newportal/contenulibre/3.tsx +++ b/src/pages/admin/newportal/contenulibre/3.tsx @@ -21,7 +21,7 @@ import { ActivityStatus } from 'types/activity.type'; const ContenuLibre = () => { const router = useRouter(); - const { activity, save } = useActivity(); + const { activity, save, setDraft } = useActivity(); const { user } = React.useContext(UserContext); const [isLoading, setIsLoading] = React.useState(false); @@ -56,6 +56,7 @@ const ContenuLibre = () => { setIsLoading(true); const { success } = await save(false); if (success) { + setDraft(null); router.push('/admin/newportal/contenulibre/success'); } setIsLoading(false);