Skip to content

Commit

Permalink
Merge pull request #1001 from parlemonde/feat-vil-617/free-content-cr…
Browse files Browse the repository at this point in the history
…eation

Feat vil 617/free content creation
  • Loading branch information
zemzamiouss authored Nov 6, 2024
2 parents 84c40f9 + 9439f90 commit 086e7b7
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 9 deletions.
Binary file not shown.
Binary file not shown.
Binary file removed .yarn/cache/fsevents-patch-6b67494872-10.zip
Binary file not shown.
Binary file removed .yarn/cache/fsevents-patch-afc6995412-10.zip
Binary file not shown.
9 changes: 9 additions & 0 deletions src/components/Navigation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,15 @@ export const Navigation = (): JSX.Element => {
phase: 3,
disabled: firstStoryCreated === false || isParent,
},
...(isTeacher
? [
{
...FREE_CONTENT,
phase: 3,
disabled: false,
},
]
: []),
],
[firstStoryCreated, mascotteActivity, village, isTeacher, isParent],
);
Expand Down
22 changes: 14 additions & 8 deletions src/pages/contenu-libre/2.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import { LightBox } from 'src/components/lightbox/Lightbox';
import { ActivityContext } from 'src/contexts/activityContext';
import { UserContext } from 'src/contexts/userContext';
import { primaryColor } from 'src/styles/variables.const';
import { UserType } from 'types/user.type';

const ContenuLibre = () => {
const router = useRouter();
Expand All @@ -26,6 +27,7 @@ const ContenuLibre = () => {
const [selectedImageUrl, setSelectedImageUrl] = React.useState<string | undefined>(undefined);
const [isAllImagesModalOpen, setIsAllImagesModalOpen] = React.useState(false);
const [isImageModalOpen, setIsImageModalOpen] = React.useState(false);
const isTeacher = user !== null && user.type === UserType.TEACHER;

const data = (activity?.data as FreeContentData) || null;
const errorSteps = React.useMemo(() => {
Expand Down Expand Up @@ -103,14 +105,18 @@ const ContenuLibre = () => {
}}
style={{ width: '100%', marginBottom: '1rem' }}
/>
<div>
Épingler la publication ?
<Switch checked={activity.isPinned} onChange={handlePinnedChange} value={activity.isPinned} color="primary" />
</div>
<div>
Publier sous votre nom la publication ? (Pas Pélico)
<Switch checked={activity.displayAsUser} onChange={handleUserChange} value={activity.displayAsUser} color="primary" />
</div>
{!isTeacher && (
<>
<div>
Épingler la publication ?
<Switch checked={activity.isPinned} onChange={handlePinnedChange} value={activity.isPinned} color="primary" />
</div>
<div>
Publier sous votre nom la publication ? (Pas Pélico)
<Switch checked={activity.displayAsUser} onChange={handleUserChange} value={activity.displayAsUser} color="primary" />
</div>
</>
)}
<p className="text">Image à la une :</p>
<div className="editor" style={{ marginTop: 0 }}>
<div className="image-editor editor__container">
Expand Down
4 changes: 3 additions & 1 deletion src/pages/contenu-libre/index.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable no-console */
import { useRouter } from 'next/router';
import React from 'react';

Expand All @@ -17,6 +18,7 @@ const ContenuLibre = () => {
const { selectedPhase } = React.useContext(VillageContext);

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

const onNext = () => {
const success = createNewActivity(ActivityType.CONTENU_LIBRE, selectedPhase);
Expand All @@ -25,7 +27,7 @@ const ContenuLibre = () => {
}
};

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

Expand Down

0 comments on commit 086e7b7

Please sign in to comment.