From 0ec1a998e5e826cb9d1b8055af39e94773ae81dd Mon Sep 17 00:00:00 2001 From: Maxime Lalo Date: Tue, 18 Apr 2023 12:03:56 +0200 Subject: [PATCH] :sparkles: Refacto back arrow if no url is provided --- .../FolderListContainer/index.tsx | 12 ++++-- .../Components/Elements/BackArrow/index.tsx | 42 +++++++++++++------ .../Layouts/Folder/CreateFolder/index.tsx | 2 +- 3 files changed, 38 insertions(+), 18 deletions(-) diff --git a/src/front/Components/DesignSystem/FolderListContainer/index.tsx b/src/front/Components/DesignSystem/FolderListContainer/index.tsx index d0a73704..031193c4 100644 --- a/src/front/Components/DesignSystem/FolderListContainer/index.tsx +++ b/src/front/Components/DesignSystem/FolderListContainer/index.tsx @@ -1,9 +1,11 @@ +import { IDashBoardFolder } from "@Front/Components/LayoutTemplates/DefaultNotaryDashboard"; +import Link from "next/link"; import React from "react"; -import classes from "./classes.module.scss"; -import SearchBar from "../SearchBar"; + import Button from "../Button"; import FolderList from "../FolderList"; -import { IDashBoardFolder } from "@Front/Components/LayoutTemplates/DefaultNotaryDashboard"; +import SearchBar from "../SearchBar"; +import classes from "./classes.module.scss"; type IProps = { folders: IDashBoardFolder[]; @@ -37,7 +39,9 @@ export default class FolderListContainer extends React.Component />
- + + +
); diff --git a/src/front/Components/Elements/BackArrow/index.tsx b/src/front/Components/Elements/BackArrow/index.tsx index 37ea588c..8e7bc0c8 100644 --- a/src/front/Components/Elements/BackArrow/index.tsx +++ b/src/front/Components/Elements/BackArrow/index.tsx @@ -1,29 +1,45 @@ import ChevronIcon from "@Assets/Icons/chevron.svg"; import Button, { EButtonVariant } from "@Front/Components/DesignSystem/Button"; -import Link from "next/link"; +import { NextRouter, useRouter } from "next/router"; import React from "react"; type IProps = { - url: string; + url?: string; }; +type IPropsClass = IProps & { + router: NextRouter; +}; type IState = {}; -export default class BackArrow extends React.Component { - public constructor(props: IProps) { +class BackArrowClass extends React.Component { + public constructor(props: IPropsClass) { super(props); + + this.handleClick = this.handleClick.bind(this); } public override render(): JSX.Element { return ( - - - + ); } + + private handleClick() { + if (this.props.url) { + this.props.router.push(this.props.url); + } + this.props.router.back(); + } +} + +export default function BackArrow(props: IProps) { + const router = useRouter(); + return ; } diff --git a/src/front/Components/Layouts/Folder/CreateFolder/index.tsx b/src/front/Components/Layouts/Folder/CreateFolder/index.tsx index 8ed23e45..34b16b16 100644 --- a/src/front/Components/Layouts/Folder/CreateFolder/index.tsx +++ b/src/front/Components/Layouts/Folder/CreateFolder/index.tsx @@ -70,7 +70,7 @@ export default class CreateFolder extends BasePage { return (
- + Créer un dossier