error handling fixes
gitea/salix/dev This commit looks good
Details
gitea/salix/dev This commit looks good
Details
This commit is contained in:
parent
cba578d42e
commit
ed5458a264
|
@ -15,6 +15,7 @@
|
|||
|
||||
.grid-block {
|
||||
box-sizing: border-box;
|
||||
background-color: #FFF;
|
||||
min-height: 40px
|
||||
}
|
||||
|
||||
|
@ -22,10 +23,6 @@
|
|||
height: 40px
|
||||
}
|
||||
|
||||
.grid-block.white {
|
||||
background-color: #FFF
|
||||
}
|
||||
|
||||
.columns {
|
||||
overflow: hidden;
|
||||
box-sizing: border-box;
|
||||
|
|
|
@ -16,7 +16,7 @@ const validator = {
|
|||
if (invalidProps.length > 0) {
|
||||
const required = invalidProps.join(', ');
|
||||
|
||||
throw new Error(`Required params not found [${required}]`);
|
||||
throw new Error(`Required properties not found [${required}]`);
|
||||
}
|
||||
},
|
||||
props: ['isPreview']
|
||||
|
|
|
@ -1,33 +1,32 @@
|
|||
const Email = require('../core/email');
|
||||
|
||||
module.exports = app => {
|
||||
app.get(`/api/email/:name`, async(req, res) => {
|
||||
app.get(`/api/email/:name`, async(req, res, next) => {
|
||||
const args = req.query;
|
||||
const requiredArgs = ['recipient', 'clientId'];
|
||||
|
||||
const requiredArgs = ['clientId', 'recipient'];
|
||||
const argList = requiredArgs.join(',');
|
||||
const hasRequiredArgs = requiredArgs.every(arg => {
|
||||
return args[arg];
|
||||
});
|
||||
|
||||
if (!hasRequiredArgs) {
|
||||
return res.status(400).json({
|
||||
message: 'Required params recipient, clientId'
|
||||
});
|
||||
}
|
||||
|
||||
try {
|
||||
if (!hasRequiredArgs)
|
||||
throw new Error(`Required properties not found [${argList}]`);
|
||||
|
||||
const email = new Email(req.params.name, args);
|
||||
if (args.isPreview === 'true') {
|
||||
const rendered = await email.render();
|
||||
|
||||
res.send(rendered);
|
||||
} else await email.send();
|
||||
} else {
|
||||
await email.send();
|
||||
|
||||
res.status(200).json({
|
||||
message: 'Sent'
|
||||
});
|
||||
}
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
|
||||
return res.status(500).json({message: 'Email not sent'});
|
||||
next(e);
|
||||
}
|
||||
|
||||
res.status(200).json({message: 'Sent'});
|
||||
});
|
||||
};
|
||||
|
|
|
@ -4,21 +4,21 @@ module.exports = app => {
|
|||
app.get(`/api/report/:name`, async(req, res, next) => {
|
||||
const args = req.query;
|
||||
const requiredArgs = ['clientId'];
|
||||
|
||||
const argList = requiredArgs.join(',');
|
||||
const hasRequiredArgs = requiredArgs.every(arg => {
|
||||
return args[arg];
|
||||
});
|
||||
|
||||
if (!hasRequiredArgs)
|
||||
res.json({message: 'Required params recipient, clientId'});
|
||||
|
||||
try {
|
||||
if (!hasRequiredArgs)
|
||||
throw new Error(`Required properties not found [${argList}]`);
|
||||
|
||||
const report = new Report(req.params.name, args);
|
||||
const stream = await report.toPdfStream();
|
||||
res.setHeader('Content-type', 'application/pdf');
|
||||
stream.pipe(res);
|
||||
} catch (e) {
|
||||
next(e);
|
||||
} catch (error) {
|
||||
next(error);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
[{
|
||||
"filename": "claim-pickup-order.pdf",
|
||||
"component": "claim-pickup"
|
||||
}]
|
||||
[
|
||||
{
|
||||
"filename": "claim-pickup-order.pdf",
|
||||
"component": "claim-pickup"
|
||||
}
|
||||
]
|
|
@ -25,7 +25,7 @@
|
|||
</div>
|
||||
<!-- Block -->
|
||||
<div class="grid-row">
|
||||
<div class="grid-block white vn-pa-lg">
|
||||
<div class="grid-block vn-pa-lg">
|
||||
<h1>{{ $t('title') }}</h1>
|
||||
<p>{{$t('description.dear')}},</p>
|
||||
<p>{{$t('description.instructions')}}</p>
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
</div>
|
||||
<!-- Block -->
|
||||
<div class="grid-row">
|
||||
<div class="grid-block white vn-pa-lg">
|
||||
<div class="grid-block vn-pa-lg">
|
||||
<h1>{{ $t('title') }}</h1>
|
||||
<p>{{$t('dearClient')}},</p>
|
||||
<p v-html="$t('clientData')"></p>
|
||||
|
|
|
@ -30,7 +30,7 @@
|
|||
</div>
|
||||
<!-- Block -->
|
||||
<div class="grid-row">
|
||||
<div class="grid-block white vn-pa-lg">
|
||||
<div class="grid-block vn-pa-lg">
|
||||
<h1>{{ $t('title') }}</h1>
|
||||
<p>{{$t('dear')}}</p>
|
||||
<p v-html="$t('description', [ticketId])"></p>
|
||||
|
@ -38,7 +38,7 @@
|
|||
</div>
|
||||
<!-- Block -->
|
||||
<div class="grid-row">
|
||||
<div class="grid-block white vn-px-lg">
|
||||
<div class="grid-block vn-px-lg">
|
||||
<p>{{$t('copyLink')}}</p>
|
||||
<div class="external-link vn-pa-sm vn-m-md">
|
||||
https://www.verdnatura.es/#!form=ecomerce/ticket&ticket={{ticketId}}
|
||||
|
@ -47,7 +47,7 @@
|
|||
</div>
|
||||
<!-- Block -->
|
||||
<div class="grid-row">
|
||||
<div class="grid-block white vn-pa-lg">
|
||||
<div class="grid-block vn-pa-lg">
|
||||
<p v-html="$t('poll')"></p>
|
||||
<p v-html="$t('help')"></p>
|
||||
<p v-html="$t('conclusion')"></p>
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
[{
|
||||
"filename": "delivery-note.pdf",
|
||||
"component": "delivery-note"
|
||||
}]
|
||||
[
|
||||
{
|
||||
"filename": "delivery-note.pdf",
|
||||
"component": "delivery-note"
|
||||
}
|
||||
]
|
|
@ -25,7 +25,7 @@
|
|||
</div>
|
||||
<!-- Block -->
|
||||
<div class="grid-row">
|
||||
<div class="grid-block white vn-pa-lg">
|
||||
<div class="grid-block vn-pa-lg">
|
||||
<h1>{{ $t('title') }}</h1>
|
||||
<p>{{$t('dear')}},</p>
|
||||
<p v-html="$t('description', [ticketId])"></p>
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
[{
|
||||
"filename": "driver-route.pdf",
|
||||
"component": "driver-route"
|
||||
}]
|
||||
[
|
||||
{
|
||||
"filename": "driver-route.pdf",
|
||||
"component": "driver-route"
|
||||
}
|
||||
]
|
|
@ -25,7 +25,7 @@
|
|||
</div>
|
||||
<!-- Block -->
|
||||
<div class="grid-row">
|
||||
<div class="grid-block white vn-pa-lg">
|
||||
<div class="grid-block vn-pa-lg">
|
||||
<h1>{{ $t('title') }}</h1>
|
||||
<p>{{$t('description.instructions')}}</p>
|
||||
</div>
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
[{
|
||||
"filename": "letter-debtor.pdf",
|
||||
"component": "letter-debtor"
|
||||
}]
|
||||
[
|
||||
{
|
||||
"filename": "letter-debtor.pdf",
|
||||
"component": "letter-debtor"
|
||||
}
|
||||
]
|
|
@ -25,7 +25,7 @@
|
|||
</div>
|
||||
<!-- Block -->
|
||||
<div class="grid-row">
|
||||
<div class="grid-block white vn-pa-lg">
|
||||
<div class="grid-block vn-pa-lg">
|
||||
<h1>{{ $t('title') }}</h1>
|
||||
<p>{{ $t('sections.introduction.title') }},</p>
|
||||
<p>{{ $t('sections.introduction.description') }}</p>
|
||||
|
@ -65,7 +65,7 @@
|
|||
</div>
|
||||
<!-- Block -->
|
||||
<div class="grid-row" v-if="isPreview">
|
||||
<div class="grid-block white vn-pa-lg">
|
||||
<div class="grid-block vn-pa-lg">
|
||||
<attachment v-for="attachment in attachments"
|
||||
v-bind:key="attachment.filename"
|
||||
v-bind:attachment="attachment"
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
[{
|
||||
"filename": "letter-debtor.pdf",
|
||||
"component": "letter-debtor"
|
||||
}]
|
||||
[
|
||||
{
|
||||
"filename": "letter-debtor.pdf",
|
||||
"component": "letter-debtor"
|
||||
}
|
||||
]
|
|
@ -25,7 +25,7 @@
|
|||
</div>
|
||||
<!-- Block -->
|
||||
<div class="grid-row">
|
||||
<div class="grid-block white vn-pa-lg">
|
||||
<div class="grid-block vn-pa-lg">
|
||||
<h1>{{ $t('title') }}</h1>
|
||||
<p>{{ $t('sections.introduction.title') }},</p>
|
||||
<p>{{ $t('sections.introduction.description') }}</p>
|
||||
|
@ -48,7 +48,7 @@
|
|||
</div>
|
||||
<!-- Block -->
|
||||
<div class="grid-row" v-if="isPreview">
|
||||
<div class="grid-block white vn-pa-lg">
|
||||
<div class="grid-block vn-pa-lg">
|
||||
<attachment v-for="attachment in attachments"
|
||||
v-bind:key="attachment.filename"
|
||||
v-bind:attachment="attachment"
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
</div>
|
||||
<!-- Block -->
|
||||
<div class="grid-row">
|
||||
<div class="grid-block white vn-pa-lg">
|
||||
<div class="grid-block vn-pa-lg">
|
||||
<h1>{{ $t('title') }}</h1>
|
||||
<p>{{ $t('sections.introduction.title') }},</p>
|
||||
<p v-html="`${$t('sections.introduction.description')}:`"></p>
|
||||
|
|
|
@ -1,12 +1,14 @@
|
|||
[{
|
||||
"filename": "model.ezp",
|
||||
"component": "printer-setup",
|
||||
"path": "/assets/files/model.ezp",
|
||||
"cid": "model.ezp"
|
||||
},
|
||||
{
|
||||
"filename": "port.png",
|
||||
"component": "printer-setup",
|
||||
"path": "/assets/files/port.png",
|
||||
"cid": "port.png"
|
||||
}]
|
||||
[
|
||||
{
|
||||
"filename": "model.ezp",
|
||||
"component": "printer-setup",
|
||||
"path": "/assets/files/model.ezp",
|
||||
"cid": "model.ezp"
|
||||
},
|
||||
{
|
||||
"filename": "port.png",
|
||||
"component": "printer-setup",
|
||||
"path": "/assets/files/port.png",
|
||||
"cid": "port.png"
|
||||
}
|
||||
]
|
|
@ -25,7 +25,7 @@
|
|||
</div>
|
||||
<!-- Block -->
|
||||
<div class="grid-row">
|
||||
<div class="grid-block white vn-pa-lg">
|
||||
<div class="grid-block vn-pa-lg">
|
||||
<h1>{{ $t('title') }}</h1>
|
||||
<p>{{$t('description.dear')}},</p>
|
||||
<p>{{$t('description.instructions')}}</p>
|
||||
|
@ -43,7 +43,7 @@
|
|||
</div>
|
||||
<!-- Block -->
|
||||
<div class="grid-row">
|
||||
<div class="grid-block white vn-pa-lg">
|
||||
<div class="grid-block vn-pa-lg">
|
||||
<h1>{{$t('sections.help.title')}}</h1>
|
||||
<p>{{$t('sections.help.description')}}</p>
|
||||
<p v-html="$t('sections.help.remoteSupport')"></p>
|
||||
|
@ -51,7 +51,7 @@
|
|||
</div>
|
||||
<!-- Block -->
|
||||
<div class="grid-row">
|
||||
<div class="grid-block white vn-pa-lg">
|
||||
<div class="grid-block vn-pa-lg">
|
||||
<div v-if="client.salesPersonName">
|
||||
{{$t('salesPersonName')}}: <strong>{{client.salesPersonName}}</strong>
|
||||
</div>
|
||||
|
@ -66,7 +66,7 @@
|
|||
</div>
|
||||
<!-- Block -->
|
||||
<div class="grid-row" v-if="isPreview">
|
||||
<div class="grid-block white vn-pa-lg">
|
||||
<div class="grid-block vn-pa-lg">
|
||||
<attachment v-for="attachment in attachments"
|
||||
v-bind:key="attachment.filename"
|
||||
v-bind:attachment="attachment"
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
</div>
|
||||
<!-- Block -->
|
||||
<div class="grid-row">
|
||||
<div class="grid-block white vn-pa-lg">
|
||||
<div class="grid-block vn-pa-lg">
|
||||
<h1>{{ $t('title') }}</h1>
|
||||
<p>{{$t('description.dear')}},</p>
|
||||
<div v-html="$t('description.instructions')"></div>
|
||||
|
@ -34,7 +34,7 @@
|
|||
</div>
|
||||
<!-- Attachments block -->
|
||||
<div class="grid-row" v-if="isPreview">
|
||||
<div class="grid-block white vn-pa-lg">
|
||||
<div class="grid-block vn-pa-lg">
|
||||
<attachment v-for="attachment in attachments"
|
||||
v-bind:key="attachment.filename"
|
||||
v-bind:attachment="attachment"
|
||||
|
|
|
@ -33,7 +33,7 @@
|
|||
</tr>
|
||||
<tr>
|
||||
<td class="font gray uppercase">{{$t('date')}}</td>
|
||||
<th>{{currentDate}}</th>
|
||||
<th>{{dated}}</th>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
|
|
@ -13,7 +13,7 @@ module.exports = {
|
|||
throw new Error('Something went wrong');
|
||||
},
|
||||
computed: {
|
||||
currentDate: function() {
|
||||
dated: function() {
|
||||
const filters = this.$options.filters;
|
||||
|
||||
return filters.date(new Date(), '%d-%m-%Y');
|
||||
|
|
|
@ -12,13 +12,6 @@ module.exports = {
|
|||
if (!this.route)
|
||||
throw new Error('Something went wrong');
|
||||
},
|
||||
computed: {
|
||||
dated: function() {
|
||||
const filters = this.$options.filters;
|
||||
|
||||
return filters.date(new Date(), '%d-%m-%Y');
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
fetchRoute(id) {
|
||||
return db.findOne(
|
||||
|
|
Loading…
Reference in New Issue