munch-ease-frontend/src/components/MealCard.vue

39 lines
998 B
Vue
Raw Normal View History

2024-01-13 02:00:15 +00:00
<template>
<div class="meal-card">
<h3>{{ dayOfWeek }} <small>{{ date }}</small></h3>
<h4>{{ meal.recipe.name }}</h4>
<p> Cooked by {{ chef_names }}</p>
<p> For {{ consumers_names }}</p>
<a @click="$emit('edit-meal', meal)">Edit</a>
</div>
</template>
<style>
.meal-card {
border: 1px solid #ccc;
border-radius: 5px;
padding: 10px;
margin-bottom: 10px;
}
</style>
<script>
export default {
name: 'MealCard',
props: ['meal'],
computed: {
chef_names() {
return this.meal.chefs.map(chef => chef.name).join(', ')
},
consumers_names() {
return this.meal.consumers.map(consumer => consumer.name).join(', ')
},
date() {
return this.meal.date.toLocaleDateString('en-au', { month: 'numeric', day: 'numeric' })
},
dayOfWeek() {
return this.meal.date.toLocaleDateString('en-au', { weekday: 'long' })
}
}
}
</script>