mirror of
https://github.com/bitbaum/loki.git
synced 2026-12-04 11:07:40 +01:00
feat(haptics): tick on Add X create CTAs
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) <noreply@anthropic.com>
This commit is contained in:
3 files changed
+26
-16
No files matched your search
@@ -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 }> = [];
|
||||
|
||||
@@ -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 (
|
||||
<ModalForm
|
||||
|
||||
@@ -5,6 +5,7 @@ import { Plus, X, Loader2 } from "lucide-react";
|
||||
import { postJson } from "@/lib/api/fetch";
|
||||
import { useCreateMutation } from "@/hooks/use-create-mutation";
|
||||
import type { CreateCommitmentInput } from "@/db/queries/today";
|
||||
import { haptic } from "@/lib/haptics";
|
||||
|
||||
export function AddCommitmentButton() {
|
||||
const [open, setOpen] = useState(false);
|
||||
@@ -28,6 +29,7 @@ export function AddCommitmentButton() {
|
||||
setError("Description is required");
|
||||
return;
|
||||
}
|
||||
haptic();
|
||||
const ok = await create({
|
||||
description,
|
||||
dueDate: dueDate || undefined,
|
||||
|
||||
Reference in new issue
Block a user