Skip to content

Commit 155ed62

Browse files
committed
add clearable option to calendardateinput, fix format, add paid_date
1 parent 5daa6f2 commit 155ed62

File tree

2 files changed

+47
-14
lines changed

2 files changed

+47
-14
lines changed

resources/js/Components/ui/calendar/CalendarDateInput.vue

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ import {
66
} from '@/Components/ui/popover';
77
import { Button } from '@/Components/ui/button';
88
import { Calendar } from '@/Components/ui/calendar';
9-
import { CalendarIcon } from 'lucide-vue-next';
10-
import { formatDateLocalized } from '@/packages/ui/src/utils/time';
9+
import { CalendarIcon, XIcon } from 'lucide-vue-next';
10+
import { formatDate } from '@/packages/ui/src/utils/time';
1111
import { parseDate } from '@internationalized/date';
1212
import { computed, inject, type ComputedRef } from 'vue';
1313
import { type Organization } from '@/packages/api/src';
@@ -17,6 +17,10 @@ const emit = defineEmits<{
1717
blur: [];
1818
}>();
1919
20+
defineProps<{
21+
clearable?: boolean;
22+
}>();
23+
2024
const handleChange = (date: string) => {
2125
model.value = date;
2226
};
@@ -25,6 +29,11 @@ const handleBlur = () => {
2529
emit('blur');
2630
};
2731
32+
const handleClear = (event: Event) => {
33+
event.stopPropagation();
34+
model.value = null;
35+
};
36+
2837
const date = computed(() => {
2938
return model.value ? parseDate(model.value) : undefined;
3039
});
@@ -44,7 +53,17 @@ const organization = inject<ComputedRef<Organization>>('organization');
4453
]"
4554
>
4655
<CalendarIcon class="mr-2 h-4 w-4" />
47-
{{ model ? formatDateLocalized(model, organization?.date_format) : 'Pick a date' }}
56+
<span class="flex-1">
57+
{{ model ? formatDate(model, organization?.date_format) : 'Pick a date' }}
58+
</span>
59+
<button
60+
v-if="clearable && model"
61+
class="ml-2 hover:bg-muted rounded p-1 transition-colors"
62+
type="button"
63+
@click="handleClear"
64+
>
65+
<XIcon class="h-4 w-4" />
66+
</button>
4867
</Button>
4968
</PopoverTrigger>
5069
<PopoverContent class="w-auto p-0">

resources/js/packages/api/src/openapi.json.client.ts

Lines changed: 25 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ const InvoiceResource = z
6767
status: z.string(),
6868
date: z.string(),
6969
due_at: z.string(),
70+
paid_date: z.string(),
7071
created_at: z.union([z.string(), z.null()]),
7172
updated_at: z.union([z.string(), z.null()]),
7273
})
@@ -76,7 +77,7 @@ const InvoiceDiscountType = z.enum(['percentage', 'fixed']);
7677
const InvoiceStoreRequest = z
7778
.object({
7879
due_at: z.union([z.string(), z.null()]).optional(),
79-
paid_at: z.union([z.string(), z.null()]).optional(),
80+
paid_date: z.union([z.string(), z.null()]).optional(),
8081
seller_name: z.string(),
8182
seller_vatin: z.union([z.string(), z.null()]).optional(),
8283
seller_address_line_1: z.union([z.string(), z.null()]).optional(),
@@ -102,8 +103,13 @@ const InvoiceStoreRequest = z
102103
billing_period_end: z.union([z.string(), z.null()]).optional(),
103104
reference: z.string(),
104105
currency: z.string(),
105-
tax_rate: z.number().int().optional(),
106-
discount_amount: z.number().int().optional(),
106+
tax_rate: z.number().int().gte(0).lte(2147483647).optional(),
107+
discount_amount: z
108+
.number()
109+
.int()
110+
.gte(0)
111+
.lte(9223372036854776000)
112+
.optional(),
107113
discount_type: InvoiceDiscountType.optional(),
108114
footer: z.union([z.string(), z.null()]).optional(),
109115
notes: z.union([z.string(), z.null()]).optional(),
@@ -115,8 +121,12 @@ const InvoiceStoreRequest = z
115121
.object({
116122
name: z.string(),
117123
description: z.union([z.string(), z.null()]).optional(),
118-
unit_price: z.number().int().gte(0).lte(99999999),
119-
quantity: z.number().gte(0),
124+
unit_price: z
125+
.number()
126+
.int()
127+
.gte(0)
128+
.lte(9223372036854776000),
129+
quantity: z.number().gte(0).lte(99999999),
120130
})
121131
.passthrough()
122132
)
@@ -161,7 +171,7 @@ const DetailedInvoiceResource = z
161171
buyer_address_country: z.string(),
162172
buyer_phone: z.string(),
163173
buyer_email: z.string(),
164-
paid_at: z.union([z.string(), z.null()]),
174+
paid_date: z.string(),
165175
due_at: z.string(),
166176
discount_type: z.string(),
167177
discount_amount: z.number().int(),
@@ -185,7 +195,7 @@ const InvoiceUpdateRequest = z
185195
.object({
186196
status: InvoiceStatus,
187197
due_at: z.union([z.string(), z.null()]),
188-
paid_at: z.union([z.string(), z.null()]),
198+
paid_date: z.union([z.string(), z.null()]),
189199
seller_name: z.string(),
190200
seller_vatin: z.union([z.string(), z.null()]),
191201
seller_address_line_1: z.union([z.string(), z.null()]),
@@ -211,8 +221,8 @@ const InvoiceUpdateRequest = z
211221
billing_period_end: z.union([z.string(), z.null()]),
212222
reference: z.string(),
213223
currency: z.string(),
214-
tax_rate: z.number().int(),
215-
discount_amount: z.number().int(),
224+
tax_rate: z.number().int().gte(0).lte(2147483647),
225+
discount_amount: z.number().int().gte(0).lte(9223372036854776000),
216226
discount_type: InvoiceDiscountType,
217227
footer: z.union([z.string(), z.null()]),
218228
notes: z.union([z.string(), z.null()]),
@@ -224,8 +234,12 @@ const InvoiceUpdateRequest = z
224234
id: z.union([z.string(), z.null()]).optional(),
225235
name: z.string(),
226236
description: z.union([z.string(), z.null()]).optional(),
227-
unit_price: z.number().int().gte(0).lte(99999999),
228-
quantity: z.number().gte(0),
237+
unit_price: z
238+
.number()
239+
.int()
240+
.gte(0)
241+
.lte(9223372036854776000),
242+
quantity: z.number().gte(0).lte(99999999),
229243
})
230244
.passthrough()
231245
),

0 commit comments

Comments
 (0)