diff --git a/client/src/chakra/theme.ts b/client/src/chakra/theme.ts index 4fb47fd..3c18195 100644 --- a/client/src/chakra/theme.ts +++ b/client/src/chakra/theme.ts @@ -12,7 +12,7 @@ const theme = extendTheme({ styles: { global: (props: any) => ({ body: { - backgroundColor: mode("gray.500", "")(props), + backgroundColor: mode("gray.300", "")(props), }, }), }, diff --git a/client/src/components/TodoForm.tsx b/client/src/components/TodoForm.tsx index 058e5f2..847fe37 100644 --- a/client/src/components/TodoForm.tsx +++ b/client/src/components/TodoForm.tsx @@ -1,68 +1,72 @@ /* eslint-disable @typescript-eslint/no-explicit-any */ -import { Button, Flex, Input, Spinner } from "@chakra-ui/react"; +import { Button, Flex, Input, Spinner, useColorMode } from "@chakra-ui/react"; import { useMutation, useQueryClient } from "@tanstack/react-query"; import { useState } from "react"; import { IoMdAdd } from "react-icons/io"; import { BASE_URL } from "../App"; const TodoForm = () => { - const [newTodo, setNewTodo] = useState(""); + const [newTodo, setNewTodo] = useState(""); + const { colorMode } = useColorMode(); // Chakra UI hook to get the current color mode - const queryClient = useQueryClient(); + const queryClient = useQueryClient(); - const { mutate: createTodo, isPending: isCreating } = useMutation({ - mutationKey: ["createTodo"], - mutationFn: async (e: React.FormEvent) => { - e.preventDefault(); - try { - const res = await fetch(BASE_URL + `/todos`, { - method: "POST", - headers: { - "Content-Type": "application/json", - }, - body: JSON.stringify({ body: newTodo }), - }); - const data = await res.json(); + const { mutate: createTodo, isPending: isCreating } = useMutation({ + mutationKey: ["createTodo"], + mutationFn: async (e: React.FormEvent) => { + e.preventDefault(); + try { + const res = await fetch(BASE_URL + `/todos`, { + method: "POST", + headers: { + "Content-Type": "application/json", + }, + body: JSON.stringify({ body: newTodo }), + }); + const data = await res.json(); - if (!res.ok) { - throw new Error(data.error || "Something went wrong"); - } + if (!res.ok) { + throw new Error(data.error || "Something went wrong"); + } - setNewTodo(""); - return data; - } catch (error: any) { - throw new Error(error); - } - }, - onSuccess: () => { - queryClient.invalidateQueries({ queryKey: ["todos"] }); - }, - onError: (error: any) => { - alert(error.message); - }, - }); + setNewTodo(""); + return data; + } catch (error: any) { + throw new Error(error); + } + }, + onSuccess: () => { + queryClient.invalidateQueries({ queryKey: ["todos"] }); + }, + onError: (error: any) => { + alert(error.message); + }, + }); - return ( -
- ); + return ( + + ); }; export default TodoForm;