Skip to content

Commit

Permalink
re use old code so that it compile
Browse files Browse the repository at this point in the history
  • Loading branch information
Neo-Ryo committed Apr 11, 2024
1 parent 03bb83c commit f5b29ca
Showing 1 changed file with 38 additions and 26 deletions.
64 changes: 38 additions & 26 deletions src/pages/admin/newportal/contenulibre/1.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,53 +3,65 @@ import React, { useEffect } from 'react';

import { isFreeContent } from 'src/activity-types/anyActivity';
import { Base } from 'src/components/Base';
import { Steps } from 'src/components/Steps';
import { StepsButton } from 'src/components/StepsButtons';
import StepsNavigation from 'src/components/activities/StepsNavigation';
import ContentEditor from 'src/components/activities/content/ContentEditor';
import { useActivity } from 'src/hooks/useActivity';
import { ContentEditor } from 'src/components/activities/content';
import { BackButton } from 'src/components/buttons/BackButton';
import { ActivityContext } from 'src/contexts/activityContext';
import type { ActivityContent } from 'types/activity.type';
import { ActivityStatus } from 'types/activity.type';

const ContenuLibreStep1: React.FC = () => {
const { activity, updateActivity, addContent, deleteContent, save } = useActivity();
const ContenuLibre = () => {
const router = useRouter();
const { activity, updateActivity, addContent, deleteContent, save } = React.useContext(ActivityContext);

const isEdit = activity !== null && activity.status !== ActivityStatus.DRAFT;

useEffect(() => {
if (activity === null && !('activity-id' in router.query) && !sessionStorage.getItem('activity')) {
router.push('/admin/newportal/contenulibre/1');
router.push('/contenu-libre');
} else if (activity && !isFreeContent(activity)) {
router.push('/admin/newportal/contenulibre/1');
router.push('/contenu-libre');
}
}, [activity, router]);

const updateContent = (content: ActivityContent[]): void => {
if (!activity) return;
if (!activity) {
return;
}
updateActivity({ content });
};

const onNext = async (): Promise<void> => {
const success = await save();
if (success) {
router.push('/admin/newportal/contenulibre/2');
}
const onNext = () => {
save().catch(console.error);
router.push('/contenu-libre/2');
};

if (!activity) {
return <Base hideLeftNav />;
return <Base />;
}

return (
<div>
<StepsNavigation currentStep={0} />
<h1>Ecrivez le contenu de votre publication</h1>
<p>
Utilisez l&apos;éditeur de bloc pour définir le contenu de votre publication. Dans l&apos;étape 2 vous pourrez définir l&apos;aspect de la
carte résumée de votre publication.
</p>
<ContentEditor content={activity.content} updateContent={updateContent} addContent={addContent} deleteContent={deleteContent} />

<StepsButton next={onNext} />
</div>
<>
<div style={{ width: '100%', padding: '0.5rem 1rem 1rem 1rem' }}>
{!isEdit && <BackButton href="/contenu-libre" />}
<Steps
steps={['Contenu', 'Forme', 'Pré-visualiser']}
urls={['/contenu-libre/1?edit', '/contenu-libre/2', '/contenu-libre/3']}
activeStep={0}
/>
<div className="width-900">
<h1>Ecrivez le contenu de votre publication</h1>
<p className="text">
Utilisez l&apos;éditeur de bloc pour définir le contenu de votre publication. Dans l&apos;étape 2 vous pourrez définir l&apos;aspect de la
carte résumée de votre publication.
</p>
<ContentEditor content={activity.content} updateContent={updateContent} addContent={addContent} deleteContent={deleteContent} />
<StepsButton next={onNext} />
</div>
</div>
</>
);
};

export default ContenuLibreStep1;
export default ContenuLibre;

0 comments on commit f5b29ca

Please sign in to comment.