Skip to content

Commit

Permalink
Adds order status.
Browse files Browse the repository at this point in the history
  • Loading branch information
dherbst committed Mar 6, 2024
1 parent 419eb36 commit 2363c5d
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 56 deletions.
49 changes: 17 additions & 32 deletions web/admin/src/pages/orders/AdminOrderPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -60,18 +60,6 @@ const resetShowMessages = () => {
errMessage.value = 'An error occurred'
}
const deleteItem = async() => {
resetShowMessages()
try {
await deleteDoc(doc(db, 'order', props.id))
showDeleteMessage.value = true
router.push({name: 'OrdersListPage'})
} catch(err) {
showErrMessage.value = true
console.error(err)
}
}
const saveItem = async () => {
resetShowMessages()
try {
Expand All @@ -82,21 +70,6 @@ const saveItem = async () => {
showSaveMessage.value = true
} else {
const q = query(collection(db, 'order'), where('name', '==', item.value.guestname))
const docs = await getDocs(q)
if (docs.size > 0) {
errMessage.value = 'Order with guestname ' + item.value.guestname + ' already exists'
showErrMessage = true
return
}
console.log('saveItem currentForm, enddate', currentForm.value, currentForm.value.enddate)
if (currentForm.value && currentForm.value.enddate) {
item.value.enddate = currentForm.value.enddate
}
const itemRef = await addDoc(collection(db, 'order'), item.value)
router.push({name: 'OrdersListPage'})
}
} catch(err) {
Expand Down Expand Up @@ -156,8 +129,8 @@ onBeforeMount(async() => {
<div class="col-md">
<span class="form-label">Number in Household:</span> {{ item.numInHousehold }}<br>
<template v-if="item.delivery"><span class="form-label">Pickup/Delivery:</span> Delivery</template>
<template v-else><span class="form-label">Pickup time:</span> {{ dayjs(item.pickuptime.starttime).format('HH:mm a')}}
- {{ dayjs(item.pickuptime.endtime).format('HH:mm a')}}
<template v-else><span class="form-label">Pickup time:</span> {{ item.pickuptime && item.pickuptime.starttime && dayjs(item.pickuptime.starttime).format('HH:mm a')}}
- {{ item.pickuptime && item.pickuptime.endtime && dayjs(item.pickuptime.endtime).format('HH:mm a')}}
</template>
</div>
<div class="col-md">
Expand All @@ -167,6 +140,21 @@ onBeforeMount(async() => {
</div>
</div>

<div class="row mb-3">
<div class="col">
<div class="form-label">Order Status:</div>
<select class="form-select" v-model="item.status">
<option value="new">New</option>
<option value="approved">Approved</option>
<option value="packed">Packed</option>
<option value="in-transit">In-Transit</option>
<option value="completed">Completed</option>
<option value="invalid">Invalid</option>
</select>

</div>
</div>

<div class="row mb-3">
<div class="col">
<div class="form-label">Items in this order:</div>
Expand All @@ -180,9 +168,6 @@ onBeforeMount(async() => {
<div class="col">
<button type="submit" class="btn btn-primary">Save</button>
</div>
<div class="col text-end">
<button @click.prevent="deleteItem" class="btn btn-danger" :disabled="props.id === '' || props.id === null || props.id === undefined">Delete</button>
</div>
</div>
</form>
</div>
Expand Down
43 changes: 19 additions & 24 deletions web/app/src/pages/OrderPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -193,41 +193,36 @@ const saveOrder = async () => {

<div class="row mt-3">
<div class="col">
<div class="form-label">Name</div>
<div class="form-control">{{ order.guestname }}</div>
<span class="form-label">Name:</span> {{ order.guestname }}<br>
<span class="form-label">Phone:</span> {{ order.phone }}<br>
<span class="form-label">Email:</span> {{ order.email }}<br>
</div>
</div>
<div class="row mt-3">
<div class="col">
<div class="form-label">Phone</div>
<div class="form-control">{{ order.phone }}</div>
</div>
</div>
<div class="row mt-3">
<div class="col">
<div class="form-label">Email</div>
<div class="form-control">{{ order.email }}</div>
<div class="col-md">
<div class="form-label">Address:</div>
{{ order.street }}<br>
<template v-if="order.street2">{{order.street2}}<br></template>
{{order.city}}, {{order.state}} {{ order.zipcode }}<br>
</div>
</div>

<div class="row mt-3">
<div class="col">
<div class="form-label">Address</div>
<div class="form-control">{{ order.street }}<br>{{ order.street2}}<br>{{order.city}}, {{ order.state}} {{ order.zipcode }}</div>
<div class="col-md">
<span class="form-label">Number in Household:</span> {{ order.numInHousehold }}<br>
</div>
</div>
<div class="row mt-3">
<div class="col">
<div class="form-label">Number in Household</div>
<div class="form-control">{{ order.numInHousehold }}</div>
<div class="col-md">
<span class="form-label">Children:</span> {{ order.numChild }}<br>
<span class="form-label">Adults:</span> {{ order.numAdult }}<br>
<span class="form-label">Seniors:</span> {{ order.numSenior }}<br>
</div>
</div>

<div class="row mt-3">
<div class="col">
<div class="form-label">Number Children, Adults, Seniors</div>
<div class="form-control">{{ order.numChild }}, {{ order.numAdult }}, {{ order.numSenior }}</div>
<span class="form-label">Order Status:</span> {{ order.status || 'new' }}
</div>
</div>


<div class="row mt-3">
<div class="col">
<div class="fs-3">Pick up date: {{ dayjs(currentForm.pickupdate.toDate()).format('ddd MM/DD/YYYY') }}</div>
Expand Down Expand Up @@ -278,7 +273,7 @@ const saveOrder = async () => {

<div class="row mt-3">
<div class="col">
<button type="submit" class="btn btn-primary">Save Order</button>
<button type="submit" class="btn btn-primary" :disabled="order.status === 'completed' || order.status === 'in-transit'">Save Order</button>
</div>
</div>

Expand Down

0 comments on commit 2363c5d

Please sign in to comment.