Skip to content

Commit

Permalink
Merge pull request #892 from parlemonde/hotfix/bug-freecontent-nav
Browse files Browse the repository at this point in the history
hotfix add index at contenu-libre
  • Loading branch information
GuillaumeLoup authored Mar 21, 2024
2 parents 2f20f45 + 5f695c6 commit 9235c6f
Showing 1 changed file with 46 additions and 0 deletions.
46 changes: 46 additions & 0 deletions src/pages/contenu-libre/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import { useRouter } from 'next/router';
import React from 'react';

import { Base } from 'src/components/Base';
import { StepsButton } from 'src/components/StepsButtons';
import { ActivityContext } from 'src/contexts/activityContext';
import { UserContext } from 'src/contexts/userContext';
import { VillageContext } from 'src/contexts/villageContext';
import { ActivityType } from 'types/activity.type';
import { UserType } from 'types/user.type';

const ContenuLibre = () => {
const router = useRouter();
const { createNewActivity } = React.useContext(ActivityContext);
const { user } = React.useContext(UserContext);
const { selectedPhase } = React.useContext(VillageContext);

const isModerator = user !== null && user.type <= UserType.MEDIATOR;

const onNext = () => {
const success = createNewActivity(ActivityType.CONTENU_LIBRE, selectedPhase);
if (success) {
router.push('/contenu-libre/1');
}
};

if (!isModerator) {
return <h1>Vous n&apos;avez pas accès à cette page, vous devez être modérateur.</h1>;
}

return (
<Base>
<div style={{ width: '100%', padding: '0.5rem 1rem 1rem 1rem' }}>
<div className="width-900">
<h1 style={{ marginTop: '0.5rem' }}>Publication de contenu libre</h1>
<p className="text">
Dans cette activité, nous vous proposons de créer une publication libre. Vous pourrez ensuite partager cette publication et décider de
l&apos;épingler dans le fil d&apos;actualité.
</p>
<StepsButton next={onNext} />
</div>
</div>
</Base>
);
};
export default ContenuLibre;

0 comments on commit 9235c6f

Please sign in to comment.