Skip to content

Commit

Permalink
feat(PetChip): add badges for food and medicines
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanvanherwijnen committed Dec 17, 2024
1 parent d752b4d commit c4c30b4
Show file tree
Hide file tree
Showing 7 changed files with 91 additions and 13 deletions.
2 changes: 2 additions & 0 deletions packages/api/src/repositories/booking.ts
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,8 @@ function withPets(eb: ExpressionBuilder<Database, 'bookings'>) {
'pets.breed',
'pets.sterilized',
'pets.gender',
'pets.medicines',
'pets.food',
withValidVaccinations,
jsonObjectFrom(
ceb
Expand Down
4 changes: 4 additions & 0 deletions packages/api/src/repositories/kennel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,8 @@ export async function getBookingPetKennels(date: string) {
.select((seb) => [
'pets.id as id',
'pets.name as name',
'pets.medicines as medicines',
'pets.food as food',
convertImageSql.as('image'),
'bookingPetKennel.kennelId as kennelId',
'bookingPetKennel.bookingId as bookingId',
Expand Down Expand Up @@ -180,6 +182,8 @@ export async function getDaycareDatePetKennels(date: string) {
.select((seb) => [
'pets.id as id',
'pets.name as name',
'pets.medicines as medicines',
'pets.food as food',
convertImageSql.as('image'),
'daycareDatePetKennel.kennelId as kennelId',
'daycareDatePetKennel.daycareDateId as daycareDateId',
Expand Down
14 changes: 12 additions & 2 deletions packages/app/src/components/AgendaChip.vue
Original file line number Diff line number Diff line change
Expand Up @@ -13,22 +13,32 @@
modelValue.status === 'canceled'
}"
dense
show-badge
:icon="icons[type]"
:color="colors[type]"
@click="emit('click', { data: pet.id!, done: () => {} })"
@open-pet="emit('openPets', petIds)"
>
<template #badge>
<template
v-if="
modelValue.isDoubleBooked ||
(modelValue.services?.some(
(service) => service.service.type === 'appointment'
) &&
index === 0)
"
#bottom-badge
>
<q-badge
v-if="
modelValue.services?.some(
(service) => service.service.type === 'appointment'
) && index === 0
"
:color="BOOKING_SERVICE_COLORS.appointment"
text-color="black"
rounded
>
<q-icon class="q-ma-none q-pa-none" name="event" size="0.8em" />
</q-badge>
<q-badge v-if="modelValue.isDoubleBooked" color="orange" rounded />
</template>
Expand Down
18 changes: 12 additions & 6 deletions packages/app/src/components/AgendaComponent.vue
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,12 @@
</div>
<div class="row">
<div class="col-12 col-sm">
<q-badge
rounded
text-color="black"
:color="BOOKING_SERVICE_COLORS.appointment"
></q-badge
<q-badge rounded :color="BOOKING_SERVICE_COLORS.appointment">
<q-icon
class="q-ma-none q-pa-none"
name="event"
size="0.8em"
/> </q-badge
><a>{{ lang.service.type.appointment }}</a>

<q-badge
Expand All @@ -53,7 +54,12 @@
></q-badge
><a>{{ lang.booking.messages.isDoubleBooked }}</a>

<q-badge class="q-ml-lg" rounded text-color="black" color="red"></q-badge
<q-badge class="q-ml-lg" rounded color="red">
<q-icon
class="q-ma-none q-pa-none"
name="vaccines"
size="0.8em"
/> </q-badge
><a>{{ lang.pet.vaccination.missingVaccinations }}</a>
</div>
</div>
Expand Down
64 changes: 59 additions & 5 deletions packages/app/src/components/pet/PetChip.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
<template>
<q-chip>
<q-chip
:class="{
'q-mb-md': $slots['bottom-badge']
}"
>
{{
`${modelValue.name} ${showLastName ? truncateLastName(modelValue.customer?.lastName || '') : ''}`
}}
Expand Down Expand Up @@ -37,17 +41,61 @@

<q-badge
v-if="showBadge || $slots['badge']"
style="top: -8px"
style="top: -10px"
floating
color="transparent"
>
<q-badge
v-if="modelValue.food?.timesADay > 2"
:style="{
padding: '0px',
'padding-left': '3px',
'padding-right': '3px'
}"
color="yellow"
rounded
>
<q-icon class="q-ma-none q-pa-none" name="restaurant" size="0.8em" />
</q-badge>
<q-badge
v-if="modelValue.medicines"
:style="{
padding: '0px',
'padding-left': '3px',
'padding-right': '3px'
}"
color="yellow"
rounded
>
<q-icon
class="q-ma-none q-pa-none"
name="medical_services"
size="0.8em"
/>
</q-badge>
<q-badge
v-if="!modelValue.hasMandatoryVaccinations"
:style="{
padding: '0px',
'padding-left': '3px',
'padding-right': '3px'
}"
color="red"
rounded
/>
>
<q-icon class="q-ma-none q-pa-none" name="vaccines" size="0.8em" />
</q-badge>
<slot name="badge"></slot>
</q-badge>

<q-badge
v-if="$slots['bottom-badge']"
style="top: 14px"
floating
color="transparent"
>
<slot name="bottom-badge"></slot>
</q-badge>
</q-chip>
</template>

Expand All @@ -58,15 +106,21 @@ import Base64Image from '../Base64Image.vue'
type Pet = Pick<
PetType,
'id' | 'name' | 'image' | 'hasMandatoryVaccinations'
'id' | 'name' | 'image' | 'hasMandatoryVaccinations' | 'medicines' | 'food'
> & {
customer?: Pick<CustomerType, 'lastName'>
}
interface Props {
modelValue: Pick<
Pet,
'id' | 'name' | 'customer' | 'image' | 'hasMandatoryVaccinations'
| 'id'
| 'name'
| 'customer'
| 'image'
| 'hasMandatoryVaccinations'
| 'medicines'
| 'food'
>
showImage?: boolean
showLastName?: boolean
Expand Down
1 change: 1 addition & 0 deletions packages/app/src/pages/employee/KennelLayout.vue
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@
'bg-yellow-2': pet.daycareDateId
}"
:draggable="true"
show-badge
show-image
@dragstart="onDragStart"
@open-pet="openPet"
Expand Down
1 change: 1 addition & 0 deletions packages/app/src/pages/print/KennelLayout.vue
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
'bg-yellow-2': pet.daycareDateId
}"
:model-value="pet"
show-badge
draggable="true"
@dragstart="onDragStart"
>
Expand Down

0 comments on commit c4c30b4

Please sign in to comment.