MCPcopy Create free account
hub / github.com/SteveSuv/remix-t3-stack / AddTaskForm

Function AddTaskForm

app/components/AddTaskForm.tsx:12–65  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

10import { LuIcon } from "./LuIcon";
11
12export const AddTaskForm = () => {
13 const { revalidate } = useRevalidator();
14 const { form } = useZodForm(addTaskFormSchema);
15 const addTaskMutation = useMutation(
16 trpcClient.action.addTask.mutationOptions({
17 onSuccess() {
18 toast.success("add task successful");
19 revalidate();
20 },
21 }),
22 );
23
24 return (
25 <form
26 className="flex flex-col gap-2"
27 autoComplete="off"
28 onSubmit={form.handleSubmit(async (data) => {
29 await addTaskMutation.mutateAsync(data);
30 form.reset();
31 })}
32 >
33 <Controller
34 name="content"
35 defaultValue=""
36 control={form.control}
37 render={({ field, fieldState }) => (
38 <>
39 <input
40 {...field}
41 className={clsx(
42 "input input-bordered w-[300px]",
43 fieldState.invalid && "input-error",
44 )}
45 placeholder="input task content"
46 required
47 min={1}
48 max={100}
49 />
50 <small className="text-error">{fieldState.error?.message}</small>
51 </>
52 )}
53 />
54
55 <button
56 className="btn"
57 type="submit"
58 disabled={form.formState.isSubmitting || addTaskMutation.isPending}
59 >
60 <LuIcon icon={Plus} />
61 Add Task
62 </button>
63 </form>
64 );
65};

Callers

nothing calls this directly

Calls 2

useZodFormFunction · 0.90
clsxFunction · 0.90

Tested by

no test coverage detected