mirror of
https://github.com/kevin-DL/build-gmail-clone-with-vue-3.git
synced 2026-01-22 15:15:34 +00:00
readEmail and archiveEmail methods
This commit is contained in:
@@ -4,7 +4,7 @@
|
|||||||
<tr v-for="email in unarchivedEmails"
|
<tr v-for="email in unarchivedEmails"
|
||||||
:key="email.id"
|
:key="email.id"
|
||||||
:class="[email.read ? 'read': '', 'clickable']"
|
:class="[email.read ? 'read': '', 'clickable']"
|
||||||
@click="email.read = true">
|
@click="readEmail(email)">
|
||||||
<td>
|
<td>
|
||||||
<input type="checkbox" />
|
<input type="checkbox" />
|
||||||
</td>
|
</td>
|
||||||
@@ -13,7 +13,7 @@
|
|||||||
<p><strong>{{email.subject}}</strong> - {{email.body}}</p>
|
<p><strong>{{email.subject}}</strong> - {{email.body}}</p>
|
||||||
</td>
|
</td>
|
||||||
<td class="date">{{format(new Date(email.sentAt), 'MMM do yyyy')}}</td>
|
<td class="date">{{format(new Date(email.sentAt), 'MMM do yyyy')}}</td>
|
||||||
<td><button @click="email.archived = true">Archive</button></td>
|
<td><button @click="archiveEmail(email)">Archive</button></td>
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
@@ -41,6 +41,16 @@
|
|||||||
return e1.sentAt < e2.sentAt ? 1 : -1
|
return e1.sentAt < e2.sentAt ? 1 : -1
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
readEmail(email){
|
||||||
|
email.read = true
|
||||||
|
axios.put(`http://localhost:3000/emails/${email.id}`, email)
|
||||||
|
},
|
||||||
|
archiveEmail(email){
|
||||||
|
email.archived = true;
|
||||||
|
axios.put(`http://localhost:3000/emails/${email.id}`, email)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
Reference in New Issue
Block a user