From f0bf30909cee7337e2ee14facb25f07dd3b469ad Mon Sep 17 00:00:00 2001 From: Kamil Niemczycki Date: Tue, 7 Jun 2022 13:08:43 +0200 Subject: [PATCH] wip --- resources/js/Pages/VacationRequest/Create.vue | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/resources/js/Pages/VacationRequest/Create.vue b/resources/js/Pages/VacationRequest/Create.vue index 499234d..b990620 100644 --- a/resources/js/Pages/VacationRequest/Create.vue +++ b/resources/js/Pages/VacationRequest/Create.vue @@ -349,7 +349,7 @@ const props = defineProps({ const form = useForm({ user: props.can.createOnBehalfOfEmployee - ? props.users.data.find(user => user.id === (props.vacationUserId ?? props.auth.user.id)) ?? props.users.data[0] + ? props.users.data.find(user => user.id === (checkUserId(props.vacationUserId) ?? props.auth.user.id)) ?? props.users.data[0] : props.auth.user, from: props.vacationFromDate, to: props.vacationFromDate, @@ -427,6 +427,10 @@ function resetForm() { estimatedDays.value = [] } +function checkUserId(userId) { + return userId > 0 ? userId: null +} + async function refreshEstimatedDays(from, to) { if (from && to) { const res = await axios.post('/api/vacation/calculate-days', { from, to })