-
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.
* [frontend] ♻️ Move Nav to RootLayout * [frontend] Add user list and signup page to Nav - [frontend] Applied Card component to signup page * [frontend] Fix value to defaultValue in user page * [frontend] Add UserCard component * [frontend] Update title and description * [frontend] Add toast on signup success/failure * [frontend] Redirect to user list page after signup * [frontend] Implement update and delete user * [frontend] `npx prettier --write frontend/src/**/*.tsx` * [frontend] No cache for user page, redirect to user list after delete * [backend] `npx prettier --write backend/src/**/*.ts` * [Makefile] Add fmt target
- Loading branch information
Showing
21 changed files
with
749 additions
and
180 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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 |
---|---|---|
@@ -1,15 +1,13 @@ | ||
import Nav from "../components/Nav"; | ||
import { Button } from "@/components/ui/button"; | ||
|
||
export default function Home() { | ||
return ( | ||
<main className="flex flex-col gap-8 p-24"> | ||
<Nav /> | ||
<> | ||
<div className="text-muted-foreground">Hello</div> | ||
<div className="flex gap-8"> | ||
<Button variant={"secondary"}>Learn More</Button> | ||
<Button>Enroll</Button> | ||
</div> | ||
</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
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,30 +1,74 @@ | ||
"use client"; | ||
|
||
async function submit(event: React.FormEvent<HTMLFormElement>) { | ||
event.preventDefault(); | ||
const res = await fetch(`${process.env.NEXT_PUBLIC_API_URL}/user`, { | ||
method: "POST", | ||
headers: { | ||
"Content-Type": "application/json", | ||
}, | ||
body: JSON.stringify(Object.fromEntries(new FormData(event.currentTarget))), | ||
}); | ||
const user = await res.json(); | ||
console.log(user); | ||
} | ||
import { useRouter } from "next/navigation"; | ||
|
||
// components | ||
import { | ||
Card, | ||
CardContent, | ||
CardDescription, | ||
CardFooter, | ||
CardHeader, | ||
CardTitle, | ||
} from "@/components/ui/card"; | ||
import { Input } from "@/components/ui/input"; | ||
import { Label } from "@/components/ui/label"; | ||
import { Button } from "@/components/ui/button"; | ||
import { useToast } from "@/components/ui/use-toast"; | ||
|
||
export default function SignUp() { | ||
const router = useRouter(); | ||
const { toast } = useToast(); | ||
async function createUser(event: React.FormEvent<HTMLFormElement>) { | ||
event.preventDefault(); | ||
const res = await fetch(`${process.env.NEXT_PUBLIC_API_URL}/user`, { | ||
method: "POST", | ||
headers: { | ||
"Content-Type": "application/json", | ||
}, | ||
body: JSON.stringify( | ||
Object.fromEntries(new FormData(event.currentTarget)), | ||
), | ||
}); | ||
const data = await res.json(); | ||
if (!res.ok) { | ||
toast({ | ||
title: res.status + " " + res.statusText, | ||
description: data.message, | ||
}); | ||
} else { | ||
toast({ | ||
title: "Success", | ||
description: "User created successfully.", | ||
}); | ||
router.push("/user"); | ||
router.refresh(); | ||
} | ||
} | ||
|
||
return ( | ||
<form className="flex flex-col gap-4" onSubmit={submit}> | ||
<label> | ||
<span>Name</span> | ||
<input type="text" name="name" /> | ||
</label> | ||
<label> | ||
<span>Email</span> | ||
<input type="email" name="email" /> | ||
</label> | ||
<button type="submit">Sign Up</button> | ||
</form> | ||
<Card className="w-[300px]"> | ||
<CardHeader>Create Account</CardHeader> | ||
<CardContent> | ||
<form onSubmit={createUser}> | ||
<div className="grid w-full items-center gap-8"> | ||
<div className="flex flex-col space-y-1.5"> | ||
<Label htmlFor="name">Name</Label> | ||
<Input id="name" type="text" name="name" placeholder="nop" /> | ||
</div> | ||
<div className="flex flex-col space-y-1.5"> | ||
<Label htmlFor="email">Email</Label> | ||
<Input | ||
id="email" | ||
type="email" | ||
name="email" | ||
placeholder="[email protected]" | ||
/> | ||
</div> | ||
<Button type="submit">Sign Up</Button> | ||
</div> | ||
</form> | ||
</CardContent> | ||
</Card> | ||
); | ||
} |
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
Oops, something went wrong.