From 8c345418b3ab3065a6eb32537cf964270488b68e Mon Sep 17 00:00:00 2001 From: Mahen Date: Fri, 13 Mar 2026 14:42:30 +0700 Subject: [PATCH] refactor: fix validation budget input --- src/components/dashboards/ProfileModal.tsx | 4 ++++ src/hooks/useProfileModal.ts | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/components/dashboards/ProfileModal.tsx b/src/components/dashboards/ProfileModal.tsx index 1276281..ddf4a6e 100644 --- a/src/components/dashboards/ProfileModal.tsx +++ b/src/components/dashboards/ProfileModal.tsx @@ -236,6 +236,8 @@ export const ProfileModal = ({ {...register("budgetMin", { valueAsNumber: true })} placeholder="Rp 0" className="border rounded-md focus:ring-2 focus:ring-primary mt-1" + min={0} + max={100000000000} /> {errors.budgetMin && (

@@ -250,6 +252,8 @@ export const ProfileModal = ({ {...register("budgetMax", { valueAsNumber: true })} placeholder="Rp 0" className="border rounded-md focus:ring-2 focus:ring-primary mt-1" + min={0} + max={100000000000} /> {errors.budgetMax && (

diff --git a/src/hooks/useProfileModal.ts b/src/hooks/useProfileModal.ts index 59fdf3f..7688d4e 100644 --- a/src/hooks/useProfileModal.ts +++ b/src/hooks/useProfileModal.ts @@ -25,8 +25,8 @@ export const useProfileModal = ({ profession: pref.profession ?? "OTHER", preferredBrand: pref.preferredBrand ?? "OTHER", preferredOS: pref.preferredOS ?? "OTHER", - budgetMin: pref.budgetMin ?? 0, - budgetMax: pref.budgetMax ?? 0, + budgetMin: pref.budgetMin === 0 || !pref.budgetMin ? "" : pref.budgetMin, + budgetMax: pref.budgetMax === 0 || !pref.budgetMax ? "" : pref.budgetMax, }, });