Skip to content

Commit

Permalink
add folder to dispatch routing element and created a Layout to handle…
Browse files Browse the repository at this point in the history
… BackArrow
  • Loading branch information
Neo-Ryo committed Apr 11, 2024
1 parent a051f8e commit 5aa7dd2
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 54 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { useRouter } from 'next/router';
import React, { useEffect } from 'react';

import Layout from '../layout';
import { isFreeContent } from 'src/activity-types/anyActivity';
import { Base } from 'src/components/Base';
import { StepsButton } from 'src/components/StepsButtons';
Expand Down Expand Up @@ -38,7 +39,7 @@ const ContenuLibreStep1: React.FC = () => {
}

return (
<div>
<Layout>
<StepsNavigation currentStep={0} />
<h1>Ecrivez le contenu de votre publication</h1>
<p>
Expand All @@ -48,7 +49,7 @@ const ContenuLibreStep1: React.FC = () => {
<ContentEditor content={activity.content} updateContent={updateContent} addContent={addContent} deleteContent={deleteContent} />

<StepsButton next={onNext} />
</div>
</Layout>
);
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import React from 'react';

import { TextField, Switch, Button } from '@mui/material';

import Layout from '../layout';
import { isFreeContent } from 'src/activity-types/anyActivity';
import { getImage } from 'src/activity-types/freeContent.constants';
import type { FreeContentData } from 'src/activity-types/freeContent.types';
Expand Down Expand Up @@ -61,7 +62,7 @@ const ContenuLibre = () => {
};

return (
<div>
<Layout>
<div style={{ width: '100%', padding: '0.5rem 1rem 1rem 1rem' }}>
<StepsNavigation currentStep={1} />
<div className="width-900">
Expand Down Expand Up @@ -221,7 +222,7 @@ const ContenuLibre = () => {
setSelectedImageUrl(undefined);
}}
/>
</div>
</Layout>
);
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import Backdrop from '@mui/material/Backdrop';
import Button from '@mui/material/Button';
import CircularProgress from '@mui/material/CircularProgress';

import Layout from '../layout';
import { isFreeContent } from 'src/activity-types/anyActivity';
import type { FreeContentData } from 'src/activity-types/freeContent.types';
import { Base } from 'src/components/Base';
Expand Down Expand Up @@ -67,7 +68,7 @@ const ContenuLibre = () => {
}

return (
<div>
<Layout>
<div style={{ width: '100%', padding: '0.5rem 1rem 1rem 1rem' }}>
<StepsNavigation currentStep={2} />
<div className="width-900">
Expand Down Expand Up @@ -127,7 +128,7 @@ const ContenuLibre = () => {
<Backdrop style={{ zIndex: 2000, color: 'white' }} open={isLoading}>
<CircularProgress color="inherit" />
</Backdrop>
</div>
</Layout>
);
};

Expand Down
37 changes: 0 additions & 37 deletions src/pages/admin/newportal/contenulibre/index.tsx

This file was deleted.

31 changes: 31 additions & 0 deletions src/pages/admin/newportal/contenulibre/layout.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import Link from 'next/link';
import type { ReactNode } from 'react';
import React from 'react';

import { UserContext } from 'src/contexts/userContext';
import BackArrow from 'src/svg/back-arrow.svg';
import { UserType } from 'types/user.type';

type Props = {
children: ReactNode;
};

export default function Layout({ children }: Props) {
const { user } = React.useContext(UserContext);
const isModerator = user !== null && user.type <= UserType.MEDIATOR;

if (!isModerator) {
return <h1>Vous n&apos;avez pas accès à cette page, vous devez être modérateur.</h1>;
}
return (
<div>
<Link href="/admin/newportal/create">
<div style={{ cursor: 'pointer', display: 'flex', alignItems: 'center' }}>
<BackArrow />
<h1 style={{ marginLeft: '10px' }}>Créer du contenu libre</h1>
</div>
</Link>
{children}
</div>
);
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
import Link from 'next/link';
import React from 'react';

import { Button } from '@mui/material';

import { bgPage } from 'src/styles/variables.const';
import PelicoSouriant from 'src/svg/pelico/pelico-souriant.svg';

Expand All @@ -11,16 +8,11 @@ const FreeContentSuccess = () => {
<div>
<div style={{ width: '100%', padding: '1rem 1rem 1rem 1rem' }}>
<div style={{ width: '100%', maxWidth: '20rem', margin: '4rem auto', backgroundColor: bgPage, padding: '1rem', borderRadius: '10px' }}>
<p className="text">Votre publication a bien été créée !</p>
<p className="text" style={{ textAlign: 'center' }}>
La publication a été crée ! Rendez-vous dans l’espace de publication pour la rendre visible aux classes
</p>
<PelicoSouriant style={{ width: '60%', height: 'auto', margin: '0 20%' }} />
</div>
<div className="text-center">
<Link href="/" passHref>
<Button component="a" href="/" variant="outlined" color="primary">
Retour à l’accueil
</Button>
</Link>
</div>
</div>
</div>
);
Expand Down

0 comments on commit 5aa7dd2

Please sign in to comment.