-
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] Fixes around room page (#51)
roomのupdate、delete関数定義場所をcomponentsからclient-actionsに変更 ファイル名、引数名などの統一
- Loading branch information
Showing
6 changed files
with
125 additions
and
119 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
File renamed without changes.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
"use client"; | ||
|
||
import { redirect } 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 Link from "next/link"; | ||
import { updateRoom, deleteRoom } from "@/app/lib/client-actions"; | ||
|
||
type Room = { id: number; name?: string }; | ||
|
||
export type { Room }; | ||
|
||
export default function RoomCard({ room }: { room: Room }) { | ||
return ( | ||
<> | ||
<Card className="w-[300px]"> | ||
<CardHeader>Room ID: {room.id}</CardHeader> | ||
<CardContent> | ||
<form | ||
onSubmit={(e) => { | ||
updateRoom(e, room.id); | ||
}} | ||
id={"UpdateRoomForm." + room.id} | ||
> | ||
<div className="grid w-full items-center gap-4"> | ||
<div className="flex flex-col space-y-1.5"> | ||
<Label htmlFor="name">Name</Label> | ||
<Input | ||
id="name" | ||
type="text" | ||
name="name" | ||
defaultValue={room.name} | ||
/> | ||
</div> | ||
</div> | ||
</form> | ||
</CardContent> | ||
<CardFooter className="flex justify-between"> | ||
<Button asChild> | ||
<Link href={`/room/${room.id}`}>Join</Link> | ||
</Button> | ||
<Button | ||
type="button" | ||
onClick={(e) => { | ||
deleteRoom(e, room.id); | ||
}} | ||
> | ||
Delete | ||
</Button> | ||
<Button | ||
variant="outline" | ||
type="submit" | ||
form={"UpdateRoomForm." + room.id} | ||
> | ||
Update | ||
</Button> | ||
</CardFooter> | ||
</Card> | ||
</> | ||
); | ||
} |