🔨 disabled email reminder button when validated documents
This commit is contained in:
parent
1790cd51d6
commit
68468f7793
@ -1,14 +1,15 @@
|
|||||||
|
import Customers from "@Front/Api/LeCoffreApi/Notary/Customers/Customers";
|
||||||
import CheckBox from "@Front/Components/DesignSystem/CheckBox";
|
import CheckBox from "@Front/Components/DesignSystem/CheckBox";
|
||||||
import { IOption } from "@Front/Components/DesignSystem/Form/SelectFieldOld";
|
import { IOption } from "@Front/Components/DesignSystem/Form/SelectFieldOld";
|
||||||
import Modal from "@Front/Components/DesignSystem/Modal";
|
import Modal from "@Front/Components/DesignSystem/Modal";
|
||||||
import Separator, { ESeperatorColor } from "@Front/Components/DesignSystem/Separator";
|
import Separator, { ESeperatorColor } from "@Front/Components/DesignSystem/Separator";
|
||||||
|
import { ToasterService } from "@Front/Components/DesignSystem/Toaster";
|
||||||
import Typography, { ETypo } from "@Front/Components/DesignSystem/Typography";
|
import Typography, { ETypo } from "@Front/Components/DesignSystem/Typography";
|
||||||
import Customer from "le-coffre-resources/dist/Customer";
|
import Customer from "le-coffre-resources/dist/Customer";
|
||||||
|
import { EDocumentStatus } from "le-coffre-resources/dist/Customer/Document";
|
||||||
import React, { useCallback, useMemo, useState } from "react";
|
import React, { useCallback, useMemo, useState } from "react";
|
||||||
|
|
||||||
import classes from "./classes.module.scss";
|
import classes from "./classes.module.scss";
|
||||||
import Customers from "@Front/Api/LeCoffreApi/Notary/Customers/Customers";
|
|
||||||
import { ToasterService } from "@Front/Components/DesignSystem/Toaster";
|
|
||||||
|
|
||||||
type IProps = {
|
type IProps = {
|
||||||
isOpen: boolean;
|
isOpen: boolean;
|
||||||
@ -32,7 +33,9 @@ export default function ReminderModal(props: IProps) {
|
|||||||
|
|
||||||
const documentsOptions: IOption[] = useMemo(
|
const documentsOptions: IOption[] = useMemo(
|
||||||
() =>
|
() =>
|
||||||
customer.documents?.map((document) => {
|
customer.documents
|
||||||
|
?.filter((document) => document.document_status !== EDocumentStatus.VALIDATED)
|
||||||
|
.map((document) => {
|
||||||
return {
|
return {
|
||||||
label: document.document_type?.name ?? "",
|
label: document.document_type?.name ?? "",
|
||||||
value: document.uid ?? "",
|
value: document.uid ?? "",
|
||||||
|
@ -13,15 +13,15 @@ import { useCallback, useEffect, useMemo, useState } from "react";
|
|||||||
|
|
||||||
import classes from "./classes.module.scss";
|
import classes from "./classes.module.scss";
|
||||||
import ReminderModal from "./ReminderModal";
|
import ReminderModal from "./ReminderModal";
|
||||||
|
import { EDocumentStatus } from "le-coffre-resources/dist/Customer/Document";
|
||||||
|
|
||||||
type IProps = {
|
type IProps = {
|
||||||
customer: Customer;
|
customer: Customer;
|
||||||
doesCustomerHaveDocument: boolean;
|
|
||||||
isAnchored: boolean;
|
isAnchored: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
export default function EmailReminder(props: IProps) {
|
export default function EmailReminder(props: IProps) {
|
||||||
const { customer, doesCustomerHaveDocument, isAnchored } = props;
|
const { customer, isAnchored } = props;
|
||||||
const [reminders, setReminders] = useState<DocumentReminder[] | null>(null);
|
const [reminders, setReminders] = useState<DocumentReminder[] | null>(null);
|
||||||
const { isOpen, open, close } = useOpenable();
|
const { isOpen, open, close } = useOpenable();
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
@ -54,6 +54,11 @@ export default function EmailReminder(props: IProps) {
|
|||||||
return Object.keys(remindersGroupByDate ?? {}).length;
|
return Object.keys(remindersGroupByDate ?? {}).length;
|
||||||
}, [reminders]);
|
}, [reminders]);
|
||||||
|
|
||||||
|
const doesCustomerHaveNotValidatedDocuments = useMemo(
|
||||||
|
() => customer.documents && customer.documents.some((document) => document.document_status !== EDocumentStatus.VALIDATED),
|
||||||
|
[customer.documents],
|
||||||
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={classes["root"]}>
|
<div className={classes["root"]}>
|
||||||
{!isAnchored && (
|
{!isAnchored && (
|
||||||
@ -63,7 +68,7 @@ export default function EmailReminder(props: IProps) {
|
|||||||
variant={EButtonVariant.PRIMARY}
|
variant={EButtonVariant.PRIMARY}
|
||||||
styletype={EButtonstyletype.OUTLINED}
|
styletype={EButtonstyletype.OUTLINED}
|
||||||
fullwidth
|
fullwidth
|
||||||
disabled={doesCustomerHaveDocument}>
|
disabled={!doesCustomerHaveNotValidatedDocuments}>
|
||||||
Relancer par mail
|
Relancer par mail
|
||||||
</Button>
|
</Button>
|
||||||
)}
|
)}
|
||||||
|
@ -56,8 +56,6 @@ export default function ClientView(props: IProps) {
|
|||||||
[customers],
|
[customers],
|
||||||
);
|
);
|
||||||
|
|
||||||
const doesCustomerHaveDocument = useMemo(() => customer.documents && customer.documents.length > 0, [customer]);
|
|
||||||
|
|
||||||
const handleClientDelete = useCallback(
|
const handleClientDelete = useCallback(
|
||||||
(customerUid: string) => {
|
(customerUid: string) => {
|
||||||
if (!folder.uid) return;
|
if (!folder.uid) return;
|
||||||
@ -116,7 +114,6 @@ export default function ClientView(props: IProps) {
|
|||||||
)}
|
)}
|
||||||
<EmailReminder
|
<EmailReminder
|
||||||
customer={customer}
|
customer={customer}
|
||||||
doesCustomerHaveDocument={!doesCustomerHaveDocument}
|
|
||||||
isAnchored={anchorStatus !== AnchorStatus.NOT_ANCHORED}
|
isAnchored={anchorStatus !== AnchorStatus.NOT_ANCHORED}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user