From 8d8aac1613ff4c68345ecabe5eb7ea802933a171 Mon Sep 17 00:00:00 2001 From: ngyngcphu Date: Wed, 15 May 2024 05:59:02 +0700 Subject: [PATCH] chore: not yet form create-room --- app/home/page.tsx | 52 ++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 45 insertions(+), 7 deletions(-) diff --git a/app/home/page.tsx b/app/home/page.tsx index d0e8c69..f7ab575 100644 --- a/app/home/page.tsx +++ b/app/home/page.tsx @@ -11,7 +11,12 @@ import { DropdownMenuRadioItem, DropdownMenuTrigger, } from "@radix-ui/react-dropdown-menu"; -import { ChevronDownIcon, ShieldCheckIcon, Volume2Icon } from "lucide-react"; +import { + ChevronDownIcon, + CirclePlusIcon, + ShieldCheckIcon, + Volume2Icon, +} from "lucide-react"; import _ from "lodash"; import { Button } from "@/components/ui/button"; import { apiClient } from "@/lib/apiClient"; @@ -120,6 +125,30 @@ function RoomStatusSection({ rooms }: { rooms: RoomStatus[] }) { })); const isHouseSafe = roomData.every((room) => room.isSafe); + const { email } = useEmailStore(); + const { jwt } = useJwtStore(); + const { toast } = useToast(); + + const createRoom = async () => { + const res = await apiClient.POST("/api/rooms/", { + body: { + email, + room_name: "New Room", + }, + headers: { + jwt, + }, + }); + + if (res.error) { + toast({ + title: "Create room failed", + description: res.error.message, + variant: "destructive", + }); + return; + } + }; return ( @@ -137,13 +166,22 @@ function RoomStatusSection({ rooms }: { rooms: RoomStatus[] }) {

{roomData.length > 0 && ( - - - +
+ + +
)}