feat: receipt send mail preview

This commit is contained in:
Ahmed Bouhuolia
2024-11-20 09:42:55 +02:00
parent 3e591beb03
commit 6103f1e4c7
12 changed files with 378 additions and 29 deletions

View File

@@ -269,3 +269,33 @@ export function useGetReceiptState(
{ ...options },
);
}
interface GetReceiptHtmlResponse {
htmlContent: string;
}
/**
* Retrieves the sale receipt html content.
* @param {number} receiptId
* @param {UseQueryOptions<string, Error>} options
* @returns {UseQueryResult<GetReceiptHtmlResponse, Error>}
*/
export const useGetSaleReceiptHtml = (
receiptId: number,
options?: UseQueryOptions<string, Error>,
): UseQueryResult<GetReceiptHtmlResponse, Error> => {
const apiRequest = useApiRequest();
return useQuery<GetReceiptHtmlResponse, Error>(
['SALE_RECEIPT_HTML', receiptId],
() =>
apiRequest
.get(`sales/receipts/${receiptId}`, {
headers: {
Accept: 'application/json+html',
},
})
.then((res) => transformToCamelCase(res.data)),
{ ...options },
);
};