Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
Neo-Ryo committed Apr 10, 2024
1 parent edc651b commit 03bb83c
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
5 changes: 1 addition & 4 deletions src/components/Steps.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
7 changes: 5 additions & 2 deletions src/contexts/activityContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 };
Expand All @@ -33,6 +33,7 @@ interface ActivityContextValue {
deleteContent(index: number): void;
save(publish?: boolean): Promise<ActivitySaveResponse>;
createActivityIfNotExist(type: number, selectedPhase: number, subType?: number, initialData?: AnyData, isVillageActivity?: boolean): Promise<void>;
setDraft(draft: Activity | null): void;
}

export const ActivityContext = React.createContext<ActivityContextValue>({
Expand All @@ -44,6 +45,7 @@ export const ActivityContext = React.createContext<ActivityContextValue>({
deleteContent: () => {},
save: async () => ({ success: false }),
createActivityIfNotExist: async () => {},
setDraft: () => {},
});

function getInitialActivity(): Activity | null {
Expand Down Expand Up @@ -387,6 +389,7 @@ export const ActivityContextProvider = ({ children }: React.PropsWithChildren<Re
deleteContent,
createActivityIfNotExist,
save,
setDraft,
}),
[activity, setActivity, updateActivity, createNewActivity, addContent, deleteContent, createActivityIfNotExist, save],
);
Expand All @@ -398,7 +401,7 @@ export const ActivityContextProvider = ({ children }: React.PropsWithChildren<Re
<div style={{ position: 'fixed', bottom: '1rem', right: '4.5rem' }}>
<Card style={{ backgroundColor: primaryColor, color: 'white', padding: '0.25rem 0.5rem', display: 'flex', alignItems: 'center' }}>
{draftStep === 1 && <CircularProgress color="inherit" size="1.25rem" />}
{draftStep === 2 && <span className="text text--small">Brouillon enregistré</span>}
{draftStep === 2 && <p className="text text--small">Brouillon enregistré</p>}
</Card>
</div>
)}
Expand Down
3 changes: 2 additions & 1 deletion src/pages/admin/newportal/contenulibre/3.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 03bb83c

Please sign in to comment.