Send token for PDF download
This commit is contained in:
parent
39d06df0f4
commit
43599feb44
|
|
@ -173,6 +173,8 @@ abstract class AppState implements Built<AppState, AppStateBuilder> {
|
||||||
|
|
||||||
UserCompanyEntity get userCompany => userCompanyState.userCompany;
|
UserCompanyEntity get userCompany => userCompanyState.userCompany;
|
||||||
|
|
||||||
|
String get token => userCompany.token.token;
|
||||||
|
|
||||||
Credentials get credentials =>
|
Credentials get credentials =>
|
||||||
Credentials(token: userCompanyState.token.token, url: authState.url);
|
Credentials(token: userCompanyState.token.token, url: authState.url);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -678,7 +678,7 @@ Future handleCreditAction(BuildContext context, List<BaseEntity> credits,
|
||||||
final url = invitation.downloadLink;
|
final url = invitation.downloadLink;
|
||||||
store.dispatch(StartSaving());
|
store.dispatch(StartSaving());
|
||||||
final http.Response? response =
|
final http.Response? response =
|
||||||
await WebClient().get(url, '', rawResponse: true);
|
await WebClient().get(url, state.token, rawResponse: true);
|
||||||
store.dispatch(StopSaving());
|
store.dispatch(StopSaving());
|
||||||
await Printing.layoutPdf(onLayout: (_) => response!.bodyBytes);
|
await Printing.layoutPdf(onLayout: (_) => response!.bodyBytes);
|
||||||
break;
|
break;
|
||||||
|
|
|
||||||
|
|
@ -824,7 +824,7 @@ void handleInvoiceAction(BuildContext? context, List<BaseEntity> invoices,
|
||||||
final url = invitation.downloadLink;
|
final url = invitation.downloadLink;
|
||||||
store.dispatch(StartSaving());
|
store.dispatch(StartSaving());
|
||||||
final http.Response? response =
|
final http.Response? response =
|
||||||
await WebClient().get(url, '', rawResponse: true);
|
await WebClient().get(url, state.token, rawResponse: true);
|
||||||
store.dispatch(StopSaving());
|
store.dispatch(StopSaving());
|
||||||
await Printing.layoutPdf(onLayout: (_) => response!.bodyBytes);
|
await Printing.layoutPdf(onLayout: (_) => response!.bodyBytes);
|
||||||
break;
|
break;
|
||||||
|
|
|
||||||
|
|
@ -625,7 +625,7 @@ void handlePurchaseOrderAction(BuildContext? context,
|
||||||
final url = invitation.downloadLink;
|
final url = invitation.downloadLink;
|
||||||
store.dispatch(StartSaving());
|
store.dispatch(StartSaving());
|
||||||
final http.Response? response =
|
final http.Response? response =
|
||||||
await WebClient().get(url, '', rawResponse: true);
|
await WebClient().get(url, state.token, rawResponse: true);
|
||||||
store.dispatch(StopSaving());
|
store.dispatch(StopSaving());
|
||||||
await Printing.layoutPdf(onLayout: (_) => response!.bodyBytes);
|
await Printing.layoutPdf(onLayout: (_) => response!.bodyBytes);
|
||||||
break;
|
break;
|
||||||
|
|
|
||||||
|
|
@ -731,7 +731,7 @@ Future handleQuoteAction(
|
||||||
final url = invitation.downloadLink;
|
final url = invitation.downloadLink;
|
||||||
store.dispatch(StartSaving());
|
store.dispatch(StartSaving());
|
||||||
final http.Response? response =
|
final http.Response? response =
|
||||||
await WebClient().get(url, '', rawResponse: true);
|
await WebClient().get(url, state.token, rawResponse: true);
|
||||||
store.dispatch(StopSaving());
|
store.dispatch(StopSaving());
|
||||||
await Printing.layoutPdf(onLayout: (_) => response!.bodyBytes);
|
await Printing.layoutPdf(onLayout: (_) => response!.bodyBytes);
|
||||||
break;
|
break;
|
||||||
|
|
|
||||||
|
|
@ -324,8 +324,10 @@ Future<Response?> _loadPDF(
|
||||||
) async {
|
) async {
|
||||||
http.Response? response;
|
http.Response? response;
|
||||||
|
|
||||||
|
final store = StoreProvider.of<AppState>(context);
|
||||||
|
final state = store.state;
|
||||||
|
|
||||||
if ((activityId ?? '').isNotEmpty || isDeliveryNote) {
|
if ((activityId ?? '').isNotEmpty || isDeliveryNote) {
|
||||||
final store = StoreProvider.of<AppState>(context);
|
|
||||||
final credential = store.state.credentials;
|
final credential = store.state.credentials;
|
||||||
final url = isDeliveryNote
|
final url = isDeliveryNote
|
||||||
? '/invoices/${invoice.id}/delivery_note'
|
? '/invoices/${invoice.id}/delivery_note'
|
||||||
|
|
@ -335,7 +337,7 @@ Future<Response?> _loadPDF(
|
||||||
} else {
|
} else {
|
||||||
final invitation = invoice.invitations.first;
|
final invitation = invoice.invitations.first;
|
||||||
final url = invitation.downloadLink;
|
final url = invitation.downloadLink;
|
||||||
response = await WebClient().get(url, '', rawResponse: true);
|
response = await WebClient().get(url, state.token, rawResponse: true);
|
||||||
}
|
}
|
||||||
|
|
||||||
return response;
|
return response;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue