From e482cc3de3d5d0b7f8faa18dc8b4d0d2a6fc8180 Mon Sep 17 00:00:00 2001 From: Hillel Coren Date: Thu, 9 Nov 2023 19:02:39 +0200 Subject: [PATCH] Add designs templates --- lib/ui/invoice/invoice_pdf.dart | 29 +++++++++++++---------------- 1 file changed, 13 insertions(+), 16 deletions(-) diff --git a/lib/ui/invoice/invoice_pdf.dart b/lib/ui/invoice/invoice_pdf.dart index 45f56baef..db3fd7602 100644 --- a/lib/ui/invoice/invoice_pdf.dart +++ b/lib/ui/invoice/invoice_pdf.dart @@ -300,29 +300,26 @@ Future _loadPDF( String? activityId, String? designId, ) async { - http.Response? response; - final store = StoreProvider.of(context); final state = store.state; + final credential = store.state.credentials; + final invitation = invoice.invitations.first; - if ((activityId ?? '').isNotEmpty || isDeliveryNote) { - final credential = store.state.credentials; - var url = isDeliveryNote - ? '/invoices/${invoice.id}/delivery_note' - : '/activities/download_entity/$activityId'; - if ((designId ?? '').isNotEmpty) { - url += '&design_id=$designId'; - } - response = await WebClient() - .get('${credential.url}$url', credential.token, rawResponse: true); + var url = ''; + + if ((activityId ?? '').isNotEmpty) { + url = '${credential.url}/activities/download_entity/$activityId'; } else { - final invitation = invoice.invitations.first; - var url = invitation.downloadLink; + if (isDeliveryNote) { + url = '${credential.url}/invoices/${invoice.id}/delivery_note'; + } else { + url = invitation.downloadLink; + } + if ((designId ?? '').isNotEmpty) { url += '&design_id=$designId'; } - response = await WebClient().get(url, state.token, rawResponse: true); } - return response; + return await WebClient().get(url, state.token, rawResponse: true); }