diff --git a/.idea/jsLibraryMappings.xml b/.idea/jsLibraryMappings.xml
new file mode 100644
index 0000000..d23208f
--- /dev/null
+++ b/.idea/jsLibraryMappings.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/biome.json b/biome.json
index 827672f..3b5fafa 100644
--- a/biome.json
+++ b/biome.json
@@ -9,5 +9,10 @@
"recommended": true
}
},
+ "javascript": {
+ "formatter": {
+ "semicolons": "asNeeded"
+ }
+ },
"formatter": { "indentStyle": "space", "indentWidth": 2 }
}
diff --git a/bun.lockb b/bun.lockb
index 774c8de..4e90f88 100755
Binary files a/bun.lockb and b/bun.lockb differ
diff --git a/src/components/auth-redirect/index.tsx b/src/components/auth-redirect/index.tsx
index 8b03e6c..dd5f54a 100644
--- a/src/components/auth-redirect/index.tsx
+++ b/src/components/auth-redirect/index.tsx
@@ -1,31 +1,31 @@
-import type { FC, ReactNode } from "react";
-import { useEffect } from "react";
+import type { FC, ReactNode } from "react"
+import { useEffect } from "react"
-import { useRouter } from "next/router";
+import { useRouter } from "next/router"
-import { Loader } from "../loader";
+import { Loader } from "../loader"
-import { useMeQuery } from "@/services";
+import { useMeQuery } from "@/services"
export const AuthRedirect: FC<{ children: ReactNode }> = ({ children }) => {
- const router = useRouter();
- const { data: user, isLoading } = useMeQuery();
+ const router = useRouter()
+ const { data: user, isLoading } = useMeQuery()
const isAuthPage =
- router.pathname === "/login" || router.pathname === "/sign-up";
+ router.pathname === "/login" || router.pathname === "/sign-up"
useEffect(() => {
if (!isLoading && !user && !isAuthPage) {
- router.push("/login");
+ router.push("/login")
}
- }, [user, isLoading, isAuthPage, router]);
+ }, [user, isLoading, isAuthPage, router])
if (isLoading || (!user && !isAuthPage)) {
return (
- );
+ )
}
- return <>{children}>;
-};
+ return <>{children}>
+}
diff --git a/src/components/button/index.tsx b/src/components/button/index.tsx
index 2f48aeb..6088487 100644
--- a/src/components/button/index.tsx
+++ b/src/components/button/index.tsx
@@ -1,10 +1,10 @@
-import type { ComponentPropsWithoutRef, FC } from "react";
+import type { ComponentPropsWithoutRef, FC } from "react"
-import { cn } from "@/helpers";
+import { cn } from "@/helpers"
type Props = ComponentPropsWithoutRef<"button"> & {
- variant?: "primary" | "outlined" | "icon";
-};
+ variant?: "primary" | "outlined" | "icon"
+}
export const Button: FC = ({
className,
@@ -18,9 +18,9 @@ export const Button: FC = ({
variant === "outlined" && "border-sky-700 bg-inherit text-sky-700",
variant === "icon" &&
"h-6 w-6 shrink-0 border-none bg-inherit p-0 text-sky-700 hover:bg-slate-100 hover:text-sky-800",
- className
+ className,
)}
{...rest}
/>
- );
-};
+ )
+}
diff --git a/src/components/fullscreen-loader/index.tsx b/src/components/fullscreen-loader/index.tsx
index c6a6a64..0f7911a 100644
--- a/src/components/fullscreen-loader/index.tsx
+++ b/src/components/fullscreen-loader/index.tsx
@@ -1,9 +1,9 @@
-import { Loader } from "../loader";
+import { Loader } from "../loader"
export const FullscreenLoader = () => {
return (
- );
-};
+ )
+}
diff --git a/src/components/index.ts b/src/components/index.ts
index bb544b5..7775d5a 100644
--- a/src/components/index.ts
+++ b/src/components/index.ts
@@ -1,6 +1,6 @@
-export * from "./todolist";
-export * from "./auth-redirect";
-export * from "./button";
-export * from "./input";
-export * from "./loader";
-export * from "./fullscreen-loader";
+export * from "./todolist"
+export * from "./auth-redirect"
+export * from "./button"
+export * from "./input"
+export * from "./loader"
+export * from "./fullscreen-loader"
diff --git a/src/components/input/index.tsx b/src/components/input/index.tsx
index 4d55992..4a123cc 100644
--- a/src/components/input/index.tsx
+++ b/src/components/input/index.tsx
@@ -1,9 +1,9 @@
-import type { DetailedHTMLProps, FC, InputHTMLAttributes } from "react";
+import type { DetailedHTMLProps, FC, InputHTMLAttributes } from "react"
type Props = DetailedHTMLProps<
InputHTMLAttributes,
HTMLInputElement
->;
+>
export const Input: FC = ({ className, ...rest }) => {
return (
@@ -11,5 +11,5 @@ export const Input: FC = ({ className, ...rest }) => {
className={`w-full rounded-md border border-gray-300 px-4 py-2 focus:border-transparent focus:outline-none focus:ring-2 focus:ring-blue-600 ${className}`}
{...rest}
/>
- );
-};
+ )
+}
diff --git a/src/components/loader/index.tsx b/src/components/loader/index.tsx
index 0e6b3e1..b2e8265 100644
--- a/src/components/loader/index.tsx
+++ b/src/components/loader/index.tsx
@@ -3,5 +3,5 @@ export const Loader = () => {
- );
-};
+ )
+}
diff --git a/src/components/todolist/index.tsx b/src/components/todolist/index.tsx
index 4953708..5bf07bd 100644
--- a/src/components/todolist/index.tsx
+++ b/src/components/todolist/index.tsx
@@ -1,19 +1,19 @@
-import type { ChangeEvent, FC, FormEvent, MouseEventHandler } from "react";
-import { memo, useState } from "react";
+import type { ChangeEvent, FC, FormEvent } from "react"
+import { memo, useState } from "react"
-import { Trash, Plus } from "lucide-react";
+import { Plus, Trash } from "lucide-react"
import type {
Task,
Todolist as TodolistType,
-} from "../../services/todolist-api/todolists";
-import { Button } from "../button";
-import { Input } from "../input";
+} from "../../services/todolist-api/todolists"
+import { Button } from "../button"
+import { Input } from "../input"
import {
ToggleGroup,
ToggleGroupItem,
-} from "@/components/toggle-group/toggle-group";
+} from "@/components/toggle-group/toggle-group"
import {
TaskStatus,
useCreateTaskMutation,
@@ -21,62 +21,62 @@ import {
useDeleteTodolistMutation,
useGetTasksQuery,
useUpdateTaskMutation,
-} from "@/services";
+} from "@/services"
type Props = {
- todolist: TodolistType;
-};
+ todolist: TodolistType
+}
-type Filter = "all" | "active" | "completed";
+type Filter = "all" | "active" | "completed"
export const Todolist: FC = memo(({ todolist }) => {
- const { data: tasks, isLoading } = useGetTasksQuery(todolist.id);
- const { mutate: putTask } = useUpdateTaskMutation();
- const { mutate: deleteTask } = useDeleteTaskMutation();
- const { mutate: deleteTodolist } = useDeleteTodolistMutation();
- const { mutate: createTask } = useCreateTaskMutation();
- const [newTaskTitle, setNewTaskTitle] = useState("");
- const [filter, setFilter] = useState("all");
+ const { data: tasks, isLoading } = useGetTasksQuery(todolist.id)
+ const { mutate: putTask } = useUpdateTaskMutation()
+ const { mutate: deleteTask } = useDeleteTaskMutation()
+ const { mutate: deleteTodolist } = useDeleteTodolistMutation()
+ const { mutate: createTask } = useCreateTaskMutation()
+ const [newTaskTitle, setNewTaskTitle] = useState("")
+ const [filter, setFilter] = useState("all")
const handleChangeStatus = (todolistId: string, task: Task) => {
const newTask: Task = {
...task,
status:
task.status === TaskStatus.DONE ? TaskStatus.OPEN : TaskStatus.DONE,
- };
+ }
- putTask({ todolistId, task: newTask });
- };
+ putTask({ todolistId, task: newTask })
+ }
const handleDeleteTask = (todolistId: string, taskId: string) => {
- deleteTask({ todolistId, taskId });
- };
+ deleteTask({ todolistId, taskId })
+ }
const handleDeleteTodolist = (todolistId: string) => {
- deleteTodolist({ todolistId });
- };
+ deleteTodolist({ todolistId })
+ }
const handleAddTask = (e: FormEvent) => {
- e.preventDefault();
- createTask({ todolistId: todolist.id, title: newTaskTitle });
- setNewTaskTitle("");
- };
+ e.preventDefault()
+ createTask({ todolistId: todolist.id, title: newTaskTitle })
+ setNewTaskTitle("")
+ }
const handleNewTaskTitleChange = (e: ChangeEvent) => {
- setNewTaskTitle(e.target.value);
- };
+ setNewTaskTitle(e.target.value)
+ }
const handleFilterChange = (value: string) => {
- setFilter(value as Filter);
- };
+ setFilter(value as Filter)
+ }
- if (isLoading) return loading...
;
+ if (isLoading) return loading...
const filteredTasks = tasks?.filter((task) => {
switch (filter) {
case "active":
- return task.status === TaskStatus.OPEN;
+ return task.status === TaskStatus.OPEN
case "completed":
- return task.status === TaskStatus.DONE;
+ return task.status === TaskStatus.DONE
default:
- return true;
+ return true
}
- });
+ })
return (
= memo(({ todolist }) => {
- );
+ )
})}
= memo(({ todolist }) => {
- );
-});
+ )
+})
diff --git a/src/components/toggle-group/toggle-group.tsx b/src/components/toggle-group/toggle-group.tsx
index 21339d1..2d1acc9 100644
--- a/src/components/toggle-group/toggle-group.tsx
+++ b/src/components/toggle-group/toggle-group.tsx
@@ -1,12 +1,12 @@
-"use client";
+"use client"
-import * as React from "react";
+import * as React from "react"
-import * as ToggleGroupPrimitive from "@radix-ui/react-toggle-group";
-import type { VariantProps } from "class-variance-authority";
-import { cva } from "class-variance-authority";
+import * as ToggleGroupPrimitive from "@radix-ui/react-toggle-group"
+import type { VariantProps } from "class-variance-authority"
+import { cva } from "class-variance-authority"
-import { cn } from "@/helpers";
+import { cn } from "@/helpers"
const toggleVariants = cva(
"inline-flex border border-sky-700 items-center justify-center rounded-md text-sm font-medium transition-colors hover:bg-muted hover:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 data-[state=on]:bg-sky-700 data-[state=on]:text-white",
@@ -27,14 +27,14 @@ const toggleVariants = cva(
variant: "default",
size: "default",
},
- }
-);
+ },
+)
const ToggleGroupContext = React.createContext<
VariantProps
>({
size: "default",
variant: "default",
-});
+})
const ToggleGroup = React.forwardRef<
React.ElementRef,
@@ -50,16 +50,16 @@ const ToggleGroup = React.forwardRef<
{children}
-));
+))
-ToggleGroup.displayName = ToggleGroupPrimitive.Root.displayName;
+ToggleGroup.displayName = ToggleGroupPrimitive.Root.displayName
const ToggleGroupItem = React.forwardRef<
React.ElementRef,
React.ComponentPropsWithoutRef &
VariantProps
>(({ className, children, variant, size, ...props }, ref) => {
- const context = React.useContext(ToggleGroupContext);
+ const context = React.useContext(ToggleGroupContext)
return (
{children}
- );
-});
+ )
+})
-ToggleGroupItem.displayName = ToggleGroupPrimitive.Item.displayName;
+ToggleGroupItem.displayName = ToggleGroupPrimitive.Item.displayName
-export { ToggleGroup, ToggleGroupItem };
+export { ToggleGroup, ToggleGroupItem }
diff --git a/src/constants/index.ts b/src/constants/index.ts
index bbe7f52..7b27518 100644
--- a/src/constants/index.ts
+++ b/src/constants/index.ts
@@ -1,3 +1,3 @@
-export * from "./routes";
-export * from "./query-keys";
-export * from "./result-code";
+export * from "./routes"
+export * from "./query-keys"
+export * from "./result-code"
diff --git a/src/constants/query-keys/index.ts b/src/constants/query-keys/index.ts
index 417b25b..6e9343c 100644
--- a/src/constants/query-keys/index.ts
+++ b/src/constants/query-keys/index.ts
@@ -2,4 +2,4 @@ export const QUERY_KEYS = {
TODOLISTS: "todolists",
TASKS: "tasks",
ME: "me",
-} as const;
+} as const
diff --git a/src/constants/routes/index.ts b/src/constants/routes/index.ts
index 956fa1a..9f5ae9c 100644
--- a/src/constants/routes/index.ts
+++ b/src/constants/routes/index.ts
@@ -1,4 +1,4 @@
export const ROUTES = {
HOME: "/",
LOGIN: "/login",
-} as const;
+} as const
diff --git a/src/env/client.mjs b/src/env/client.mjs
index 107c6d3..5d17abd 100644
--- a/src/env/client.mjs
+++ b/src/env/client.mjs
@@ -1,35 +1,35 @@
// @ts-check
-import { clientEnv, clientSchema } from "./schema.mjs";
+import { clientEnv, clientSchema } from "./schema.mjs"
-const _clientEnv = clientSchema.safeParse(clientEnv);
+const _clientEnv = clientSchema.safeParse(clientEnv)
export const formatErrors = (
/** @type {import('zod').ZodFormattedError