Skip to content

Commit 405216e

Browse files
golanu814Pranav
andauthored
fix: Improve user settings page card with customization and account deletion capabilities (#95)
* fix: Improve user settings page card with customization and account deletion capabilities * fix: Improve settings UI again --------- Co-authored-by: Pranav <anupragol05@users.noreply.github.com>
1 parent d3b15b3 commit 405216e

File tree

10 files changed

+747
-233
lines changed

10 files changed

+747
-233
lines changed

client/app/dashboard/layout.tsx

Lines changed: 72 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,9 @@ import {
3838
DropdownMenuItem,
3939
DropdownMenuSeparator,
4040
DropdownMenuTrigger,
41+
DropdownMenuLabel,
4142
} from "@/components/ui/dropdown-menu";
43+
import { Button } from "@/components/ui/button";
4244
import { Lordicon } from "@/components/lordicon";
4345
import Link from "next/link";
4446
import { useAuth } from "@/hooks/use-auth";
@@ -295,19 +297,26 @@ function AppSidebar({ user }: AppSidebarProps) {
295297
);
296298
}
297299

298-
export default function DashboardLayout({
300+
function DashboardLayoutContent({
299301
children,
300302
}: {
301303
children: React.ReactNode;
302304
}) {
303305
const router = useRouter();
304306
const pathname = usePathname();
307+
const { theme, setTheme } = useTheme();
305308
const { user, isAuthenticated, loading } = useAuth();
306309
const [showOnboarding, setShowOnboarding] = useState(false);
307310

308311
useEffect(() => {
312+
// Only redirect if we've finished loading and user is definitely not authenticated
313+
// Add a small delay to avoid race conditions after login
309314
if (!loading && !isAuthenticated) {
310-
router.push("/");
315+
const timer = setTimeout(() => {
316+
// Double-check auth status before redirecting
317+
router.push("/");
318+
}, 200);
319+
return () => clearTimeout(timer);
311320
}
312321
}, [isAuthenticated, loading, router]);
313322

@@ -352,31 +361,69 @@ export default function DashboardLayout({
352361

353362
return (
354363
<TooltipProvider>
355-
<SidebarProvider>
356-
<AppSidebar user={user} />
357-
<SidebarInset>
358-
<header className="flex h-16 shrink-0 items-center gap-2 border-b px-6 transition-[width,height] ease-linear group-has-data-[collapsible=icon]/sidebar-wrapper:h-16">
359-
<div className="flex items-center gap-2">
360-
<SidebarTrigger className="-ml-1" />
361-
<div className="hidden md:flex items-center gap-2 text-xs text-muted-foreground">
362-
<span>Toggle sidebar</span>
363-
<Kbd>{typeof navigator !== 'undefined' && navigator.platform.includes('Mac') ? '⌘' : 'Ctrl'}</Kbd>
364-
<span>+</span>
365-
<Kbd>B</Kbd>
364+
<SidebarProvider>
365+
<AppSidebar user={user} />
366+
<SidebarInset>
367+
<header className="flex h-16 shrink-0 items-center gap-2 border-b px-6 transition-[width,height] ease-linear group-has-data-[collapsible=icon]/sidebar-wrapper:h-16">
368+
<div className="flex items-center gap-2">
369+
<SidebarTrigger className="-ml-1" />
370+
<div className="hidden md:flex items-center gap-2 text-xs text-muted-foreground">
371+
<span>Toggle sidebar</span>
372+
<Kbd>{typeof navigator !== 'undefined' && navigator.platform.includes('Mac') ? '⌘' : 'Ctrl'}</Kbd>
373+
<span>+</span>
374+
<Kbd>B</Kbd>
375+
</div>
366376
</div>
377+
<div className="ml-auto flex items-center gap-4">
378+
<DropdownMenu>
379+
<DropdownMenuTrigger asChild>
380+
<Button variant="ghost" size="icon" className="h-9 w-9">
381+
{theme === "light" ? (
382+
<Sun className="h-4 w-4" />
383+
) : theme === "dark" ? (
384+
<Moon className="h-4 w-4" />
385+
) : (
386+
<Monitor className="h-4 w-4" />
387+
)}
388+
<span className="sr-only">Toggle theme</span>
389+
</Button>
390+
</DropdownMenuTrigger>
391+
<DropdownMenuContent align="end">
392+
<DropdownMenuLabel>Theme</DropdownMenuLabel>
393+
<DropdownMenuSeparator />
394+
<DropdownMenuItem onClick={() => setTheme("light")}>
395+
<Sun className="mr-2 h-4 w-4" />
396+
<span>Light</span>
397+
</DropdownMenuItem>
398+
<DropdownMenuItem onClick={() => setTheme("dark")}>
399+
<Moon className="mr-2 h-4 w-4" />
400+
<span>Dark</span>
401+
</DropdownMenuItem>
402+
<DropdownMenuItem onClick={() => setTheme("system")}>
403+
<Monitor className="mr-2 h-4 w-4" />
404+
<span>System</span>
405+
</DropdownMenuItem>
406+
</DropdownMenuContent>
407+
</DropdownMenu>
408+
{user?.user_id && <NotificationCenter userId={user.user_id} />}
409+
<span className="text-sm text-muted-foreground hidden md:inline">
410+
Crisis Detection Platform
411+
</span>
412+
</div>
413+
</header>
414+
<div className="flex flex-1 flex-col gap-6 p-6 pt-6">
415+
{children}
367416
</div>
368-
<div className="ml-auto flex items-center gap-4">
369-
{user?.user_id && <NotificationCenter userId={user.user_id} />}
370-
<span className="text-sm text-muted-foreground hidden md:inline">
371-
Crisis Detection Platform
372-
</span>
373-
</div>
374-
</header>
375-
<div className="flex flex-1 flex-col gap-6 p-6 pt-6">
376-
{children}
377-
</div>
378-
</SidebarInset>
379-
</SidebarProvider>
417+
</SidebarInset>
418+
</SidebarProvider>
380419
</TooltipProvider>
381420
);
382421
}
422+
423+
export default function DashboardLayout({
424+
children,
425+
}: {
426+
children: React.ReactNode;
427+
}) {
428+
return <DashboardLayoutContent>{children}</DashboardLayoutContent>;
429+
}

0 commit comments

Comments
 (0)