Skip to content

Commit 4b1f2e3

Browse files
committed
Ask for the animal age as years + months
1 parent 67e7469 commit 4b1f2e3

File tree

2 files changed

+31
-15
lines changed

2 files changed

+31
-15
lines changed

app/Http/Requests/StoreAppointmentSchedule.php

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,16 @@ public function authorize(): bool
2424
public function rules(): array
2525
{
2626
return [
27-
'client.name' => ['required', 'string', 'between:2,50'],
27+
'client.name' => ['required', 'string', 'min:2', 'max:50'],
2828
'client.email' => ['required', 'email'],
29-
'animal.name' => ['required', 'string', 'between:2,50'],
30-
'animal.type' => ['required', 'string', 'between:3,20'],
31-
'animal.ageMonths' => ['required', 'numeric', 'integer', 'max:1200'],
29+
'animal.name' => ['required', 'string', 'min:2', 'max:50'],
30+
'animal.type' => ['required', 'string', 'min:3', 'max:20'],
31+
'animal.ageYears' => ['required', 'numeric', 'integer', 'max:100'],
32+
'animal.ageMonths' => ['required', 'numeric', 'integer', 'max:12'],
3233
'appointment.preferredDate' => ['required', Rule::date()->todayOrAfter()],
33-
'appointment.preferredTime' => ['required', 'array', 'between:1,2'],
34+
'appointment.preferredTime' => ['required', 'array', 'min:1', 'max:2'],
3435
'appointment.preferredTime.*' => ['required', Rule::enum(TimeOfDay::class)->only(TimeOfDay::selectable())],
35-
'appointment.symptoms' => ['required', 'string', 'between:10,255'],
36+
'appointment.symptoms' => ['required', 'string', 'min:10', 'max:255'],
3637
];
3738
}
3839
}

resources/js/pages/client/NewAppointment.vue

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ const form = useForm(
2323
animal: {
2424
name: '',
2525
type: '',
26+
ageYears: null,
2627
ageMonths: null,
2728
},
2829
appointment: {
@@ -104,11 +105,11 @@ function createAnimalType(item: string) {
104105
<p class="mb-2 text-2xl/12">About you</p>
105106

106107
<!--Client: name -->
107-
<UFormField label="Name" name="client.name" required>
108+
<UFormField label="Name" name="client.name" class="w-full" required>
108109
<UInput v-model="form.client.name" placeholder="Your name" class="w-full" />
109110
</UFormField>
110111
<!--Client: email-->
111-
<UFormField label="Email" name="client.email" description="Used to contact you about your appointment" required>
112+
<UFormField label="Email" name="client.email" description="Used to contact you about your appointment" class="w-full" required>
112113
<UInput v-model="form.client.email" type="email" placeholder="Your email" class="w-full" />
113114
</UFormField>
114115

@@ -118,11 +119,11 @@ function createAnimalType(item: string) {
118119
<p class="mb-2 pt-0 text-2xl/12">About your pet</p>
119120
<div class="flex flex-col gap-4 md:flex-row">
120121
<!-- Pet: name-->
121-
<UFormField label="Name" name="animal.name" required>
122+
<UFormField label="Name" name="animal.name" class="w-full" required>
122123
<UInput v-model="form.animal.name" class="w-full" placeholder="Your pet's name" />
123124
</UFormField>
124125
<!-- Pet: type -->
125-
<UFormField label="Type" name="animal.type" required>
126+
<UFormField label="Type" name="animal.type" class="w-full" required>
126127
<UInputMenu
127128
v-model="form.animal.type"
128129
placeholder="Your pet type"
@@ -132,20 +133,34 @@ function createAnimalType(item: string) {
132133
class="w-full"
133134
/>
134135
</UFormField>
135-
<!-- Pet: age -->
136-
<UFormField label="Age" name="animal.ageMonths" hint="in months" required>
137-
<UInput v-model="form.animal.ageMonths" class="w-full" placeholder="Your pet's age (in months)" />
138-
</UFormField>
139136
</div>
140137

138+
<!-- Pet: age -->
139+
<UFormField label="Age" required>
140+
<div class="flex flex-col gap-2 sm:flex-row">
141+
<UFormField name="animal.ageYears">
142+
<div class="flex w-full gap-2 sm:items-center">
143+
<UInput v-model="form.animal.ageYears" placeholder="Age in years..." class="w-full" />
144+
<span class="whitespace-nowrap text-gray-400">year(s) and</span>
145+
</div>
146+
</UFormField>
147+
<UFormField name="animal.ageMonths">
148+
<div class="flex w-full items-center gap-2">
149+
<UInput v-model="form.animal.ageMonths" placeholder="... and months" class="w-full" />
150+
<span class="whitespace-nowrap text-gray-400">month(s)</span>
151+
</div>
152+
</UFormField>
153+
</div>
154+
</UFormField>
155+
141156
<USeparator class="mb-0 py-6" />
142157

143158
<!-- Appointment -->
144159
<p class="mb-2 pt-0 text-2xl/12">About your visit</p>
145160
<div class="flex flex-col gap-4 md:flex-row">
146161
<div class="space-y-2 md:w-1/3">
147162
<!-- Appointment: date + time -->
148-
<UFormField label="Preferred Time" name="appointment.preferredDate" required>
163+
<UFormField label="Preferred Time" name="appointment.preferredDate" class="w-full" required>
149164
<UInput v-model="form.appointment.preferredDate" type="date" class="w-full" />
150165
</UFormField>
151166
<UFormField name="appointment.preferredTime">

0 commit comments

Comments
 (0)