Add designs templates

This commit is contained in:
Hillel Coren 2023-11-09 19:02:39 +02:00
parent fd1d6426ad
commit e482cc3de3
1 changed files with 13 additions and 16 deletions

View File

@ -300,29 +300,26 @@ Future<Response?> _loadPDF(
String? activityId,
String? designId,
) async {
http.Response? response;
final store = StoreProvider.of<AppState>(context);
final state = store.state;
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);
} else {
final invitation = invoice.invitations.first;
var url = invitation.downloadLink;
if ((designId ?? '').isNotEmpty) {
url += '&design_id=$designId';
}
response = await WebClient().get(url, state.token, rawResponse: true);
var url = '';
if ((activityId ?? '').isNotEmpty) {
url = '${credential.url}/activities/download_entity/$activityId';
} else {
if (isDeliveryNote) {
url = '${credential.url}/invoices/${invoice.id}/delivery_note';
} else {
url = invitation.downloadLink;
}
return response;
if ((designId ?? '').isNotEmpty) {
url += '&design_id=$designId';
}
}
return await WebClient().get(url, state.token, rawResponse: true);
}