2016-05-13 16:48:46 +07:00
|
|
|
const dateformat = require('dateformat')
|
2016-06-30 08:18:07 -07:00
|
|
|
const html = require('../../../html')
|
2016-05-13 16:48:46 +07:00
|
|
|
|
2016-07-02 00:13:13 +02:00
|
|
|
module.exports = function (state, prev, send) {
|
|
|
|
|
const params = state.params
|
2016-05-13 16:48:46 +07:00
|
|
|
const mailbox = params.mailbox
|
2016-05-23 04:00:29 +09:00
|
|
|
const messages = state[mailbox].messages
|
2016-06-30 08:18:07 -07:00
|
|
|
return html`
|
2016-05-13 16:48:46 +07:00
|
|
|
<div>
|
2016-05-14 10:44:44 +07:00
|
|
|
<div class="db cf w-100">
|
|
|
|
|
<div class="fl mb3 w-25 mt0 b">Date</th>
|
|
|
|
|
<div class="fl mb3 w-25 mt0 b">Subject</th>
|
|
|
|
|
<div class="fl mb3 w-25 mt0 b">From</th>
|
|
|
|
|
<div class="fl mb3 w-25 mt0 b">To</th>
|
|
|
|
|
</div>
|
2016-05-21 15:32:01 +09:00
|
|
|
${messages.map(function (msg) {
|
2016-05-13 16:48:46 +07:00
|
|
|
return createMessage(msg, mailbox)
|
|
|
|
|
})}
|
|
|
|
|
</div>
|
|
|
|
|
`
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function createMessage (message, mailbox) {
|
2016-06-30 08:18:07 -07:00
|
|
|
return html`
|
2016-05-13 16:48:46 +07:00
|
|
|
<div class="db cf w-100">
|
|
|
|
|
<a href="${'/' + mailbox + '/' + message.id}">
|
|
|
|
|
<div class="fl mb3 w-25 f6 link">
|
|
|
|
|
${dateformat(message.date, 'mmmm dS')}
|
|
|
|
|
</div>
|
|
|
|
|
<div class="fl mb3 w-25 f6 link">${message.subject}</div>
|
|
|
|
|
<div class="fl mb3 w-25 f6 link">${message.from}</div>
|
|
|
|
|
<div class="fl mb3 w-25 f6 link">${message.to}</div>
|
|
|
|
|
</a>
|
|
|
|
|
</div>
|
|
|
|
|
`
|
|
|
|
|
}
|