import { IntlShape } from 'react-intl' ; import { createPDF , printPDF } from '@client/pdfRenderer' ; import { IApplication } from '@client/applications' ; import { IUserDetails } from '@opencrvs/client/src/utils/userUtils' ; import { Event } from '@client/forms' ; import { IOfflineData } from '@client/offline/reducer' ; import { OptionalData } from '@client/pdfRenderer/transformer/types' ; export function printMoneyReceipt ( intl , application , userDetails , offlineResource ) { if ( ! userDetails ) { throw new Error ( 'No user details found' ) ; } if ( ! offlineResource . templates || ! offlineResource . templates . receipt ) { throw new Error ( 'Money reciept template is misssing in offline data' ) ; } printPDF ( offlineResource . templates . receipt , application , userDetails , offlineResource , intl ) ; } export async function previewCertificate ( intl , application , userDetails , offlineResource , callBack , optionalData ? ) { if ( ! userDetails ) { throw new Error ( 'No user details found' ) ; } await createPDF ( application . event === Event . BIRTH ? offlineResource . templates . certificates . birth : offlineResource . templates . certificates . death , application , userDetails , offlineResource , intl , optionalData ) . getDataUrl ( ( pdf ) => { callBack ( pdf ) ; } ) ; } export function printCertificate ( intl , application , userDetails , offlineResource , optionalData ? ) { if ( ! userDetails ) { throw new Error ( 'No user details found' ) ; } printPDF ( application . event === Event . BIRTH ? offlineResource . templates . certificates . birth : offlineResource . templates . certificates . death , application , userDetails , offlineResource , intl , optionalData ) ; }