Skip to content

Commit

Permalink
Merge branch 'main' of github.com:formbricks/oss.gg into auth-flow
Browse files Browse the repository at this point in the history
  • Loading branch information
mattinannt committed Jan 19, 2024
2 parents 7480fff + c76d050 commit bc07274
Show file tree
Hide file tree
Showing 12 changed files with 172 additions and 316 deletions.
24 changes: 12 additions & 12 deletions app/(dashboard)/dashboard/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
import { notFound } from "next/navigation";
import { notFound } from "next/navigation"

import { dashboardConfig } from "@/config/dashboard";
import { getCurrentUser } from "@/lib/session";
import { MainNav } from "@/components/main-nav";
import { DashboardNav } from "@/components/nav";
import { SiteFooter } from "@/components/site-footer";
import { UserAccountNav } from "@/components/user-account-nav";
import { dashboardConfig } from "@/config/dashboard"
import { getCurrentUser } from "@/lib/session"
import { MainNav } from "@/components/main-nav"
import { DashboardNav } from "@/components/nav"
import { SiteFooter } from "@/components/site-footer"
import { UserAccountNav } from "@/components/user-account-nav"

interface DashboardLayoutProps {
children?: React.ReactNode;
children?: React.ReactNode
}

export default async function DashboardLayout({
children,
}: DashboardLayoutProps) {
const user = await getCurrentUser();
const user = await getCurrentUser()

if (!user) {
return notFound();
return notFound()
}

return (
Expand All @@ -28,7 +28,7 @@ export default async function DashboardLayout({
<UserAccountNav
user={{
name: user.name,
image: user.image,
avatarUrl: user.avatarUrl,
email: user.email,
}}
/>
Expand All @@ -44,5 +44,5 @@ export default async function DashboardLayout({
</div>
<SiteFooter className="border-t" />
</div>
);
)
}
16 changes: 4 additions & 12 deletions app/(dashboard)/dashboard/loading.tsx
Original file line number Diff line number Diff line change
@@ -1,21 +1,13 @@
import { DashboardHeader } from "@/components/header";
import { PostItem } from "@/components/post-item";
import { DashboardShell } from "@/components/shell";
import { Button } from "@/components/ui/button";
import { Button } from "@/components/ui/button"
import { DashboardHeader } from "@/components/header"
import { DashboardShell } from "@/components/shell"

export default function DashboardLoading() {
return (
<DashboardShell>
<DashboardHeader heading="Posts" text="Create and manage posts.">
<Button>Create</Button>
</DashboardHeader>
<div className="divide-border-200 divide-y rounded-md border">
<PostItem.Skeleton />
<PostItem.Skeleton />
<PostItem.Skeleton />
<PostItem.Skeleton />
<PostItem.Skeleton />
</div>
</DashboardShell>
);
)
}
42 changes: 0 additions & 42 deletions components/post-item.tsx

This file was deleted.

114 changes: 0 additions & 114 deletions components/post-operations.tsx

This file was deleted.

28 changes: 16 additions & 12 deletions components/user-account-nav.tsx
Original file line number Diff line number Diff line change
@@ -1,28 +1,32 @@
"use client";
"use client"

import Link from "next/link";
import { User } from "next-auth";
import { signOut } from "next-auth/react";
import Link from "next/link"
import { User } from "next-auth"
import { signOut } from "next-auth/react"

import {
DropdownMenu,
DropdownMenuContent,
DropdownMenuItem,
DropdownMenuSeparator,
DropdownMenuTrigger,
} from "@/components/ui/dropdown-menu";
import { UserAvatar } from "@/components/user-avatar";
} from "@/components/ui/dropdown-menu"
import { UserAvatar } from "@/components/user-avatar"

interface UserAccountNavProps extends React.HTMLAttributes<HTMLDivElement> {
user: Pick<User, "name" | "image" | "email">;
interface UserAccountNavProps {
user: {
name: User["name"]
avatarUrl: User["image"]
email?: User["email"]
}
}

export function UserAccountNav({ user }: UserAccountNavProps) {
return (
<DropdownMenu>
<DropdownMenuTrigger>
<UserAvatar
user={{ name: user.name || null, image: user.image || null }}
user={{ name: user.name || null, avatarUrl: user.avatarUrl || null }}
className="h-8 w-8"
/>
</DropdownMenuTrigger>
Expand All @@ -48,15 +52,15 @@ export function UserAccountNav({ user }: UserAccountNavProps) {
<DropdownMenuItem
className="cursor-pointer"
onSelect={(event) => {
event.preventDefault();
event.preventDefault()
signOut({
callbackUrl: `${window.location.origin}/login`,
});
})
}}
>
Sign out
</DropdownMenuItem>
</DropdownMenuContent>
</DropdownMenu>
);
)
}
16 changes: 8 additions & 8 deletions components/user-avatar.tsx
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
import { User } from "@prisma/client";
import { AvatarProps } from "@radix-ui/react-avatar";
import { User } from "@prisma/client"
import { AvatarProps } from "@radix-ui/react-avatar"
import { UserIcon } from "lucide-react"

import { Avatar, AvatarFallback, AvatarImage } from "@/components/ui/avatar";
import { UserIcon } from "lucide-react";
import { Avatar, AvatarFallback, AvatarImage } from "@/components/ui/avatar"

interface UserAvatarProps extends AvatarProps {
user: Pick<User, "image" | "name">;
user: Pick<User, "avatarUrl" | "name">
}

export function UserAvatar({ user, ...props }: UserAvatarProps) {
return (
<Avatar {...props}>
{user.image ? (
<AvatarImage alt="Picture" src={user.image} />
{user.avatarUrl ? (
<AvatarImage alt="Picture" src={user.avatarUrl} />
) : (
<AvatarFallback>
<span className="sr-only">{user.name}</span>
<UserIcon className="h-4 w-4" />
</AvatarFallback>
)}
</Avatar>
);
)
}
Loading

0 comments on commit bc07274

Please sign in to comment.