Merge branch 'dev' of github.com:smart-chain-fr/leCoffre-front into dev
This commit is contained in:
commit
462a8c67c2
@ -7,21 +7,15 @@ type IProps = {
|
|||||||
isOpen: boolean;
|
isOpen: boolean;
|
||||||
onClose?: () => void;
|
onClose?: () => void;
|
||||||
|
|
||||||
onDeleteSuccess: (uid: string) => void;
|
onDelete: (customerUid: string) => void;
|
||||||
};
|
};
|
||||||
|
|
||||||
export default function DeleteCustomerModal(props: IProps) {
|
export default function DeleteCustomerModal(props: IProps) {
|
||||||
const { isOpen, onClose, customerUid, onDeleteSuccess } = props;
|
const { isOpen, onClose, onDelete } = props;
|
||||||
|
|
||||||
const onDelete = useCallback(
|
const handleDelete = useCallback(() => {
|
||||||
() => onDeleteSuccess(customerUid),
|
onDelete(props.customerUid);
|
||||||
// Documents.getInstance()
|
}, [onDelete, props.customerUid]);
|
||||||
// .delete(documentUid)
|
|
||||||
// .then(() => onDeleteSuccess(documentUid))
|
|
||||||
// .then(onClose)
|
|
||||||
// .catch((error) => console.warn(error)),
|
|
||||||
[customerUid, onDeleteSuccess],
|
|
||||||
);
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Modal
|
<Modal
|
||||||
@ -29,7 +23,7 @@ export default function DeleteCustomerModal(props: IProps) {
|
|||||||
onClose={onClose}
|
onClose={onClose}
|
||||||
title={"Êtes-vous sûr de vouloir supprimer ce client du dossier ?"}
|
title={"Êtes-vous sûr de vouloir supprimer ce client du dossier ?"}
|
||||||
firstButton={{ children: "Annuler", onClick: onClose }}
|
firstButton={{ children: "Annuler", onClick: onClose }}
|
||||||
secondButton={{ children: "Supprimer le client", onClick: onDelete }}>
|
secondButton={{ children: "Supprimer le client", onClick: handleDelete }}>
|
||||||
<Typography typo={ETypo.TEXT_MD_light}>
|
<Typography typo={ETypo.TEXT_MD_light}>
|
||||||
Cette action retirera le client de ce dossier. Vous ne pourrez plus récupérer les informations associées à ce client dans ce
|
Cette action retirera le client de ce dossier. Vous ne pourrez plus récupérer les informations associées à ce client dans ce
|
||||||
dossier une fois supprimées.
|
dossier une fois supprimées.
|
||||||
|
@ -10,11 +10,13 @@ import classes from "./classes.module.scss";
|
|||||||
import DeleteCustomerModal from "./DeleteCustomerModal";
|
import DeleteCustomerModal from "./DeleteCustomerModal";
|
||||||
import Link from "next/link";
|
import Link from "next/link";
|
||||||
import Module from "@Front/Config/Module";
|
import Module from "@Front/Config/Module";
|
||||||
|
import { useCallback } from "react";
|
||||||
|
|
||||||
type IProps = {
|
type IProps = {
|
||||||
customer: ICustomer;
|
customer: ICustomer;
|
||||||
anchorStatus: AnchorStatus;
|
anchorStatus: AnchorStatus;
|
||||||
folderUid: string | undefined;
|
folderUid: string | undefined;
|
||||||
|
onDelete: (customerUid: string) => void;
|
||||||
};
|
};
|
||||||
|
|
||||||
export default function ClientBox(props: IProps) {
|
export default function ClientBox(props: IProps) {
|
||||||
@ -22,7 +24,12 @@ export default function ClientBox(props: IProps) {
|
|||||||
|
|
||||||
const { isOpen, open, close } = useOpenable();
|
const { isOpen, open, close } = useOpenable();
|
||||||
|
|
||||||
console.log("customer", customer);
|
const handleDelete = useCallback(
|
||||||
|
(customerUid: string) => {
|
||||||
|
props.onDelete(customerUid);
|
||||||
|
},
|
||||||
|
[props],
|
||||||
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={classes["root"]}>
|
<div className={classes["root"]}>
|
||||||
@ -76,7 +83,7 @@ export default function ClientBox(props: IProps) {
|
|||||||
onClick={open}>
|
onClick={open}>
|
||||||
Supprimer le client
|
Supprimer le client
|
||||||
</Button>
|
</Button>
|
||||||
<DeleteCustomerModal isOpen={isOpen} onClose={close} customerUid={customer.uid ?? ""} onDeleteSuccess={() => {}} />
|
<DeleteCustomerModal isOpen={isOpen} onClose={close} customerUid={customer.uid ?? ""} onDelete={handleDelete} />
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
@ -10,6 +10,10 @@
|
|||||||
gap: var(--spacing-md, 16px);
|
gap: var(--spacing-md, 16px);
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
|
|
||||||
|
.tabs {
|
||||||
|
width: calc(100% - 210px);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.content {
|
.content {
|
||||||
|
@ -2,7 +2,7 @@ import Tabs from "@Front/Components/Elements/Tabs";
|
|||||||
import Customer from "le-coffre-resources/dist/Customer";
|
import Customer from "le-coffre-resources/dist/Customer";
|
||||||
import { OfficeFolder } from "le-coffre-resources/dist/Notary";
|
import { OfficeFolder } from "le-coffre-resources/dist/Notary";
|
||||||
|
|
||||||
import { useMemo, useState } from "react";
|
import { useCallback, useMemo, useState } from "react";
|
||||||
|
|
||||||
import { AnchorStatus } from "..";
|
import { AnchorStatus } from "..";
|
||||||
import classes from "./classes.module.scss";
|
import classes from "./classes.module.scss";
|
||||||
@ -13,6 +13,7 @@ import Module from "@Front/Config/Module";
|
|||||||
import Link from "next/link";
|
import Link from "next/link";
|
||||||
import NoDocument from "./NoDocument";
|
import NoDocument from "./NoDocument";
|
||||||
import DocumentTables from "./DocumentTables";
|
import DocumentTables from "./DocumentTables";
|
||||||
|
import Folders from "@Front/Api/LeCoffreApi/Notary/Folders/Folders";
|
||||||
|
|
||||||
type IProps = {
|
type IProps = {
|
||||||
folder: OfficeFolder;
|
folder: OfficeFolder;
|
||||||
@ -47,10 +48,26 @@ export default function ClientView(props: IProps) {
|
|||||||
|
|
||||||
const doesCustomerHaveDocument = useMemo(() => customer.documents && customer.documents.length > 0, [customer]);
|
const doesCustomerHaveDocument = useMemo(() => customer.documents && customer.documents.length > 0, [customer]);
|
||||||
|
|
||||||
|
const handleClientDelete = useCallback(
|
||||||
|
(customerUid: string) => {
|
||||||
|
if (!folder.uid) return;
|
||||||
|
Folders.getInstance().put(
|
||||||
|
folder.uid,
|
||||||
|
OfficeFolder.hydrate<OfficeFolder>({
|
||||||
|
...folder,
|
||||||
|
customers: folder.customers?.filter((customer) => customer.uid !== customerUid),
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
window.location.reload();
|
||||||
|
},
|
||||||
|
[folder],
|
||||||
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<section className={classes["root"]}>
|
<section className={classes["root"]}>
|
||||||
<div className={classes["tab-container"]}>
|
<div className={classes["tab-container"]}>
|
||||||
{tabs && <Tabs<ICustomer> tabs={tabs} onSelect={setCustomer} />}
|
<div className={classes["tabs"]}>{tabs && <Tabs<ICustomer> tabs={tabs} onSelect={setCustomer} />}</div>
|
||||||
|
|
||||||
{anchorStatus === AnchorStatus.NOT_ANCHORED && (
|
{anchorStatus === AnchorStatus.NOT_ANCHORED && (
|
||||||
<Link
|
<Link
|
||||||
href={Module.getInstance()
|
href={Module.getInstance()
|
||||||
@ -68,7 +85,7 @@ export default function ClientView(props: IProps) {
|
|||||||
</div>
|
</div>
|
||||||
<div className={classes["content"]}>
|
<div className={classes["content"]}>
|
||||||
<div className={classes["client-box"]}>
|
<div className={classes["client-box"]}>
|
||||||
<ClientBox customer={customer} anchorStatus={anchorStatus} folderUid={folder.uid} />
|
<ClientBox customer={customer} anchorStatus={anchorStatus} folderUid={folder.uid} onDelete={handleClientDelete} />
|
||||||
{anchorStatus === AnchorStatus.NOT_ANCHORED && (
|
{anchorStatus === AnchorStatus.NOT_ANCHORED && (
|
||||||
<Link
|
<Link
|
||||||
href={Module.getInstance()
|
href={Module.getInstance()
|
||||||
@ -81,7 +98,7 @@ export default function ClientView(props: IProps) {
|
|||||||
</Link>
|
</Link>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
{doesCustomerHaveDocument ? <DocumentTables documents={customer.documents ?? []}/> : <NoDocument />}
|
{doesCustomerHaveDocument ? <DocumentTables documents={customer.documents ?? []} /> : <NoDocument />}
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
);
|
);
|
||||||
|
@ -78,9 +78,9 @@ export default function InformationSection(props: IProps) {
|
|||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<Typography typo={ETypo.TEXT_MD_REGULAR} color={ETypoColor.COLOR_NEUTRAL_700}>
|
<Typography typo={ETypo.TEXT_MD_REGULAR} color={ETypoColor.COLOR_NEUTRAL_700}>
|
||||||
Notre dossier
|
Note du dossier
|
||||||
</Typography>
|
</Typography>
|
||||||
<Typography typo={ETypo.TEXT_LG_REGULAR}>Travaux de rénovation en cours. </Typography>
|
<Typography typo={ETypo.TEXT_LG_REGULAR}>{folder?.description}</Typography>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
|
@ -1,14 +1,16 @@
|
|||||||
import backgroundImage from "@Assets/images/background_refonte_reverse.svg";
|
import backgroundImage from "@Assets/images/background_refonte_reverse.svg";
|
||||||
import LogoIcon from "@Assets/logo_small_blue.svg";
|
import LogoIcon from "@Assets/logo_small_blue.svg";
|
||||||
|
import Users from "@Front/Api/LeCoffreApi/Notary/Users/Users";
|
||||||
import Button, { EButtonSize, EButtonstyletype, EButtonVariant } from "@Front/Components/DesignSystem/Button";
|
import Button, { EButtonSize, EButtonstyletype, EButtonVariant } from "@Front/Components/DesignSystem/Button";
|
||||||
import Typography, { ETypo, ETypoColor } from "@Front/Components/DesignSystem/Typography";
|
import Typography, { ETypo, ETypoColor } from "@Front/Components/DesignSystem/Typography";
|
||||||
import DefaultNotaryDashboard from "@Front/Components/LayoutTemplates/DefaultNotaryDashboard";
|
import DefaultNotaryDashboard from "@Front/Components/LayoutTemplates/DefaultNotaryDashboard";
|
||||||
import Module from "@Front/Config/Module";
|
import Module from "@Front/Config/Module";
|
||||||
|
import JwtService from "@Front/Services/JwtService/JwtService";
|
||||||
import { DocumentIcon } from "@heroicons/react/24/outline";
|
import { DocumentIcon } from "@heroicons/react/24/outline";
|
||||||
import { OfficeFolder } from "le-coffre-resources/dist/Notary";
|
import User, { OfficeFolder } from "le-coffre-resources/dist/Notary";
|
||||||
import Image from "next/image";
|
import Image from "next/image";
|
||||||
import Link from "next/link";
|
import Link from "next/link";
|
||||||
import { useCallback, useState } from "react";
|
import { useCallback, useEffect, useState } from "react";
|
||||||
|
|
||||||
import classes from "./classes.module.scss";
|
import classes from "./classes.module.scss";
|
||||||
|
|
||||||
@ -16,10 +18,25 @@ export default function Folder() {
|
|||||||
const [_folder, setFolder] = useState<OfficeFolder | null>(null);
|
const [_folder, setFolder] = useState<OfficeFolder | null>(null);
|
||||||
const [_isArchivedModalOpen, _setIsArchivedModalOpen] = useState(true);
|
const [_isArchivedModalOpen, _setIsArchivedModalOpen] = useState(true);
|
||||||
|
|
||||||
|
const [activeUser, setActiveUser] = useState<User | null>();
|
||||||
const onSelectedFolder = useCallback((folder: OfficeFolder): void => {
|
const onSelectedFolder = useCallback((folder: OfficeFolder): void => {
|
||||||
setFolder(folder);
|
setFolder(folder);
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
const decodedJwt = JwtService.getInstance().decodeJwt();
|
||||||
|
if (!decodedJwt) return;
|
||||||
|
Users.getInstance()
|
||||||
|
.getByUid(decodedJwt.userId, {
|
||||||
|
q: {
|
||||||
|
contact: true,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
.then((user) => {
|
||||||
|
setActiveUser(user);
|
||||||
|
});
|
||||||
|
}, []);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<DefaultNotaryDashboard
|
<DefaultNotaryDashboard
|
||||||
title={"Dossier"}
|
title={"Dossier"}
|
||||||
@ -31,9 +48,17 @@ export default function Folder() {
|
|||||||
<div className={classes["title-container"]}>
|
<div className={classes["title-container"]}>
|
||||||
<Image src={LogoIcon} alt="logo" />
|
<Image src={LogoIcon} alt="logo" />
|
||||||
|
|
||||||
<Typography typo={ETypo.TITLE_H1} color={ETypoColor.COLOR_PRIMARY_500}>
|
{activeUser && activeUser.contact && (
|
||||||
Bonjour John, bienvenue sur LeCoffre.io
|
<Typography typo={ETypo.TITLE_H1} color={ETypoColor.COLOR_PRIMARY_500}>
|
||||||
</Typography>
|
Bonjour {activeUser.contact.first_name}, bienvenue sur LeCoffre.io
|
||||||
|
</Typography>
|
||||||
|
)}
|
||||||
|
{!activeUser ||
|
||||||
|
(!activeUser.contact && (
|
||||||
|
<Typography typo={ETypo.TITLE_H1} color={ETypoColor.COLOR_PRIMARY_500}>
|
||||||
|
Bonjour, bienvenue sur LeCoffre.io
|
||||||
|
</Typography>
|
||||||
|
))}
|
||||||
<Typography typo={ETypo.TEXT_LG_REGULAR}>
|
<Typography typo={ETypo.TEXT_LG_REGULAR}>
|
||||||
Commencez par créer votre{" "}
|
Commencez par créer votre{" "}
|
||||||
<Typography typo={ETypo.TEXT_LG_SEMIBOLD} type="span">
|
<Typography typo={ETypo.TEXT_LG_SEMIBOLD} type="span">
|
||||||
|
Loading…
x
Reference in New Issue
Block a user