Email templates
This commit is contained in:
parent
0683c789fd
commit
a1ee7e91ab
|
|
@ -68,8 +68,15 @@ class InvoiceRepository {
|
|||
}
|
||||
|
||||
Future emailInvoice(
|
||||
CompanyEntity company, AuthState auth, InvoiceEntity invoice, String subject, String body) async {
|
||||
CompanyEntity company,
|
||||
AuthState auth,
|
||||
InvoiceEntity invoice,
|
||||
EmailTemplate template,
|
||||
String subject,
|
||||
String body) async {
|
||||
|
||||
final data = {
|
||||
'reminder': template == EmailTemplate.initial ? '' : template.toString(),
|
||||
'template': {
|
||||
'body': body,
|
||||
'subject': subject,
|
||||
|
|
|
|||
|
|
@ -30,6 +30,7 @@ class EditInvoice implements PersistUI {
|
|||
class ShowEmailInvoice {
|
||||
final InvoiceEntity invoice;
|
||||
final BuildContext context;
|
||||
|
||||
ShowEmailInvoice({this.invoice, this.context});
|
||||
|
||||
//final Completer completer;
|
||||
|
|
@ -163,10 +164,12 @@ class SaveInvoiceFailure implements StopSaving {
|
|||
class EmailInvoiceRequest implements StartSaving {
|
||||
final Completer completer;
|
||||
final int invoiceId;
|
||||
final EmailTemplate template;
|
||||
final String subject;
|
||||
final String body;
|
||||
|
||||
EmailInvoiceRequest({this.completer, this.invoiceId, this.subject, this.body});
|
||||
EmailInvoiceRequest(
|
||||
{this.completer, this.invoiceId, this.template, this.subject, this.body});
|
||||
}
|
||||
|
||||
class EmailInvoiceSuccess implements StopSaving, PersistData {}
|
||||
|
|
|
|||
|
|
@ -192,7 +192,7 @@ Middleware<AppState> _emailInvoice(InvoiceRepository repository) {
|
|||
final origInvoice = store.state.invoiceState.map[action.invoiceId];
|
||||
repository
|
||||
.emailInvoice(store.state.selectedCompany, store.state.authState,
|
||||
origInvoice, action.subject, action.body)
|
||||
origInvoice, action.template, action.subject, action.body)
|
||||
.then((void _) {
|
||||
store.dispatch(EmailInvoiceSuccess());
|
||||
store.dispatch(LoadClient(clientId: origInvoice.clientId));
|
||||
|
|
|
|||
|
|
@ -248,7 +248,8 @@ class _InvoiceEmailViewState extends State<InvoiceEmailView> {
|
|||
IconButton(
|
||||
tooltip: localization.send,
|
||||
icon: Icon(Icons.send),
|
||||
onPressed: () => viewModel.onSendPressed(emailSubject, emailBody),
|
||||
onPressed: () => viewModel.onSendPressed(
|
||||
selectedTemplate, emailSubject, emailBody),
|
||||
)
|
||||
],
|
||||
),
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@ class EmailInvoiceDialogVM {
|
|||
final CompanyEntity company;
|
||||
final InvoiceEntity invoice;
|
||||
final ClientEntity client;
|
||||
final Function(String, String) onSendPressed;
|
||||
final Function(EmailTemplate, String, String) onSendPressed;
|
||||
|
||||
//final List<ContactEntity> recipients;
|
||||
|
||||
|
|
@ -62,8 +62,9 @@ class EmailInvoiceDialogVM {
|
|||
company: state.selectedCompany,
|
||||
invoice: invoice,
|
||||
client: state.clientState.map[invoice.clientId],
|
||||
onSendPressed: (subject, body) => store.dispatch(EmailInvoiceRequest(
|
||||
onSendPressed: (template, subject, body) => store.dispatch(EmailInvoiceRequest(
|
||||
invoiceId: invoice.id,
|
||||
template: template,
|
||||
subject: subject,
|
||||
body: body,
|
||||
))
|
||||
|
|
|
|||
Loading…
Reference in New Issue