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