-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
17 changed files
with
340 additions
and
61 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { Spinner } from "@nextui-org/react"; | ||
import * as React from "react"; | ||
|
||
export default function Loading() { | ||
return ( | ||
<div> | ||
<Spinner color="primary" labelColor="primary" /> | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,52 @@ | ||
"use client"; | ||
|
||
import { Button, useDisclosure } from "@nextui-org/react"; | ||
import { useRouter } from "next/navigation"; | ||
|
||
import Todo from "~/app/components/todo"; | ||
import TodoModal from "~/app/components/todoModal"; | ||
import { useUser } from "~/hook/user-user"; | ||
|
||
export default function Page(): JSX.Element { | ||
export default function Page() { | ||
const { isOpen, onOpen, onOpenChange } = useDisclosure(); | ||
const router = useRouter(); | ||
|
||
const { data, isLoading } = useUser(); | ||
|
||
const addTodo = () => { | ||
onOpen(); | ||
}; | ||
|
||
if (!data && !isLoading) { | ||
router.push("/login"); | ||
return null; | ||
} | ||
|
||
return ( | ||
<main className="max-w-screen-lg mx-auto p-6 flex flex-col gap-y-12"> | ||
<div className="flex justify-between items-center"> | ||
<h1 className="font-bold text-4xl">Todos</h1> | ||
<Button color="primary" variant="shadow" onClick={addTodo}> | ||
Add Todo | ||
</Button> | ||
</div> | ||
|
||
<ul className="flex flex-col gap-y-4"> | ||
<Todo /> | ||
</ul> | ||
|
||
<TodoModal | ||
isOpen={isOpen} | ||
onOpenChange={onOpenChange} | ||
heading="Add Todo" | ||
onPrimaryAction={() => { | ||
console.info("Add Todo"); | ||
}} | ||
/> | ||
{data && ( | ||
<> | ||
<div className="flex justify-between items-center"> | ||
<h1 className="font-bold text-4xl">Todos</h1> | ||
<Button color="primary" variant="shadow" onClick={addTodo}> | ||
Add Todo | ||
</Button> | ||
</div> | ||
|
||
<ul className="flex flex-col gap-y-4"> | ||
<Todo /> | ||
</ul> | ||
|
||
<TodoModal | ||
isOpen={isOpen} | ||
onOpenChange={onOpenChange} | ||
heading="Add Todo" | ||
onPrimaryAction={() => { | ||
console.info("Add Todo"); | ||
}} | ||
/> | ||
</> | ||
)} | ||
</main> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,15 @@ | ||
"use client"; | ||
|
||
import { NextUIProvider } from "@nextui-org/react"; | ||
import { QueryClient, QueryClientProvider } from "@tanstack/react-query"; | ||
import * as React from "react"; | ||
|
||
export function Providers({ children }: { children: React.ReactNode }) { | ||
return <NextUIProvider>{children}</NextUIProvider>; | ||
const [queryClient] = React.useState(() => new QueryClient()); | ||
|
||
return ( | ||
<NextUIProvider> | ||
<QueryClientProvider client={queryClient}>{children}</QueryClientProvider> | ||
</NextUIProvider> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { useQuery } from "@tanstack/react-query"; | ||
|
||
import { api } from "~/lib/api"; | ||
|
||
export function useUser() { | ||
return useQuery({ | ||
queryFn: api.getUser, | ||
queryKey: ["user"], | ||
retry: 0, | ||
}); | ||
} |
Oops, something went wrong.