Skip to content

Commit

Permalink
fix import
Browse files Browse the repository at this point in the history
  • Loading branch information
Neo-Ryo committed Apr 11, 2024
1 parent f5b29ca commit a051f8e
Showing 1 changed file with 25 additions and 37 deletions.
62 changes: 25 additions & 37 deletions src/pages/admin/newportal/contenulibre/1.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,65 +3,53 @@ 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';
import { BackButton } from 'src/components/buttons/BackButton';
import { ActivityContext } from 'src/contexts/activityContext';
import { useActivity } from 'src/hooks/useActivity';
import type { ActivityContent } from 'types/activity.type';
import { ActivityStatus } from 'types/activity.type';

const ContenuLibre = () => {
const ContenuLibreStep1: React.FC = () => {
const { activity, updateActivity, addContent, deleteContent, save } = useActivity();
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('/contenu-libre');
router.push('/admin/newportal/contenulibre/1');
} else if (activity && !isFreeContent(activity)) {
router.push('/contenu-libre');
router.push('/admin/newportal/contenulibre/1');
}
}, [activity, router]);

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

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

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

return (
<>
<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>
</>
<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>
);
};

export default ContenuLibre;
export default ContenuLibreStep1;

0 comments on commit a051f8e

Please sign in to comment.