diff --git a/app/components/app/sep/entry-form.vue b/app/components/app/sep/entry-form.vue index 1b546322..458c070f 100644 --- a/app/components/app/sep/entry-form.vue +++ b/app/components/app/sep/entry-form.vue @@ -72,8 +72,8 @@ const onSubmit = handleSubmit((values) => {
- - + +

{{ errors.tanggalSep }}

@@ -142,7 +142,7 @@ const onSubmit = handleSubmit((values) => {
- +

{{ errors.tglSuratKontrol }}

diff --git a/app/components/pub/custom-ui/form/datepicker-single.vue b/app/components/pub/custom-ui/form/datepicker-single.vue index 6904b662..d866bbdf 100644 --- a/app/components/pub/custom-ui/form/datepicker-single.vue +++ b/app/components/pub/custom-ui/form/datepicker-single.vue @@ -8,7 +8,36 @@ import { Button } from '~/components/pub/ui/button' import { Calendar } from '~/components/pub/ui/calendar' import { Popover, PopoverContent, PopoverTrigger } from '~/components/pub/ui/popover' -const date = ref(undefined) +const props = defineProps<{ + placeholder?: string + modelValue?: Date | string | undefined +}>() + +const emit = defineEmits<{ + 'update:modelValue': [value: Date | string | undefined] +}>() + +const date = ref(undefined) + +// Sync prop to local state +watch( + () => props.modelValue, + (value) => { + if (value instanceof Date) { + date.value = value + } else if (typeof value === 'string' && value) { + date.value = value + } else { + date.value = undefined + } + }, + { immediate: true } +) + +watch(date, (value) => { + const newValue = format(value, 'yyyy-MM-dd') + emit('update:modelValue', newValue) +})