From 25cb863145d39ab2faff2a2abe7ba344d28440f2 Mon Sep 17 00:00:00 2001 From: g-but <41178744+g-but@users.noreply.github.com> Date: Wed, 20 May 2026 20:09:02 +0200 Subject: [PATCH] feat(haptics): tick on Add X create CTAs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Extend haptic() to the three primary create surfaces: - AddCommitmentButton: fires in submit() after the description-required guard, so an empty submit doesn't haptic but a valid one does. - NewGoalButton / NewSubscriptionButton: fire in onSubmit before the create() call; ModalForm's canSubmit prop already gates invalid submits so the haptic only triggers on a real create attempt. Skipped the previous session's "useHaptic() hook extraction" suggestion — haptic is already a single named export from lib/haptics.ts; wrapping a side-effect-free, lifecycle-free function in a hook would add ceremony without value. Co-Authored-By: Claude Opus 4.7 (1M context) --- src/components/goals/NewGoalButton.tsx | 16 ++++++++----- .../money/NewSubscriptionButton.tsx | 24 +++++++++++-------- src/components/today/AddCommitmentButton.tsx | 2 ++ 3 files changed, 26 insertions(+), 16 deletions(-) diff --git a/src/components/goals/NewGoalButton.tsx b/src/components/goals/NewGoalButton.tsx index 931596572..e618fdcee 100644 --- a/src/components/goals/NewGoalButton.tsx +++ b/src/components/goals/NewGoalButton.tsx @@ -7,6 +7,7 @@ import { GOAL_STATUS } from "@/lib/constants/statuses"; import { Field } from "@/components/ui/form"; import { ModalForm } from "@/components/ui/modal-form"; import { useCreateMutation } from "@/hooks/use-create-mutation"; +import { haptic } from "@/lib/haptics"; export function NewGoalButton({ goals }: { goals: GoalWithChildren[] }) { const [title, setTitle] = useState(""); @@ -22,12 +23,15 @@ export function NewGoalButton({ goals }: { goals: GoalWithChildren[] }) { setTitle(""); setDescription(""); setTargetDate(""); setParentGoalId(""); setError(null); }; - const onSubmit = () => create({ - title: title.trim(), - description: description.trim() || undefined, - targetDate: targetDate || undefined, - parentGoalId: parentGoalId || undefined, - }); + const onSubmit = () => { + haptic(); + return create({ + title: title.trim(), + description: description.trim() || undefined, + targetDate: targetDate || undefined, + parentGoalId: parentGoalId || undefined, + }); + }; // Flatten goal tree for parent selector (exclude completed goals) const flatGoals: Array<{ id: string; title: string; depth: number }> = []; diff --git a/src/components/money/NewSubscriptionButton.tsx b/src/components/money/NewSubscriptionButton.tsx index c93033d6c..3312b9f42 100644 --- a/src/components/money/NewSubscriptionButton.tsx +++ b/src/components/money/NewSubscriptionButton.tsx @@ -7,6 +7,7 @@ import { ModalForm } from "@/components/ui/modal-form"; import { useCreateMutation } from "@/hooks/use-create-mutation"; import { postJson } from "@/lib/api/fetch"; import type { CreateSubscriptionInput } from "@/db/queries/money"; +import { haptic } from "@/lib/haptics"; export function NewSubscriptionButton() { const [name, setName] = useState(""); @@ -28,16 +29,19 @@ export function NewSubscriptionButton() { setError(null); }; - const onSubmit = () => create({ - name: name.trim(), - vendor: vendor.trim() || undefined, - amount: amount ? parseFloat(amount) : undefined, - currency, - frequency, - nextDue: nextDue || undefined, - paymentMethod: paymentMethod.trim() || undefined, - notes: notes.trim() || undefined, - }); + const onSubmit = () => { + haptic(); + return create({ + name: name.trim(), + vendor: vendor.trim() || undefined, + amount: amount ? parseFloat(amount) : undefined, + currency, + frequency, + nextDue: nextDue || undefined, + paymentMethod: paymentMethod.trim() || undefined, + notes: notes.trim() || undefined, + }); + }; return (