From b8750f1e8e578a563661522a25de4b3da46a17e5 Mon Sep 17 00:00:00 2001 From: ajdj100 Date: Wed, 17 Dec 2025 22:58:46 -0500 Subject: [PATCH] implemented "today" button for quickly setting promotion dates --- .../components/promotions/promotionForm.vue | 32 ++++++++++++++----- 1 file changed, 24 insertions(+), 8 deletions(-) diff --git a/ui/src/components/promotions/promotionForm.vue b/ui/src/components/promotions/promotionForm.vue index 786c6b0..dc7b10f 100644 --- a/ui/src/components/promotions/promotionForm.vue +++ b/ui/src/components/promotions/promotionForm.vue @@ -26,7 +26,7 @@ import { error } from 'console'; import Input from '../ui/input/Input.vue'; import Field from '../ui/field/Field.vue'; -const { handleSubmit, errors, values, resetForm } = useForm({ +const { handleSubmit, errors, values, resetForm, setFieldValue } = useForm({ validationSchema: toTypedSchema(batchPromotionSchema), validateOnMount: false, }) @@ -103,8 +103,21 @@ onMounted(async () => { allRanks.value = await getAllRanks(); }) +function setAllToday() { + const today = () => { + const d = new Date() + const year = d.getFullYear() + const month = String(d.getMonth() + 1).padStart(2, '0') + const day = String(d.getDate()).padStart(2, '0') + return `${year}-${month}-${day}` + } + values.promotions?.forEach((_, index) => { + // @ts-ignore + setFieldValue(`promotions[${index}].start_date`, today()) + }) +}