feat: payment received mail preview

This commit is contained in:
Ahmed Bouhuolia
2024-11-21 14:32:28 +02:00
parent c5c85bdfbe
commit b6f3c0145f
27 changed files with 422 additions and 366 deletions

View File

@@ -261,17 +261,32 @@ export function useSendPaymentReceiveMail(props) {
);
}
export function usePaymentReceiveDefaultOptions(paymentReceiveId, props) {
return useRequestQuery(
export interface GetPaymentReceivedMailStateResponse {
companyName: string;
customerName: string;
entries: Array<{ paymentAmountFormatted: string }>;
from: Array<string>;
fromOptions: Array<{ mail: string; label: string; primary: boolean }>;
paymentAmountFormatted: string;
paymentDate: string;
paymentDateFormatted: string;
to: Array<string>;
toOptions: Array<{ mail: string; label: string; primary: boolean }>;
totalFormatted: string;
}
export function usePaymentReceivedMailState(
paymentReceiveId: number,
props?: UseQueryOptions<GetPaymentReceivedMailStateResponse, Error>,
): UseQueryResult<GetPaymentReceivedMailStateResponse, Error> {
const apiRequest = useApiRequest();
return useQuery<GetPaymentReceivedMailStateResponse, Error>(
[t.PAYMENT_RECEIVE_MAIL_OPTIONS, paymentReceiveId],
{
method: 'get',
url: `sales/payment_receives/${paymentReceiveId}/mail`,
},
{
select: (res) => res.data.data,
...props,
},
() =>
apiRequest
.get(`sales/payment_receives/${paymentReceiveId}/mail`)
.then((res) => transformToCamelCase(res.data?.data)),
);
}

View File

@@ -237,17 +237,29 @@ export function useSendSaleReceiptMail(props) {
);
}
export function useSaleReceiptDefaultOptions(invoiceId, props) {
return useRequestQuery(
[t.SALE_RECEIPT_MAIL_OPTIONS, invoiceId],
{
method: 'get',
url: `sales/receipts/${invoiceId}/mail`,
},
{
select: (res) => res.data.data,
...props,
},
export interface GetSaleReceiptMailStateResponse {
attachReceipt: boolean;
formatArgs: Record<string, any>;
from: string[];
fromOptions: Array<{ mail: string; label: string; primary: boolean; }>
message: string;
subject: string;
to: string[];
toOptions: Array<{ mail: string; label: string; primary: boolean; }>;
}
export function useSaleReceiptMailState(
receiptId: number,
props?: UseQueryOptions<GetSaleReceiptMailStateResponse, Error>,
): UseQueryResult<GetSaleReceiptMailStateResponse, Error> {
const apiRequest = useApiRequest();
return useQuery<GetSaleReceiptMailStateResponse, Error>(
[t.SALE_RECEIPT_MAIL_OPTIONS, receiptId],
() =>
apiRequest
.get(`sales/receipts/${receiptId}/mail`)
.then((res) => transformToCamelCase(res.data.data)),
);
}