Add CC email
This commit is contained in:
parent
ad51025af5
commit
cc4a36d83e
|
|
@ -111,13 +111,16 @@ class CreditRepository {
|
|||
InvoiceEntity credit,
|
||||
EmailTemplate template,
|
||||
String subject,
|
||||
String body) async {
|
||||
String body,
|
||||
String ccEmail,
|
||||
) async {
|
||||
final data = {
|
||||
'entity': '${credit.entityType}',
|
||||
'entity_id': credit.id,
|
||||
'template': 'email_template_$template',
|
||||
'body': body,
|
||||
'subject': subject,
|
||||
'cc_email': ccEmail,
|
||||
};
|
||||
|
||||
final dynamic response = await webClient.post(
|
||||
|
|
|
|||
|
|
@ -125,13 +125,16 @@ class InvoiceRepository {
|
|||
InvoiceEntity invoice,
|
||||
EmailTemplate template,
|
||||
String subject,
|
||||
String body) async {
|
||||
String body,
|
||||
String ccEmail,
|
||||
) async {
|
||||
final data = {
|
||||
'entity': '${invoice.entityType}',
|
||||
'entity_id': invoice.id,
|
||||
'template': 'email_template_$template',
|
||||
'body': body,
|
||||
'subject': subject,
|
||||
'cc_email': ccEmail,
|
||||
};
|
||||
|
||||
final dynamic response = await webClient.post(
|
||||
|
|
|
|||
|
|
@ -119,13 +119,16 @@ class PurchaseOrderRepository {
|
|||
InvoiceEntity purchaseOrder,
|
||||
EmailTemplate template,
|
||||
String subject,
|
||||
String body) async {
|
||||
String body,
|
||||
String ccEmail,
|
||||
) async {
|
||||
final data = {
|
||||
'entity': '${purchaseOrder.entityType}',
|
||||
'entity_id': purchaseOrder.id,
|
||||
'template': 'email_template_$template',
|
||||
'body': body,
|
||||
'subject': subject,
|
||||
'cc_email': ccEmail,
|
||||
};
|
||||
|
||||
final dynamic response = await webClient.post(
|
||||
|
|
|
|||
|
|
@ -117,14 +117,21 @@ class QuoteRepository {
|
|||
return quoteResponse.data;
|
||||
}
|
||||
|
||||
Future<InvoiceEntity> emailQuote(Credentials credentials, InvoiceEntity quote,
|
||||
EmailTemplate template, String subject, String body) async {
|
||||
Future<InvoiceEntity> emailQuote(
|
||||
Credentials credentials,
|
||||
InvoiceEntity quote,
|
||||
EmailTemplate template,
|
||||
String subject,
|
||||
String body,
|
||||
String ccEmail,
|
||||
) async {
|
||||
final data = {
|
||||
'entity': '${quote.entityType}',
|
||||
'entity_id': quote.id,
|
||||
'template': 'email_template_$template',
|
||||
'body': body,
|
||||
'subject': subject,
|
||||
'cc_email': ccEmail,
|
||||
};
|
||||
|
||||
final dynamic response = await webClient.post(
|
||||
|
|
|
|||
|
|
@ -227,14 +227,21 @@ class SaveCreditFailure implements StopSaving {
|
|||
}
|
||||
|
||||
class EmailCreditRequest implements StartSaving {
|
||||
EmailCreditRequest(
|
||||
{this.completer, this.creditId, this.template, this.subject, this.body});
|
||||
EmailCreditRequest({
|
||||
@required this.completer,
|
||||
@required this.creditId,
|
||||
@required this.template,
|
||||
@required this.subject,
|
||||
@required this.body,
|
||||
@required this.ccEmail,
|
||||
});
|
||||
|
||||
final Completer completer;
|
||||
final String creditId;
|
||||
final EmailTemplate template;
|
||||
final String subject;
|
||||
final String body;
|
||||
final String ccEmail;
|
||||
}
|
||||
|
||||
class EmailCreditSuccess implements StopSaving, PersistData {}
|
||||
|
|
|
|||
|
|
@ -273,8 +273,14 @@ Middleware<AppState> _emailCredit(CreditRepository repository) {
|
|||
final action = dynamicAction as EmailCreditRequest;
|
||||
final origCredit = store.state.creditState.map[action.creditId];
|
||||
repository
|
||||
.emailCredit(store.state.credentials, origCredit, action.template,
|
||||
action.subject, action.body)
|
||||
.emailCredit(
|
||||
store.state.credentials,
|
||||
origCredit,
|
||||
action.template,
|
||||
action.subject,
|
||||
action.body,
|
||||
action.ccEmail,
|
||||
)
|
||||
.then((void _) {
|
||||
store.dispatch(EmailCreditSuccess());
|
||||
if (action.completer != null) {
|
||||
|
|
|
|||
|
|
@ -228,14 +228,21 @@ class SaveInvoiceFailure implements StopSaving {
|
|||
}
|
||||
|
||||
class EmailInvoiceRequest implements StartSaving {
|
||||
EmailInvoiceRequest(
|
||||
{this.completer, this.invoiceId, this.template, this.subject, this.body});
|
||||
EmailInvoiceRequest({
|
||||
@required this.completer,
|
||||
@required this.invoiceId,
|
||||
@required this.template,
|
||||
@required this.subject,
|
||||
@required this.body,
|
||||
@required this.ccEmail,
|
||||
});
|
||||
|
||||
final Completer completer;
|
||||
final String invoiceId;
|
||||
final EmailTemplate template;
|
||||
final String subject;
|
||||
final String body;
|
||||
final String ccEmail;
|
||||
}
|
||||
|
||||
class EmailInvoiceSuccess implements StopSaving, PersistData {
|
||||
|
|
|
|||
|
|
@ -353,8 +353,14 @@ Middleware<AppState> _emailInvoice(InvoiceRepository repository) {
|
|||
final action = dynamicAction as EmailInvoiceRequest;
|
||||
final origInvoice = store.state.invoiceState.map[action.invoiceId];
|
||||
repository
|
||||
.emailInvoice(store.state.credentials, origInvoice, action.template,
|
||||
action.subject, action.body)
|
||||
.emailInvoice(
|
||||
store.state.credentials,
|
||||
origInvoice,
|
||||
action.template,
|
||||
action.subject,
|
||||
action.body,
|
||||
action.ccEmail,
|
||||
)
|
||||
.then((InvoiceEntity invoice) {
|
||||
store.dispatch(EmailInvoiceSuccess(invoice: invoice));
|
||||
store.dispatch(RefreshData());
|
||||
|
|
|
|||
|
|
@ -336,18 +336,21 @@ class RestorePurchaseOrdersFailure implements StopSaving {
|
|||
}
|
||||
|
||||
class EmailPurchaseOrderRequest implements StartSaving {
|
||||
EmailPurchaseOrderRequest(
|
||||
{this.completer,
|
||||
this.purchaseOrderId,
|
||||
this.template,
|
||||
this.subject,
|
||||
this.body});
|
||||
EmailPurchaseOrderRequest({
|
||||
@required this.completer,
|
||||
@required this.purchaseOrderId,
|
||||
@required this.template,
|
||||
@required this.subject,
|
||||
@required this.body,
|
||||
@required this.ccEmail,
|
||||
});
|
||||
|
||||
final Completer completer;
|
||||
final String purchaseOrderId;
|
||||
final EmailTemplate template;
|
||||
final String subject;
|
||||
final String body;
|
||||
final String ccEmail;
|
||||
}
|
||||
|
||||
class EmailPurchaseOrderSuccess implements StopSaving, PersistData {
|
||||
|
|
|
|||
|
|
@ -391,8 +391,14 @@ Middleware<AppState> _emailPurchaseOrder(PurchaseOrderRepository repository) {
|
|||
final origPurchaseOrder =
|
||||
store.state.purchaseOrderState.map[action.purchaseOrderId];
|
||||
repository
|
||||
.emailPurchaseOrder(store.state.credentials, origPurchaseOrder,
|
||||
action.template, action.subject, action.body)
|
||||
.emailPurchaseOrder(
|
||||
store.state.credentials,
|
||||
origPurchaseOrder,
|
||||
action.template,
|
||||
action.subject,
|
||||
action.body,
|
||||
action.ccEmail,
|
||||
)
|
||||
.then((purchaseOrder) {
|
||||
store.dispatch(EmailPurchaseOrderSuccess(purchaseOrder));
|
||||
if (action.completer != null) {
|
||||
|
|
|
|||
|
|
@ -227,14 +227,21 @@ class SaveQuoteFailure implements StopSaving {
|
|||
}
|
||||
|
||||
class EmailQuoteRequest implements StartSaving {
|
||||
EmailQuoteRequest(
|
||||
{this.completer, this.quoteId, this.template, this.subject, this.body});
|
||||
EmailQuoteRequest({
|
||||
@required this.completer,
|
||||
@required this.quoteId,
|
||||
@required this.template,
|
||||
@required this.subject,
|
||||
@required this.body,
|
||||
@required this.ccEmail,
|
||||
});
|
||||
|
||||
final Completer completer;
|
||||
final String quoteId;
|
||||
final EmailTemplate template;
|
||||
final String subject;
|
||||
final String body;
|
||||
final String ccEmail;
|
||||
}
|
||||
|
||||
class EmailQuoteSuccess implements StopSaving, PersistData {
|
||||
|
|
|
|||
|
|
@ -315,7 +315,7 @@ Middleware<AppState> _emailQuote(QuoteRepository repository) {
|
|||
final origQuote = store.state.quoteState.map[action.quoteId];
|
||||
repository
|
||||
.emailQuote(store.state.credentials, origQuote, action.template,
|
||||
action.subject, action.body)
|
||||
action.subject, action.body, action.ccEmail,)
|
||||
.then((quote) {
|
||||
store.dispatch(EmailQuoteSuccess(quote));
|
||||
if (action.completer != null) {
|
||||
|
|
|
|||
|
|
@ -420,8 +420,13 @@ class _InvoiceEmailViewState extends State<InvoiceEmailView>
|
|||
saveLabel: localization.send,
|
||||
onSavePressed: (context) {
|
||||
if (state.account.accountSmsVerified || state.isSelfHosted) {
|
||||
viewModel.onSendPressed(context, selectedTemplate,
|
||||
_subjectController.text, _bodyController.text);
|
||||
viewModel.onSendPressed(
|
||||
context,
|
||||
selectedTemplate,
|
||||
_subjectController.text,
|
||||
_bodyController.text,
|
||||
'',
|
||||
);
|
||||
} else {
|
||||
showMessageDialog(
|
||||
context: context, message: localization.verifyPhoneNumberHelp);
|
||||
|
|
@ -506,8 +511,13 @@ class _InvoiceEmailViewState extends State<InvoiceEmailView>
|
|||
),
|
||||
saveLabel: localization.send,
|
||||
onSavePressed: (context) {
|
||||
viewModel.onSendPressed(context, selectedTemplate,
|
||||
_subjectController.text, _bodyController.text);
|
||||
viewModel.onSendPressed(
|
||||
context,
|
||||
selectedTemplate,
|
||||
_subjectController.text,
|
||||
_bodyController.text,
|
||||
'',
|
||||
);
|
||||
},
|
||||
body: TabBarView(
|
||||
controller: _controller,
|
||||
|
|
|
|||
|
|
@ -59,7 +59,7 @@ class EmailCreditVM extends EmailEntityVM {
|
|||
ClientEntity client,
|
||||
VendorEntity vendor,
|
||||
Function loadClient,
|
||||
Function(BuildContext, EmailTemplate, String, String) onSendPressed,
|
||||
Function(BuildContext, EmailTemplate, String, String, String) onSendPressed,
|
||||
}) : super(
|
||||
state: state,
|
||||
isLoading: isLoading,
|
||||
|
|
@ -84,7 +84,7 @@ class EmailCreditVM extends EmailEntityVM {
|
|||
loadClient: () {
|
||||
store.dispatch(LoadClient(clientId: credit.clientId));
|
||||
},
|
||||
onSendPressed: (context, template, subject, body) {
|
||||
onSendPressed: (context, template, subject, body, ccEmail) {
|
||||
final completer = snackBarCompleter<Null>(
|
||||
context, AppLocalization.of(context).emailedCredit,
|
||||
shouldPop: isMobile(context));
|
||||
|
|
@ -99,6 +99,7 @@ class EmailCreditVM extends EmailEntityVM {
|
|||
template: template,
|
||||
subject: subject,
|
||||
body: body,
|
||||
ccEmail: ccEmail,
|
||||
));
|
||||
},
|
||||
);
|
||||
|
|
|
|||
|
|
@ -68,7 +68,8 @@ abstract class EmailEntityVM {
|
|||
final InvoiceEntity invoice;
|
||||
final ClientEntity client;
|
||||
final VendorEntity vendor;
|
||||
final Function(BuildContext, EmailTemplate, String, String) onSendPressed;
|
||||
final Function(BuildContext, EmailTemplate, String, String, String)
|
||||
onSendPressed;
|
||||
}
|
||||
|
||||
class EmailInvoiceVM extends EmailEntityVM {
|
||||
|
|
@ -80,7 +81,7 @@ class EmailInvoiceVM extends EmailEntityVM {
|
|||
InvoiceEntity invoice,
|
||||
ClientEntity client,
|
||||
VendorEntity vendor,
|
||||
Function(BuildContext, EmailTemplate, String, String) onSendPressed,
|
||||
Function(BuildContext, EmailTemplate, String, String, String) onSendPressed,
|
||||
}) : super(
|
||||
state: state,
|
||||
isLoading: isLoading,
|
||||
|
|
@ -104,7 +105,7 @@ class EmailInvoiceVM extends EmailEntityVM {
|
|||
invoice: invoice,
|
||||
client: state.clientState.map[invoice.clientId] ??
|
||||
ClientEntity(id: invoice.clientId),
|
||||
onSendPressed: (context, template, subject, body) {
|
||||
onSendPressed: (context, template, subject, body, ccEmail) {
|
||||
final completer = snackBarCompleter<Null>(
|
||||
context, AppLocalization.of(context).emailedInvoice,
|
||||
shouldPop: isMobile(context));
|
||||
|
|
@ -119,6 +120,7 @@ class EmailInvoiceVM extends EmailEntityVM {
|
|||
template: template,
|
||||
subject: subject,
|
||||
body: body,
|
||||
ccEmail: ccEmail,
|
||||
));
|
||||
},
|
||||
);
|
||||
|
|
|
|||
|
|
@ -59,7 +59,8 @@ class EmailPurchaseOrderVM extends EmailEntityVM {
|
|||
@required ClientEntity client,
|
||||
@required VendorEntity vendor,
|
||||
@required
|
||||
Function(BuildContext, EmailTemplate, String, String) onSendPressed,
|
||||
Function(BuildContext, EmailTemplate, String, String, String)
|
||||
onSendPressed,
|
||||
}) : super(
|
||||
state: state,
|
||||
isLoading: isLoading,
|
||||
|
|
@ -83,7 +84,7 @@ class EmailPurchaseOrderVM extends EmailEntityVM {
|
|||
invoice: purchaseOrder,
|
||||
client: state.clientState.map[purchaseOrder.clientId],
|
||||
vendor: state.vendorState.map[purchaseOrder.vendorId],
|
||||
onSendPressed: (context, template, subject, body) {
|
||||
onSendPressed: (context, template, subject, body, ccEmail) {
|
||||
final completer = snackBarCompleter<Null>(
|
||||
context, AppLocalization.of(context).emailedPurchaseOrder,
|
||||
shouldPop: isMobile(context));
|
||||
|
|
@ -98,6 +99,7 @@ class EmailPurchaseOrderVM extends EmailEntityVM {
|
|||
template: template,
|
||||
subject: subject,
|
||||
body: body,
|
||||
ccEmail: ccEmail,
|
||||
));
|
||||
},
|
||||
);
|
||||
|
|
|
|||
|
|
@ -59,7 +59,8 @@ class EmailQuoteVM extends EmailEntityVM {
|
|||
@required ClientEntity client,
|
||||
@required VendorEntity vendor,
|
||||
@required
|
||||
Function(BuildContext, EmailTemplate, String, String) onSendPressed,
|
||||
Function(BuildContext, EmailTemplate, String, String, String)
|
||||
onSendPressed,
|
||||
}) : super(
|
||||
state: state,
|
||||
isLoading: isLoading,
|
||||
|
|
@ -82,7 +83,7 @@ class EmailQuoteVM extends EmailEntityVM {
|
|||
invoice: quote,
|
||||
client: state.clientState.map[quote.clientId],
|
||||
vendor: state.vendorState.map[quote.vendorId],
|
||||
onSendPressed: (context, template, subject, body) {
|
||||
onSendPressed: (context, template, subject, body, ccEmail) {
|
||||
final completer = snackBarCompleter<Null>(
|
||||
context, AppLocalization.of(context).emailedQuote,
|
||||
shouldPop: isMobile(context));
|
||||
|
|
@ -97,6 +98,7 @@ class EmailQuoteVM extends EmailEntityVM {
|
|||
template: template,
|
||||
subject: subject,
|
||||
body: body,
|
||||
ccEmail: ccEmail,
|
||||
));
|
||||
},
|
||||
);
|
||||
|
|
|
|||
Loading…
Reference in New Issue