Skip to content

Commit 548c2c3

Browse files
committed
feat/refactor/fix: Multiple updates and improvements
1 parent 53b6c41 commit 548c2c3

File tree

16 files changed

+520
-213
lines changed

16 files changed

+520
-213
lines changed

apps/collabydraw/actions/room.ts

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,3 +168,29 @@ export async function deleteRoom(data: { roomName: string }) {
168168
return { success: false, error: "Failed to delete room" };
169169
}
170170
}
171+
172+
export async function getUserRooms() {
173+
try {
174+
const session = await getServerSession(authOptions);
175+
const user = session?.user;
176+
177+
if (!user || !user.id) {
178+
return { success: false, error: "User not authenticated" };
179+
}
180+
181+
const rooms = await client.room.findMany({
182+
where: { adminId: user.id },
183+
select: {
184+
id: true,
185+
slug: true,
186+
createdAt: true,
187+
updatedAt: true,
188+
},
189+
});
190+
191+
return { success: true, rooms };
192+
} catch (error) {
193+
console.error("Failed to fetch user rooms:", error);
194+
return { success: false, error: "Failed to fetch user rooms" };
195+
}
196+
}

apps/collabydraw/app/(auth-layout)/auth/signin/page.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import Link from "next/link";
44

55
export default function SignInPage() {
66
return (
7-
<Card className="border-0 shadow-none lg:shadow-2xl rounded-3xl mt-10 mx-auto px-6 py-8 lg:mt-0 lg:p-16 relative z-10 dark:!bg-surface-loww max-w-[480px] bg-yellow-light">
7+
<Card className="border-0 shadow-none lg:shadow-2xl rounded-3xl m-0 mx-auto px-6 py-8 lg:p-16 relative z-10 max-w-[480px] bg-yellow-light">
88
<CardHeader className="p-0">
99
<CardTitle className="text-2xl font-bold text-center">Hi there!</CardTitle>
1010
<CardDescription className="text-sm pb-4 text-primary text-center">Enter your email to sign in to your account</CardDescription>

apps/collabydraw/app/(auth-layout)/auth/signup/page.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import Link from "next/link";
44

55
export default function SignUpPage() {
66
return (
7-
<Card className="border-0 shadow-none lg:shadow-2xl rounded-3xl mt-10 mx-auto px-6 py-8 lg:mt-0 lg:p-16 relative z-10 dark:!bg-surface-loww max-w-[480px] bg-yellow-light">
7+
<Card className="border-0 shadow-none lg:shadow-2xl rounded-3xl m-0 mx-auto px-6 py-8 lg:p-16 relative z-10 max-w-[480px] bg-yellow-light">
88
<CardHeader className="p-0">
99
<CardTitle className="text-2xl font-bold text-center">Create an account</CardTitle>
1010
<CardDescription className="text-sm pb-4 text-primary text-center">Enter your email below to create your account</CardDescription>

apps/collabydraw/components/MainMenuStack.tsx

Lines changed: 28 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import {
1818
DownloadIcon,
1919
Upload,
2020
Linkedin,
21+
Share,
2122
} from "lucide-react"
2223
import { Button, buttonVariants } from "@/components/ui/button"
2324
import { Separator } from "@/components/ui/separator"
@@ -26,9 +27,12 @@ import { ConfirmDialog } from "./confirm-dialog"
2627
import { cn } from "@/lib/utils"
2728
import { useTheme } from "next-themes"
2829
import { clearAllChats } from "@/actions/chat"
29-
import { signOut } from "next-auth/react"
30-
import { redirect } from "next/navigation"
30+
import { signOut, useSession } from "next-auth/react"
31+
import { redirect, usePathname } from "next/navigation"
3132
import Link from "next/link"
33+
import { CollaborationAdDialog } from "./CollaborationAdDialog"
34+
import { RoomSharingDialog } from "./RoomSharingDialog"
35+
import CollaborationStartdDialog from "./CollaborationStartdDialog"
3236

3337
interface SidebarProps {
3438
isOpen: boolean
@@ -44,10 +48,13 @@ interface SidebarProps {
4448
}
4549

4650
export function MainMenuStack({ isOpen, onClose, canvasColor, setCanvasColor, isMobile, roomName, isStandalone = false, onClearCanvas, onExportCanvas, onImportCanvas }: SidebarProps) {
47-
const [clearDialogOpen, setClearDialogOpen] = useState(false)
48-
const { theme, setTheme } = useTheme()
51+
const [clearDialogOpen, setClearDialogOpen] = useState(false);
52+
const { theme, setTheme } = useTheme();
53+
const { data: session } = useSession();
4954

50-
console.log('isOpen = ', isOpen);
55+
const pathname = usePathname();
56+
const [isShareOpen, setIsShareOpen] = useState(false);
57+
const decodedPathname = decodeURIComponent(pathname);
5158

5259
useEffect(() => {
5360
const handleOutsideClick = (e: MouseEvent) => {
@@ -93,7 +100,12 @@ export function MainMenuStack({ isOpen, onClose, canvasColor, setCanvasColor, is
93100
<SidebarItem icon={TrashIcon} label="Clear canvas" onClick={() => setClearDialogOpen(true)} />
94101
<SidebarItem icon={DownloadIcon} label="Export Drawing" onClick={onExportCanvas} />
95102
<SidebarItem icon={Upload} label="Import Drawing" onClick={onImportCanvas} />
96-
<SidebarItem icon={UserPlus} onClick={() => redirect('/auth/signup')} label="Sign up" className="text-color-promo hover:text-color-promo font-bold" />
103+
<SidebarItem icon={Share} label="Live collaboration" onClick={() => setIsShareOpen(true)} />
104+
{session?.user && session?.user.id ? (
105+
<CollaborationStartdDialog open={isShareOpen} onOpenChange={setIsShareOpen} />
106+
) : (
107+
<CollaborationAdDialog open={isShareOpen} onOpenChange={setIsShareOpen} />
108+
)}
97109
</>
98110
) : (
99111
<>
@@ -106,12 +118,16 @@ export function MainMenuStack({ isOpen, onClose, canvasColor, setCanvasColor, is
106118
Room Name: <span>{roomName}</span>
107119
</Button>
108120
<SidebarItem icon={Trash} label="Reset the canvas" onClick={() => setClearDialogOpen(true)} />
109-
<SidebarItem icon={LogOut} label="Log Out" onClick={() => signOut({ callbackUrl: '/' })} />
121+
<RoomSharingDialog open={isShareOpen} onOpenChange={setIsShareOpen} link={`${process.env.NODE_ENV !== 'production' ? 'http://localhost:3000' : 'https://collabydraw.com'}/${decodedPathname}`} />
110122
</>
111123
)}
124+
{session?.user && session?.user.id ? (
125+
<SidebarItem icon={LogOut} label="Log Out" onClick={() => signOut({ callbackUrl: '/' })} />
126+
) : (
127+
<SidebarItem icon={UserPlus} onClick={() => redirect('/auth/signup')} label="Sign up" className="text-color-promo hover:text-color-promo font-bold" />
128+
)}
112129

113130
<Separator className="my-4 dark:bg-default-border-color-dark" />
114-
115131
<SidebarLinkItem icon={Github} label="GitHub" url="https://github.com/coderomm" />
116132
<SidebarLinkItem icon={Twitter} label="Twitter / X" url="https://x.com/1omsharma" />
117133
<SidebarLinkItem icon={Linkedin} label="Linkedin" url="https://www.linkedin.com/in/1omsharma/" />
@@ -165,8 +181,7 @@ function SidebarItem({ icon: Icon, label, shortcut, className, onClick }: Sideba
165181
className,
166182
)}
167183
onClick={onClick}
168-
target="_blank"
169-
rel="noopener noreferrer"
184+
title={label}
170185
>
171186
<Icon className="h-4 w-4" />
172187
<span>{label}</span>
@@ -196,6 +211,9 @@ function SidebarLinkItem({ icon: Icon, label, shortcut, className, url }: Sideba
196211
className,
197212
)}
198213
href={url}
214+
target="_blank"
215+
rel="noopener noreferrer"
216+
title={label}
199217
>
200218
<Icon className="h-4 w-4" />
201219
<span>{label}</span>

apps/collabydraw/components/RoomSharingDialog.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,6 @@ export function RoomSharingDialog({ open, onOpenChange, link }: { open: boolean,
9393
<DialogFooter className="flex items-center justify-center sm:justify-center">
9494
<Button
9595
onClick={stopSession}
96-
variant=""
9796
className="py-2 px-6 min-h-12 rounded-md text-[.875rem] font-semibold shadow-none bg-red-500 hover:bg-red-600 active:bg-red-700 active:scale-[.98] text-white"
9897
disabled={isPending}
9998
>

apps/collabydraw/components/SvgIcons.tsx

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,20 @@ export function PaletteFilled({ className }: { className?: string }) {
66
<path fill="currentColor" d="M204.3 5C104.9 24.4 24.8 104.3 5.2 203.4c-37 187 131.7 326.4 258.8 306.7 41.2-6.4 61.4-54.6 42.5-91.7-23.1-45.4 9.9-98.4 60.9-98.4h79.7c35.8 0 64.8-29.6 64.9-65.3C511.5 97.1 368.1-26.9 204.3 5zM96 320c-17.7 0-32-14.3-32-32s14.3-32 32-32 32 14.3 32 32-14.3 32-32 32zm32-128c-17.7 0-32-14.3-32-32s14.3-32 32-32 32 14.3 32 32-14.3 32-32 32zm128-64c-17.7 0-32-14.3-32-32s14.3-32 32-32 32 14.3 32 32-14.3 32-32 32zm128 64c-17.7 0-32-14.3-32-32s14.3-32 32-32 32 14.3 32 32-14.3 32-32 32z"></path>
77
</svg>
88
)
9+
}
10+
11+
export function EllipsisVertical({ className }: { className: string }) {
12+
return (
13+
< svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor" className={cn("size-6", className)}>
14+
<path fillRule="evenodd" d="M10.5 6a1.5 1.5 0 1 1 3 0 1.5 1.5 0 0 1-3 0Zm0 6a1.5 1.5 0 1 1 3 0 1.5 1.5 0 0 1-3 0Zm0 6a1.5 1.5 0 1 1 3 0 1.5 1.5 0 0 1-3 0Z" clipRule="evenodd" />
15+
</svg >
16+
)
17+
}
18+
19+
export function ListBullet({ className }: { className: string }) {
20+
return (
21+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor" className={cn("size-6", className)}>
22+
<path fillRule="evenodd" d="M2.625 6.75a1.125 1.125 0 1 1 2.25 0 1.125 1.125 0 0 1-2.25 0Zm4.875 0A.75.75 0 0 1 8.25 6h12a.75.75 0 0 1 0 1.5h-12a.75.75 0 0 1-.75-.75ZM2.625 12a1.125 1.125 0 1 1 2.25 0 1.125 1.125 0 0 1-2.25 0ZM7.5 12a.75.75 0 0 1 .75-.75h12a.75.75 0 0 1 0 1.5h-12A.75.75 0 0 1 7.5 12Zm-4.875 5.25a1.125 1.125 0 1 1 2.25 0 1.125 1.125 0 0 1-2.25 0Zm4.875 0a.75.75 0 0 1 .75-.75h12a.75.75 0 0 1 0 1.5h-12a.75.75 0 0 1-.75-.75Z" clipRule="evenodd" />
23+
</svg>
24+
)
925
}

apps/collabydraw/components/ToolMenuStack.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ export function ToolMenuStack({
5757
setBgFill={setBgFill}
5858
strokeFill={strokeFill}
5959
setStrokeFill={setStrokeFill}
60+
activeTool={activeTool}
6061
/>
6162

6263
<div className="">
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import { Info } from "lucide-react";
2+
import { Button } from "./ui/button";
3+
import { useState } from "react";
4+
import { UserRoomsListDialog } from "./UserRoomsListDialog";
5+
6+
export default function UserRoomsList() {
7+
const [isOpen, setIsOpen] = useState(false);
8+
return (
9+
<div className="User_Rooms_List fixed z-[4] bottom-4 right-4 rounded-lg hidden md:flex items-center surface-box-shadow">
10+
<Button type="button" onClick={() => setIsOpen(true)}
11+
className="excalidraw-button collab-button relative w-auto py-3 px-4 rounded-md text-[.875rem] font-semibold shadow-none bg-color-primary hover:bg-brand-hover active:bg-brand-active active:scale-[.98]"
12+
title="See All Rooms..."><Info /></Button>
13+
<UserRoomsListDialog open={isOpen} onOpenChange={setIsOpen} />
14+
</div>
15+
);
16+
};

0 commit comments

Comments
 (0)