From 4960b51ee3ad7f69eae9f0367df295a6e2a2cb84 Mon Sep 17 00:00:00 2001 From: Maxime Lalo Date: Wed, 24 Jul 2024 12:39:18 +0200 Subject: [PATCH 01/12] :sparkles: Searchbar fully working --- .../FolderListContainer/index.tsx | 199 ++++++++---------- .../SearchBar/classes.module.scss | 80 +++++-- .../DesignSystem/SearchBar/index.tsx | 83 ++++---- 3 files changed, 189 insertions(+), 173 deletions(-) diff --git a/src/front/Components/DesignSystem/FolderListContainer/index.tsx b/src/front/Components/DesignSystem/FolderListContainer/index.tsx index 0ac30339..4c3f0a39 100644 --- a/src/front/Components/DesignSystem/FolderListContainer/index.tsx +++ b/src/front/Components/DesignSystem/FolderListContainer/index.tsx @@ -2,8 +2,8 @@ import Module from "@Front/Config/Module"; import { OfficeFolder } from "le-coffre-resources/dist/Notary"; import { EDocumentStatus } from "le-coffre-resources/dist/Notary/Document"; import Link from "next/link"; -import { NextRouter, useRouter } from "next/router"; -import React from "react"; +import { useRouter } from "next/router"; +import React, { useCallback, useEffect } from "react"; import BlockList, { IBlock } from "../BlockList"; import Button from "../Button"; @@ -19,110 +19,17 @@ type IProps = { onCloseLeftSide?: () => void; }; -type IPropsClass = IProps & { - router: NextRouter; - selectedFolder: string; -}; +export default function FolderListContainer(props: IProps) { + const router = useRouter(); + const { folderUid } = router.query; + const { folders, isArchived } = props; -type IState = { - filteredFolders: OfficeFolder[]; - blocks: IBlock[]; -}; - -class FolderListContainerClass extends React.Component { - private redirectPath: string = this.props.isArchived + const redirectPath: string = isArchived ? Module.getInstance().get().modules.pages.Folder.pages.FolderArchived.pages.FolderInformation.props.path : Module.getInstance().get().modules.pages.Folder.pages.FolderInformation.props.path; - public constructor(props: IPropsClass) { - super(props); - this.state = { - filteredFolders: this.props.folders, - blocks: this.getBlocks(this.props.folders), - }; - this.filterFolders = this.filterFolders.bind(this); - this.onSelectedFolder = this.onSelectedFolder.bind(this); - } - public override render(): JSX.Element { - const navigatePath = Module.getInstance().get().modules.pages.Folder.pages.CreateFolder.props.path; - return ( -
-
-
- -
-
- -
-
- {!this.props.isArchived && ( -
- - - - - -
- )} -
- ); - } - - public override componentDidUpdate(prevProps: Readonly, prevState: Readonly, snapshot?: any): void { - if (prevProps.selectedFolder !== this.props.selectedFolder) { - this.setState({ filteredFolders: this.props.folders, blocks: this.getBlocks(this.props.folders) }); - } - } - private getBlocks(folders: OfficeFolder[]): IBlock[] { - const pendingFolders = folders - .filter((folder) => { - const pendingDocuments = (folder.documents ?? []).filter( - (document) => document.document_status === EDocumentStatus.DEPOSITED, - ); - return pendingDocuments.length >= 1; - }) - .sort((folder1, folder2) => { - return folder1.created_at! > folder2.created_at! ? -1 : 1; - }); - - const otherFolders = folders - .filter((folder) => { - const pendingDocuments = (folder.documents ?? []).filter( - (document) => document.document_status === EDocumentStatus.DEPOSITED, - ); - return pendingDocuments.length === 0; - }) - .sort((folder1, folder2) => { - return folder1.created_at! > folder2.created_at! ? -1 : 1; - }); - - return [...pendingFolders, ...otherFolders].map((folder) => { - return { - id: folder.uid!, - name: folder.folder_number! + " - " + folder.name!, - selected: this.props.selectedFolder === folder.uid, - hasFlag: folder.documents?.some((document) => document.document_status === EDocumentStatus.DEPOSITED), - }; - }); - } - - private onSelectedFolder(block: IBlock) { - const folder = this.props.folders.find((folder) => folder.uid === block.id); - if (!folder) return; - this.props.onSelectedFolder && this.props.onSelectedFolder(folder); - const path = this.redirectPath.replace("[folderUid]", folder.uid ?? ""); - this.props.router.push(path); - } - - private filterFolders(value: string): void { - const filteredFolders: OfficeFolder[] = this.props.folders.filter((folder) => { + const filterFolders = (value: string): void => { + const filteredFolders: OfficeFolder[] = folders.filter((folder) => { const name = folder.name.toLowerCase(); const number = folder.folder_number.toLowerCase(); value = value.toLowerCase(); @@ -139,12 +46,86 @@ class FolderListContainerClass extends React.Component { return name.includes(value) || number.includes(value); }); - this.setState({ filteredFolders, blocks: this.getBlocks(filteredFolders) }); - } -} + setBlocks(getBlocks(filteredFolders)); + }; -export default function FolderListContainer(props: IProps) { - const router = useRouter(); - const { folderUid } = router.query; - return ; + const getBlocks = useCallback( + (folders: OfficeFolder[]): IBlock[] => { + const pendingFolders = folders + .filter((folder) => { + const pendingDocuments = (folder.documents ?? []).filter( + (document) => document.document_status === EDocumentStatus.DEPOSITED, + ); + return pendingDocuments.length >= 1; + }) + .sort((folder1, folder2) => { + return folder1.created_at! > folder2.created_at! ? -1 : 1; + }); + + const otherFolders = folders + .filter((folder) => { + const pendingDocuments = (folder.documents ?? []).filter( + (document) => document.document_status === EDocumentStatus.DEPOSITED, + ); + return pendingDocuments.length === 0; + }) + .sort((folder1, folder2) => { + return folder1.created_at! > folder2.created_at! ? -1 : 1; + }); + + return [...pendingFolders, ...otherFolders].map((folder) => { + return { + id: folder.uid!, + name: folder.folder_number! + " - " + folder.name!, + selected: folderUid === folder.uid, + hasFlag: folder.documents?.some((document) => document.document_status === EDocumentStatus.DEPOSITED), + }; + }); + }, + [folderUid], + ); + + const [blocks, setBlocks] = React.useState(getBlocks(folders)); + + const onSelectedFolder = (block: IBlock) => { + const folder = folders.find((folder) => folder.uid === block.id); + if (!folder) return; + props.onSelectedFolder && props.onSelectedFolder(folder); + const path = redirectPath.replace("[folderUid]", folder.uid ?? ""); + router.push(path); + }; + + useEffect(() => { + setBlocks(getBlocks(folders)); + }, [folders, getBlocks]); + + const navigatePath = Module.getInstance().get().modules.pages.Folder.pages.CreateFolder.props.path; + return ( +
+
+
+ +
+
+ +
+
+ {!isArchived && ( +
+ + + + + +
+ )} +
+ ); } diff --git a/src/front/Components/DesignSystem/SearchBar/classes.module.scss b/src/front/Components/DesignSystem/SearchBar/classes.module.scss index 326e7950..e4350b4e 100644 --- a/src/front/Components/DesignSystem/SearchBar/classes.module.scss +++ b/src/front/Components/DesignSystem/SearchBar/classes.module.scss @@ -2,30 +2,66 @@ .root { display: flex; - align-items: center; - padding-left: 24px; - background-color: var(--color-generic-white); - border: 1px solid var(--color-neutral-200); - position: relative; + padding: var(--spacing-2, 16px) var(--spacing-sm, 8px); + align-items: flex-start; + gap: var(--spacing-2, 16px); - .fake-placeholder { - position: absolute; - left: 47px; - top: 24px; - color: var(--color-neutral-500); - pointer-events: none; + border-radius: var(--input-radius, 0px); + border: 1px solid var(--input-main-border-default, #d7dce0); + background: var(--input-background, #fff); + + &:hover { + border-radius: var(--input-radius, 0px); + border: 1px solid var(--input-main-border-hovered, #b4bec5); + background: var(--input-background, #fff); } - .input { - border: 0; - margin-left: 8px; - padding: 24px 0; - width: 100%; - font-family: "Inter", sans-serif; - font-style: normal; - font-weight: 400; - font-size: 18px; - line-height: 22px; - color: var(--color-neutral-500); + &[data-has-value="true"] { + border-radius: var(--input-radius, 0px); + border: 1px solid var(--input-main-border-filled, #6d7e8a); + background: var(--input-background, #fff); + } + + &[data-is-focused="true"] { + border-radius: var(--input-radius, 0px); + border: 1px solid var(--input-main-border-focused, #005bcb); + background: var(--input-background, #fff); + } + + .input-container { + display: flex; + flex: 1; + gap: 8px; + padding: 0px var(--spacing-2, 16px); + + .input { + flex: 1; + border: none; + + color: var(--input-placeholder-filled, #24282e); + + /* text/md/semibold */ + font-family: var(--font-text-family, Poppins); + font-size: 16px; + font-style: normal; + font-weight: var(--font-text-weight-semibold, 600); + line-height: normal; + letter-spacing: 0.08px; + + &::placeholder { + color: var(--input-placeholder-empty, #6d7e8a); + /* text/md/regular */ + font-family: var(--font-text-family, Poppins); + font-size: 16px; + font-style: normal; + font-weight: var(--font-text-weight-regular, 400); + line-height: normal; + letter-spacing: 0.08px; + } + } + + .cross { + cursor: pointer; + } } } diff --git a/src/front/Components/DesignSystem/SearchBar/index.tsx b/src/front/Components/DesignSystem/SearchBar/index.tsx index 8c16ee0c..9289a034 100644 --- a/src/front/Components/DesignSystem/SearchBar/index.tsx +++ b/src/front/Components/DesignSystem/SearchBar/index.tsx @@ -1,54 +1,53 @@ -import LoopIcon from "@Assets/Icons/loop.svg"; -import Image from "next/image"; -import React from "react"; +import React, { useCallback } from "react"; -import Typography, { ETypo, ETypoColor } from "../Typography"; import classes from "./classes.module.scss"; +import { MagnifyingGlassIcon, XMarkIcon } from "@heroicons/react/24/outline"; type IProps = { onChange?: (input: string) => void; placeholder?: string; }; -type IState = { - hasValue: boolean; -}; +export default function SearchBar({ onChange, placeholder = "Rechercher" }: IProps) { + const [isFocused, setIsFocused] = React.useState(false); + const [value, setValue] = React.useState(""); -export default class SearchBar extends React.Component { - static defaultProps = { - placeholder: "Search", - }; + const handleOnChange = useCallback( + (event: React.ChangeEvent) => { + setValue(event.target.value); + onChange && onChange(event.target.value); + }, + [onChange], + ); - public constructor(props: IProps) { - super(props); - this.state = { - hasValue: false, - }; - this.doesInputHaveValue = this.doesInputHaveValue.bind(this); - this.onChange = this.onChange.bind(this); - } - public override render(): JSX.Element { - return ( -
- Loop icon - {!this.state.hasValue && ( - -
{this.props.placeholder}
-
- )} - + const handleFocus = useCallback(() => { + setIsFocused(true); + }, []); + + const handleBlur = useCallback(() => { + setIsFocused(false); + }, []); + + const clearValue = useCallback(() => { + setValue(""); + onChange && onChange(""); + }, [onChange]); + + return ( + + ); } From 8ff373271b6ed21f6affa0397486e73c1cbf7fdb Mon Sep 17 00:00:00 2001 From: Maxime Lalo Date: Wed, 24 Jul 2024 14:54:32 +0200 Subject: [PATCH 02/12] :sparkles: New nav without responsive --- .../DesignSystem/BlockList/index.tsx | 48 ------------- .../FolderArchivedListContainer/index.tsx | 10 +-- .../FolderListContainer/index.tsx | 33 +++++---- .../SearchBar/classes.module.scss | 1 + .../DesignSystem/SearchBar/index.tsx | 24 +++---- .../BlockList/Block/classes.module.scss | 29 ++++++++ .../SearchBlockList/BlockList/Block/index.tsx | 44 ++++++++++++ .../BlockList/classes.module.scss | 0 .../SearchBlockList/BlockList/index.tsx | 23 +++++++ .../SearchBlockList/classes.module.scss | 30 ++++++++ .../DesignSystem/SearchBlockList/index.tsx | 69 +++++++++++++++++++ .../DesignSystem/Typography/index.tsx | 9 +-- 12 files changed, 233 insertions(+), 87 deletions(-) delete mode 100644 src/front/Components/DesignSystem/BlockList/index.tsx create mode 100644 src/front/Components/DesignSystem/SearchBlockList/BlockList/Block/classes.module.scss create mode 100644 src/front/Components/DesignSystem/SearchBlockList/BlockList/Block/index.tsx rename src/front/Components/DesignSystem/{ => SearchBlockList}/BlockList/classes.module.scss (100%) create mode 100644 src/front/Components/DesignSystem/SearchBlockList/BlockList/index.tsx create mode 100644 src/front/Components/DesignSystem/SearchBlockList/classes.module.scss create mode 100644 src/front/Components/DesignSystem/SearchBlockList/index.tsx diff --git a/src/front/Components/DesignSystem/BlockList/index.tsx b/src/front/Components/DesignSystem/BlockList/index.tsx deleted file mode 100644 index e733a3ac..00000000 --- a/src/front/Components/DesignSystem/BlockList/index.tsx +++ /dev/null @@ -1,48 +0,0 @@ -import React, { useCallback } from "react"; -import classes from "./classes.module.scss"; -import Typography, { ETypo } from "../Typography"; -import ChevronIcon from "@Assets/Icons/chevron.svg"; -import Image from "next/image"; -import WarningBadge from "../WarningBadge"; - -export type IBlock = { - name: string; - id: string; - selected: boolean; - rightIcon?: JSX.Element; - hasFlag?: boolean; -}; - -type IProps = { - blocks: IBlock[]; - onSelectedBlock: (block: IBlock) => void; -}; -export default function BlockList({ blocks, onSelectedBlock }: IProps) { - const selectBlock = useCallback( - (e: React.MouseEvent) => { - onSelectedBlock && onSelectedBlock(blocks.find((folder) => folder.id === e.currentTarget.id)!); - }, - [blocks, onSelectedBlock], - ); - - return ( -
- {blocks.map((folder) => { - return ( -
-
-
- {folder.name} -
-
- {folder.hasFlag && } - {folder.rightIcon} - chevron -
-
-
- ); - })} -
- ); -} diff --git a/src/front/Components/DesignSystem/FolderArchivedListContainer/index.tsx b/src/front/Components/DesignSystem/FolderArchivedListContainer/index.tsx index 19797c52..c77c890c 100644 --- a/src/front/Components/DesignSystem/FolderArchivedListContainer/index.tsx +++ b/src/front/Components/DesignSystem/FolderArchivedListContainer/index.tsx @@ -5,12 +5,13 @@ import Link from "next/link"; import { NextRouter, useRouter } from "next/router"; import React from "react"; -import BlockList, { IBlock } from "../BlockList"; import Button from "../Button"; import SearchBar from "../SearchBar"; import classes from "./classes.module.scss"; import Rules, { RulesMode } from "@Front/Components/Elements/Rules"; import { AppRuleActions, AppRuleNames } from "@Front/Api/Entities/rule"; +import { IBlock } from "../SearchBlockList/BlockList/Block"; +import BlockList from "../SearchBlockList/BlockList"; type IProps = { folders: OfficeFolder[]; @@ -106,9 +107,10 @@ class FolderArchivedListContainerClass extends React.Component { return { id: folder.uid!, - name: folder.folder_number! + " - " + folder.name!, - selected: this.props.selectedFolder === folder.uid, - hasFlag: folder.documents?.some((document) => document.document_status === EDocumentStatus.DEPOSITED), + primaryText: folder.name, + isActive: this.props.selectedFolder === folder.uid, + secondaryText: folder.folder_number, + showAlert: folder.documents?.some((document) => document.document_status === EDocumentStatus.DEPOSITED), }; }); } diff --git a/src/front/Components/DesignSystem/FolderListContainer/index.tsx b/src/front/Components/DesignSystem/FolderListContainer/index.tsx index 4c3f0a39..3d04a58d 100644 --- a/src/front/Components/DesignSystem/FolderListContainer/index.tsx +++ b/src/front/Components/DesignSystem/FolderListContainer/index.tsx @@ -5,12 +5,14 @@ import Link from "next/link"; import { useRouter } from "next/router"; import React, { useCallback, useEffect } from "react"; -import BlockList, { IBlock } from "../BlockList"; import Button from "../Button"; import SearchBar from "../SearchBar"; import classes from "./classes.module.scss"; import Rules, { RulesMode } from "@Front/Components/Elements/Rules"; import { AppRuleActions, AppRuleNames } from "@Front/Api/Entities/rule"; +import { IBlock } from "../SearchBlockList/BlockList/Block"; +import BlockList from "../SearchBlockList/BlockList"; +import SearchBlockList from "../SearchBlockList"; type IProps = { folders: OfficeFolder[]; @@ -76,9 +78,10 @@ export default function FolderListContainer(props: IProps) { return [...pendingFolders, ...otherFolders].map((folder) => { return { id: folder.uid!, - name: folder.folder_number! + " - " + folder.name!, - selected: folderUid === folder.uid, - hasFlag: folder.documents?.some((document) => document.document_status === EDocumentStatus.DEPOSITED), + primaryText: folder.name, + secondaryText: folder.folder_number, + isActive: folderUid === folder.uid, + showAlert: folder.documents?.some((document) => document.document_status === EDocumentStatus.DEPOSITED), }; }); }, @@ -99,18 +102,18 @@ export default function FolderListContainer(props: IProps) { setBlocks(getBlocks(folders)); }, [folders, getBlocks]); - const navigatePath = Module.getInstance().get().modules.pages.Folder.pages.CreateFolder.props.path; + //const navigatePath = Module.getInstance().get().modules.pages.Folder.pages.CreateFolder.props.path; return (
-
-
- -
-
- -
-
- {!isArchived && ( + + {/* {!isArchived && (
- )} + )} */}
); } diff --git a/src/front/Components/DesignSystem/SearchBar/classes.module.scss b/src/front/Components/DesignSystem/SearchBar/classes.module.scss index e4350b4e..bfb3e58c 100644 --- a/src/front/Components/DesignSystem/SearchBar/classes.module.scss +++ b/src/front/Components/DesignSystem/SearchBar/classes.module.scss @@ -47,6 +47,7 @@ font-weight: var(--font-text-weight-semibold, 600); line-height: normal; letter-spacing: 0.08px; + width: 100%; &::placeholder { color: var(--input-placeholder-empty, #6d7e8a); diff --git a/src/front/Components/DesignSystem/SearchBar/index.tsx b/src/front/Components/DesignSystem/SearchBar/index.tsx index 9289a034..57a7af19 100644 --- a/src/front/Components/DesignSystem/SearchBar/index.tsx +++ b/src/front/Components/DesignSystem/SearchBar/index.tsx @@ -12,26 +12,18 @@ export default function SearchBar({ onChange, placeholder = "Rechercher" }: IPro const [isFocused, setIsFocused] = React.useState(false); const [value, setValue] = React.useState(""); - const handleOnChange = useCallback( - (event: React.ChangeEvent) => { - setValue(event.target.value); - onChange && onChange(event.target.value); + const changeValue = useCallback( + (value: string) => { + setValue(value); + onChange && onChange(value); }, [onChange], ); - const handleFocus = useCallback(() => { - setIsFocused(true); - }, []); - - const handleBlur = useCallback(() => { - setIsFocused(false); - }, []); - - const clearValue = useCallback(() => { - setValue(""); - onChange && onChange(""); - }, [onChange]); + const handleOnChange = (event: React.ChangeEvent) => changeValue(event.target.value); + const handleFocus = () => setIsFocused(true); + const handleBlur = () => setIsFocused(false); + const clearValue = () => changeValue(""); return (
); } diff --git a/src/front/Components/Elements/Tabs/index.tsx b/src/front/Components/Elements/Tabs/index.tsx index 7906b750..c90dbc36 100644 --- a/src/front/Components/Elements/Tabs/index.tsx +++ b/src/front/Components/Elements/Tabs/index.tsx @@ -8,11 +8,12 @@ import useOpenable from "@Front/Hooks/useOpenable"; export type ITabValue = T & { id: unknown; -} +}; type ITabInternal = ITab & { key?: string; value: ITabValue; + hasWarning?: boolean; }; type IProps = { @@ -100,6 +101,7 @@ export default function Tabs({ onSelect, tabs: propsTabs }: IProps) { value={element.value} onSelect={handleSelect} isSelected={element.value.id === selectedTab.id} + hasWarning={element.hasWarning} /> ))} @@ -112,6 +114,7 @@ export default function Tabs({ onSelect, tabs: propsTabs }: IProps) { value={element.value} onSelect={handleSelect} isSelected={element.value.id === selectedTab.id} + hasWarning={element.hasWarning} /> ))} From c868b8cd23a538e34b9e4bce449d74589b1c993a Mon Sep 17 00:00:00 2001 From: Maxime Lalo Date: Wed, 24 Jul 2024 17:01:46 +0200 Subject: [PATCH 08/12] :sparkles: warning on tabs --- .../Layouts/Folder/FolderInformation/ClientView/index.tsx | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/front/Components/Layouts/Folder/FolderInformation/ClientView/index.tsx b/src/front/Components/Layouts/Folder/FolderInformation/ClientView/index.tsx index cce182f9..264db94d 100644 --- a/src/front/Components/Layouts/Folder/FolderInformation/ClientView/index.tsx +++ b/src/front/Components/Layouts/Folder/FolderInformation/ClientView/index.tsx @@ -14,6 +14,7 @@ import Link from "next/link"; import NoDocument from "./NoDocument"; import DocumentTables from "./DocumentTables"; import Folders from "@Front/Api/LeCoffreApi/Notary/Folders/Folders"; +import { EDocumentStatus } from "le-coffre-resources/dist/Customer/Document"; type IProps = { folder: OfficeFolder; @@ -42,6 +43,9 @@ export default function ClientView(props: IProps) { label: `${customer.contact?.first_name} ${customer.contact?.last_name}`, key: customer.uid, value: customer, + hasWarning: + customer.documents && + customer.documents.filter((document) => document.document_status === EDocumentStatus.DEPOSITED).length > 0, })), [customers], ); From 6f16d05463611bd20cc3884ff021a5b13576064d Mon Sep 17 00:00:00 2001 From: Maxime Lalo Date: Wed, 24 Jul 2024 17:11:26 +0200 Subject: [PATCH 09/12] :sparkles: NEw componnt --- .../FolderListContainer/index.tsx | 1 + .../DeedTypeListContainer/index.tsx | 54 ++++++------------- 2 files changed, 17 insertions(+), 38 deletions(-) diff --git a/src/front/Components/DesignSystem/FolderListContainer/index.tsx b/src/front/Components/DesignSystem/FolderListContainer/index.tsx index 6b8c3e46..53df5b74 100644 --- a/src/front/Components/DesignSystem/FolderListContainer/index.tsx +++ b/src/front/Components/DesignSystem/FolderListContainer/index.tsx @@ -64,6 +64,7 @@ export default function FolderListContainer(props: IProps) { const [blocks, setBlocks] = React.useState(getBlocks(folders)); const onSelectedFolder = (block: IBlock) => { + props.onCloseLeftSide && props.onCloseLeftSide(); const folder = folders.find((folder) => folder.uid === block.id); if (!folder) return; props.onSelectedFolder && props.onSelectedFolder(folder); diff --git a/src/front/Components/LayoutTemplates/DefaultDeedTypeDashboard/DeedTypeListContainer/index.tsx b/src/front/Components/LayoutTemplates/DefaultDeedTypeDashboard/DeedTypeListContainer/index.tsx index 6dc34c85..4386d52d 100644 --- a/src/front/Components/LayoutTemplates/DefaultDeedTypeDashboard/DeedTypeListContainer/index.tsx +++ b/src/front/Components/LayoutTemplates/DefaultDeedTypeDashboard/DeedTypeListContainer/index.tsx @@ -1,15 +1,12 @@ import DeedTypes from "@Front/Api/LeCoffreApi/Admin/DeedTypes/DeedTypes"; -import Button from "@Front/Components/DesignSystem/Button"; -import SearchBar from "@Front/Components/DesignSystem/SearchBar"; import Module from "@Front/Config/Module"; import { DeedType } from "le-coffre-resources/dist/Admin"; -import Link from "next/link"; import { useRouter } from "next/router"; -import React, { useCallback, useState } from "react"; +import React, { useCallback } from "react"; import classes from "./classes.module.scss"; import { IBlock } from "@Front/Components/DesignSystem/SearchBlockList/BlockList/Block"; -import BlockList from "@Front/Components/DesignSystem/SearchBlockList/BlockList"; +import SearchBlockList from "@Front/Components/DesignSystem/SearchBlockList"; type IProps = { deedTypes: DeedType[]; @@ -18,20 +15,9 @@ type IProps = { }; export default function DeedListContainer(props: IProps) { - const [filteredUsers, setFilteredUsers] = useState(props.deedTypes); const router = useRouter(); const { deedTypeUid } = router.query; - const filterDeeds = useCallback( - (input: string) => { - const filteredUsers = props.deedTypes.filter((deedType) => { - return deedType.name?.toLowerCase().includes(input.toLowerCase()); - }); - setFilteredUsers(filteredUsers); - }, - [props.deedTypes], - ); - const onSelectedBlock = useCallback( (block: IBlock) => { props.onCloseLeftSide && props.onCloseLeftSide(); @@ -43,28 +29,20 @@ export default function DeedListContainer(props: IProps) { return (
-
-
- -
-
- { - return { - primaryText: deed.name, - id: deed.uid!, - selected: deedTypeUid === deed.uid, - }; - })} - onSelectedBlock={onSelectedBlock} - /> -
-
-
- - - -
+ { + return { + primaryText: deed.name, + id: deed.uid!, + selected: deedTypeUid === deed.uid, + }; + })} + onSelectedBlock={onSelectedBlock} + bottomButton={{ + link: Module.getInstance().get().modules.pages.DeedTypes.pages.Create.props.path, + text: "Créer un type d'acte", + }} + />
); } From 02994a29591fbb9cc1b6a65cc8783ecd308b8956 Mon Sep 17 00:00:00 2001 From: Maxime Lalo Date: Wed, 24 Jul 2024 17:37:22 +0200 Subject: [PATCH 10/12] :sparkles: New left nav everywhere + fix button --- .../FolderArchivedListContainer/index.tsx | 33 +--------- .../SearchBlockList/BlockList/Block/index.tsx | 4 +- .../SearchBlockList/classes.module.scss | 1 - .../DesignSystem/SearchBlockList/index.tsx | 17 +++-- .../DesignSystem/Typography/index.tsx | 1 + .../CollaboratorListContainer/index.tsx | 57 ++++------------- .../DeedTypeListContainer/index.tsx | 2 +- .../DocumentTypeListContainer/index.tsx | 53 +++++---------- .../OfficeListContainer/index.tsx | 44 ++++--------- .../RoleListContainer/index.tsx | 64 ++++++------------- .../UserListContainer/index.tsx | 45 ++++--------- 11 files changed, 93 insertions(+), 228 deletions(-) diff --git a/src/front/Components/DesignSystem/FolderArchivedListContainer/index.tsx b/src/front/Components/DesignSystem/FolderArchivedListContainer/index.tsx index c77c890c..30f9824b 100644 --- a/src/front/Components/DesignSystem/FolderArchivedListContainer/index.tsx +++ b/src/front/Components/DesignSystem/FolderArchivedListContainer/index.tsx @@ -1,17 +1,12 @@ import Module from "@Front/Config/Module"; import { OfficeFolder } from "le-coffre-resources/dist/Notary"; import { EDocumentStatus } from "le-coffre-resources/dist/Notary/Document"; -import Link from "next/link"; import { NextRouter, useRouter } from "next/router"; import React from "react"; -import Button from "../Button"; -import SearchBar from "../SearchBar"; import classes from "./classes.module.scss"; -import Rules, { RulesMode } from "@Front/Components/Elements/Rules"; -import { AppRuleActions, AppRuleNames } from "@Front/Api/Entities/rule"; import { IBlock } from "../SearchBlockList/BlockList/Block"; -import BlockList from "../SearchBlockList/BlockList"; +import SearchBlockList from "../SearchBlockList"; type IProps = { folders: OfficeFolder[]; @@ -45,33 +40,9 @@ class FolderArchivedListContainerClass extends React.Component -
-
- -
-
- -
-
- {!this.props.isArchived && ( -
- - - - - -
- )} + ); } diff --git a/src/front/Components/DesignSystem/SearchBlockList/BlockList/Block/index.tsx b/src/front/Components/DesignSystem/SearchBlockList/BlockList/Block/index.tsx index c9914f64..19ec5787 100644 --- a/src/front/Components/DesignSystem/SearchBlockList/BlockList/Block/index.tsx +++ b/src/front/Components/DesignSystem/SearchBlockList/BlockList/Block/index.tsx @@ -29,7 +29,9 @@ export default function Block(props: IProps) { {secondaryText} - + {primaryText} diff --git a/src/front/Components/DesignSystem/SearchBlockList/classes.module.scss b/src/front/Components/DesignSystem/SearchBlockList/classes.module.scss index 9f53834d..e7bcaa27 100644 --- a/src/front/Components/DesignSystem/SearchBlockList/classes.module.scss +++ b/src/front/Components/DesignSystem/SearchBlockList/classes.module.scss @@ -24,6 +24,5 @@ .bottom-container { margin-top: auto; - width: 336px; } } diff --git a/src/front/Components/DesignSystem/SearchBlockList/index.tsx b/src/front/Components/DesignSystem/SearchBlockList/index.tsx index 46434edd..3dd43a52 100644 --- a/src/front/Components/DesignSystem/SearchBlockList/index.tsx +++ b/src/front/Components/DesignSystem/SearchBlockList/index.tsx @@ -4,7 +4,7 @@ import { IBlock } from "./BlockList/Block"; import classes from "./classes.module.scss"; import SearchBar from "../SearchBar"; import Button from "../Button"; -import Link from "next/link"; +import { useRouter } from "next/router"; type IProps = { blocks: IBlock[]; @@ -17,6 +17,8 @@ type IProps = { export default function SearchBlockList(props: IProps) { const { blocks, onSelectedBlock, bottomButton } = props; + const router = useRouter(); + const [blocksShowing, setBlocksShowing] = useState(blocks); const bottomButtonRef = useRef(null); const searchBarRef = useRef(null); @@ -47,6 +49,11 @@ export default function SearchBlockList(props: IProps) { }; }, [bottomButton]); + const redirectOnBottomButtonClick = useCallback(() => { + if (!bottomButton) return; + router.push(bottomButton.link); + }, [bottomButton, router]); + useEffect(() => { setBlocksShowing(blocks); }, [blocks]); @@ -60,9 +67,11 @@ export default function SearchBlockList(props: IProps) { {bottomButton && ( - - - +
+ +
)} ); diff --git a/src/front/Components/DesignSystem/Typography/index.tsx b/src/front/Components/DesignSystem/Typography/index.tsx index 17db7964..fd0d019f 100644 --- a/src/front/Components/DesignSystem/Typography/index.tsx +++ b/src/front/Components/DesignSystem/Typography/index.tsx @@ -154,6 +154,7 @@ export enum ETypoColor { CONTRAST_HOVERED = "--contrast-hovered", ERROR_WEAK_CONTRAST = "--error-weak-contrast", NAVIGATION_BUTTON_CONTRAST_DEFAULT = "--navigation-button-contrast-default", + NAVIGATION_BUTTON_CONTRAST_ACTIVE = "--navigation-button-contrast-active", } export default function Typography(props: IProps) { diff --git a/src/front/Components/LayoutTemplates/DefaultCollaboratorDashboard/CollaboratorListContainer/index.tsx b/src/front/Components/LayoutTemplates/DefaultCollaboratorDashboard/CollaboratorListContainer/index.tsx index 9df33274..eee22e10 100644 --- a/src/front/Components/LayoutTemplates/DefaultCollaboratorDashboard/CollaboratorListContainer/index.tsx +++ b/src/front/Components/LayoutTemplates/DefaultCollaboratorDashboard/CollaboratorListContainer/index.tsx @@ -1,12 +1,11 @@ -import React, { useCallback, useState } from "react"; +import React, { useCallback } from "react"; import classes from "./classes.module.scss"; -import SearchBar from "@Front/Components/DesignSystem/SearchBar"; import User from "le-coffre-resources/dist/Notary"; import { useRouter } from "next/router"; import Module from "@Front/Config/Module"; import { IBlock } from "@Front/Components/DesignSystem/SearchBlockList/BlockList/Block"; -import BlockList from "@Front/Components/DesignSystem/SearchBlockList/BlockList"; +import SearchBlockList from "@Front/Components/DesignSystem/SearchBlockList"; type IProps = { collaborators: User[]; @@ -15,22 +14,9 @@ type IProps = { }; export default function CollaboratorListContainer(props: IProps) { - const [filteredUsers, setFilteredUsers] = useState(props.collaborators); const router = useRouter(); const { collaboratorUid } = router.query; - const filterUsers = useCallback( - (input: string) => { - const filteredUsers = props.collaborators.filter((user) => { - return ( - user.contact?.first_name?.toLowerCase().includes(input.toLowerCase()) || - user.contact?.last_name?.toLowerCase().includes(input.toLowerCase()) - ); - }); - setFilteredUsers(filteredUsers); - }, - [props.collaborators], - ); const onSelectedBlock = useCallback( (block: IBlock) => { @@ -43,35 +29,16 @@ export default function CollaboratorListContainer(props: IProps) { return (
-
-
- -
-
- { - return { - primaryText: user.contact?.first_name + " " + user.contact?.last_name, - id: user.uid!, - selected: user.uid === collaboratorUid, - rightIcon: user.seats?.some((seat) => new Date(seat.subscription!.end_date) >= new Date()) ? ( -
- ) : ( - <> - ), - }; - })} - onSelectedBlock={onSelectedBlock} - /> -
-
+ { + return { + primaryText: user.contact?.first_name + " " + user.contact?.last_name, + id: user.uid!, + isActive: user.uid === collaboratorUid, + }; + })} + onSelectedBlock={onSelectedBlock} + />
); } diff --git a/src/front/Components/LayoutTemplates/DefaultDeedTypeDashboard/DeedTypeListContainer/index.tsx b/src/front/Components/LayoutTemplates/DefaultDeedTypeDashboard/DeedTypeListContainer/index.tsx index 4386d52d..fd94a36d 100644 --- a/src/front/Components/LayoutTemplates/DefaultDeedTypeDashboard/DeedTypeListContainer/index.tsx +++ b/src/front/Components/LayoutTemplates/DefaultDeedTypeDashboard/DeedTypeListContainer/index.tsx @@ -34,7 +34,7 @@ export default function DeedListContainer(props: IProps) { return { primaryText: deed.name, id: deed.uid!, - selected: deedTypeUid === deed.uid, + isActive: deedTypeUid === deed.uid, }; })} onSelectedBlock={onSelectedBlock} diff --git a/src/front/Components/LayoutTemplates/DefaultDocumentTypesDashboard/DocumentTypeListContainer/index.tsx b/src/front/Components/LayoutTemplates/DefaultDocumentTypesDashboard/DocumentTypeListContainer/index.tsx index 3e41b785..da7fb26f 100644 --- a/src/front/Components/LayoutTemplates/DefaultDocumentTypesDashboard/DocumentTypeListContainer/index.tsx +++ b/src/front/Components/LayoutTemplates/DefaultDocumentTypesDashboard/DocumentTypeListContainer/index.tsx @@ -1,14 +1,11 @@ -import Button from "@Front/Components/DesignSystem/Button"; -import SearchBar from "@Front/Components/DesignSystem/SearchBar"; import Module from "@Front/Config/Module"; import { DocumentType } from "le-coffre-resources/dist/SuperAdmin"; -import Link from "next/link"; import { useRouter } from "next/router"; -import React, { useCallback, useState } from "react"; +import React, { useCallback } from "react"; import classes from "./classes.module.scss"; import { IBlock } from "@Front/Components/DesignSystem/SearchBlockList/BlockList/Block"; -import BlockList from "@Front/Components/DesignSystem/SearchBlockList/BlockList"; +import SearchBlockList from "@Front/Components/DesignSystem/SearchBlockList"; type IProps = { documentTypes: DocumentType[]; @@ -17,19 +14,9 @@ type IProps = { }; export default function DocumentTypeListContainer(props: IProps) { - const [filteredDocumentTypes, setFilteredDocumentTypes] = useState(props.documentTypes); const router = useRouter(); const { documentTypeUid } = router.query; - const filterDocumentTypes = useCallback( - (input: string) => { - const filteredDocumentTypes = props.documentTypes.filter((documentType) => { - return documentType.name.toLowerCase().includes(input.toLowerCase()); - }); - setFilteredDocumentTypes(filteredDocumentTypes); - }, - [props.documentTypes], - ); const onSelectedBlock = useCallback( (block: IBlock) => { @@ -42,28 +29,20 @@ export default function DocumentTypeListContainer(props: IProps) { return (
-
-
- -
-
- { - return { - primaryText: documentType.name, - id: documentType.uid!, - selected: documentType.uid === documentTypeUid, - }; - })} - onSelectedBlock={onSelectedBlock} - /> -
-
-
- - - -
+ { + return { + primaryText: documentType.name, + id: documentType.uid!, + isActive: documentType.uid === documentTypeUid, + }; + })} + onSelectedBlock={onSelectedBlock} + bottomButton={{ + link: Module.getInstance().get().modules.pages.DocumentTypes.pages.Create.props.path, + text: "Créer un type de document", + }} + />
); } diff --git a/src/front/Components/LayoutTemplates/DefaultOfficeDashboard/OfficeListContainer/index.tsx b/src/front/Components/LayoutTemplates/DefaultOfficeDashboard/OfficeListContainer/index.tsx index b6db9a28..b3c92662 100644 --- a/src/front/Components/LayoutTemplates/DefaultOfficeDashboard/OfficeListContainer/index.tsx +++ b/src/front/Components/LayoutTemplates/DefaultOfficeDashboard/OfficeListContainer/index.tsx @@ -1,12 +1,11 @@ -import SearchBar from "@Front/Components/DesignSystem/SearchBar"; import Module from "@Front/Config/Module"; import { Office } from "le-coffre-resources/dist/SuperAdmin"; import { useRouter } from "next/router"; -import React, { useCallback, useState } from "react"; +import React, { useCallback } from "react"; import classes from "./classes.module.scss"; import { IBlock } from "@Front/Components/DesignSystem/SearchBlockList/BlockList/Block"; -import BlockList from "@Front/Components/DesignSystem/SearchBlockList/BlockList"; +import SearchBlockList from "@Front/Components/DesignSystem/SearchBlockList"; type IProps = { offices: Office[]; @@ -15,21 +14,9 @@ type IProps = { }; export default function OfficeListContainer(props: IProps) { - const [filteredOffices, setFilteredOffices] = useState(props.offices); const router = useRouter(); const { officeUid } = router.query; - const filterOffices = useCallback( - (input: string) => { - const filteredOffices = props.offices.filter((office) => { - return ( - office.name.toLowerCase().includes(input.toLowerCase()) || office.crpcen?.toLowerCase().includes(input.toLowerCase()) - ); - }); - setFilteredOffices(filteredOffices); - }, - [props.offices], - ); const onSelectedBlock = useCallback( (block: IBlock) => { @@ -42,23 +29,16 @@ export default function OfficeListContainer(props: IProps) { return (
-
-
- -
-
- { - return { - primaryText: office.crpcen + " - " + office.name, - id: office.uid!, - selected: office.uid === officeUid, - }; - })} - onSelectedBlock={onSelectedBlock} - /> -
-
+ { + return { + primaryText: office.crpcen + " - " + office.name, + id: office.uid!, + isActive: office.uid === officeUid, + }; + })} + onSelectedBlock={onSelectedBlock} + />
); } diff --git a/src/front/Components/LayoutTemplates/DefaultRoleDashboard/RoleListContainer/index.tsx b/src/front/Components/LayoutTemplates/DefaultRoleDashboard/RoleListContainer/index.tsx index 1ee4c395..b02309c9 100644 --- a/src/front/Components/LayoutTemplates/DefaultRoleDashboard/RoleListContainer/index.tsx +++ b/src/front/Components/LayoutTemplates/DefaultRoleDashboard/RoleListContainer/index.tsx @@ -1,14 +1,11 @@ -import SearchBar from "@Front/Components/DesignSystem/SearchBar"; import Module from "@Front/Config/Module"; import { OfficeRole } from "le-coffre-resources/dist/Admin"; import { useRouter } from "next/router"; -import React, { useCallback, useState } from "react"; +import React, { useCallback } from "react"; import classes from "./classes.module.scss"; -import Link from "next/link"; -import Button from "@Front/Components/DesignSystem/Button"; import { IBlock } from "@Front/Components/DesignSystem/SearchBlockList/BlockList/Block"; -import BlockList from "@Front/Components/DesignSystem/SearchBlockList/BlockList"; +import SearchBlockList from "@Front/Components/DesignSystem/SearchBlockList"; type IProps = { roles: OfficeRole[]; @@ -17,21 +14,10 @@ type IProps = { }; export default function RoleListContainer(props: IProps) { - const [filteredRoles, setFilteredRoles] = useState(props.roles); const router = useRouter(); const { roleUid } = router.query; - const filterRoles = useCallback( - (input: string) => { - const filteredRoles = props.roles.filter((role) => { - return role.name?.toLowerCase().includes(input.toLowerCase()); - }); - setFilteredRoles(filteredRoles); - }, - [props.roles], - ); - const onSelectedBlock = useCallback( (block: IBlock) => { props.onCloseLeftSide && props.onCloseLeftSide(); @@ -43,33 +29,25 @@ export default function RoleListContainer(props: IProps) { return (
-
-
- -
-
- { - if (role.name === "admin") return false; - return true; - }) - .map((role) => { - return { - primaryText: role.name, - id: role.uid!, - selected: role.uid === roleUid, - }; - })} - onSelectedBlock={onSelectedBlock} - /> -
-
-
- - - -
+ { + if (role.name === "admin") return false; + return true; + }) + .map((role) => { + return { + primaryText: role.name, + id: role.uid!, + isActive: role.uid === roleUid, + }; + })} + onSelectedBlock={onSelectedBlock} + bottomButton={{ + link: Module.getInstance().get().modules.pages.Roles.pages.Create.props.path, + text: "Créer un rôle", + }} + />
); } diff --git a/src/front/Components/LayoutTemplates/DefaultUserDashboard/UserListContainer/index.tsx b/src/front/Components/LayoutTemplates/DefaultUserDashboard/UserListContainer/index.tsx index f543cba6..0842539d 100644 --- a/src/front/Components/LayoutTemplates/DefaultUserDashboard/UserListContainer/index.tsx +++ b/src/front/Components/LayoutTemplates/DefaultUserDashboard/UserListContainer/index.tsx @@ -1,12 +1,11 @@ -import SearchBar from "@Front/Components/DesignSystem/SearchBar"; import Module from "@Front/Config/Module"; import User from "le-coffre-resources/dist/Notary"; import { useRouter } from "next/router"; -import React, { useCallback, useState } from "react"; +import React, { useCallback } from "react"; import classes from "./classes.module.scss"; import { IBlock } from "@Front/Components/DesignSystem/SearchBlockList/BlockList/Block"; -import BlockList from "@Front/Components/DesignSystem/SearchBlockList/BlockList"; +import SearchBlockList from "@Front/Components/DesignSystem/SearchBlockList"; type IProps = { users: User[]; @@ -15,22 +14,9 @@ type IProps = { }; export default function UserListContainer(props: IProps) { - const [filteredUsers, setFilteredUsers] = useState(props.users); const router = useRouter(); const { userUid } = router.query; - const filterUsers = useCallback( - (input: string) => { - const filteredUsers = props.users.filter((user) => { - return ( - user.contact?.first_name?.toLowerCase().includes(input.toLowerCase()) || - user.contact?.last_name?.toLowerCase().includes(input.toLowerCase()) - ); - }); - setFilteredUsers(filteredUsers); - }, - [props.users], - ); const onSelectedBlock = useCallback( (block: IBlock) => { @@ -43,23 +29,16 @@ export default function UserListContainer(props: IProps) { return (
-
-
- -
-
- { - return { - primaryText: user.contact?.first_name + " " + user.contact?.last_name, - id: user.uid!, - selected: user.uid === userUid, - }; - })} - onSelectedBlock={onSelectedBlock} - /> -
-
+ { + return { + primaryText: user.contact?.first_name + " " + user.contact?.last_name, + id: user.uid!, + isActive: user.uid === userUid, + }; + })} + onSelectedBlock={onSelectedBlock} + />
); } From 19fec6e4a2cfe492c0e8c75a4e5b46515769d87c Mon Sep 17 00:00:00 2001 From: Maxime Lalo Date: Wed, 24 Jul 2024 17:46:50 +0200 Subject: [PATCH 11/12] :bug: fonts bug --- src/front/index.scss | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/front/index.scss b/src/front/index.scss index f0794043..3b8e1f7e 100644 --- a/src/front/index.scss +++ b/src/front/index.scss @@ -1,5 +1,5 @@ -@import "@Themes/constants.scss"; @import "@Themes/fonts.scss"; +@import "@Themes/constants.scss"; @import "@Themes/variables.scss"; * { From 53f98b2f36ede7e8ce52f602f0742613ffc1b8af Mon Sep 17 00:00:00 2001 From: Maxime Lalo Date: Wed, 24 Jul 2024 17:53:37 +0200 Subject: [PATCH 12/12] :bug: trying to fix font --- src/pages/_app.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/_app.tsx b/src/pages/_app.tsx index c2205983..4776411b 100644 --- a/src/pages/_app.tsx +++ b/src/pages/_app.tsx @@ -1,6 +1,6 @@ +import "@Front/index.scss"; import { DefaultLayout } from "@Front/Components/LayoutTemplates/DefaultLayout"; import { FrontendVariables } from "@Front/Config/VariablesFront"; -import "@Front/index.scss"; import type { NextPage } from "next"; import type { AppType, AppProps } from "next/app"; import { useEffect, type ReactElement, type ReactNode } from "react";