Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UI Improvement and Bug fixes #59

Merged
merged 20 commits into from
Dec 15, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
refactor: using dialog instead of route
PrinceBaghel258025 committed Dec 12, 2023
commit 324a92b0087f07e24c319d052d756bb56a2a7728
122 changes: 65 additions & 57 deletions src/components/customProfile.tsx
Original file line number Diff line number Diff line change
@@ -16,14 +16,17 @@ import {
useAuth,
useOrganization,
useOrganizationList,
OrganizationProfile,
} from "@clerk/nextjs";
import { Avatar, AvatarFallback, AvatarImage } from "@/components/avatar";
import Link from "next/link";
import { Dialog, DialogContent, DialogTrigger } from "@/components/ui/dialog";
import { UserProfile } from "@clerk/nextjs";

type Props = {};

const CustomProfile = (props: Props) => {
const { signOut, isSignedIn, orgId, orgSlug, userId } = useAuth();
const [isPersonalProfile, setIsPersonalProfile] = React.useState(true);

const { user } = useUser();

@@ -42,65 +45,70 @@ const CustomProfile = (props: Props) => {
});

const organization = useOrganization();
// console.log("user", user);
// console.log(
// "organizationList",
// organizationList?.map((o) => ({
// img: o.organization.imageUrl,
// name: o.organization.name,
// })),
// userMemberships,
// );
return (
<div>
<DropdownMenu>
<DropdownMenuTrigger asChild className="cursor-pointer">
<Avatar>
<AvatarImage src={user?.imageUrl} />
<AvatarFallback>{user?.firstName}</AvatarFallback>
</Avatar>
</DropdownMenuTrigger>
<DropdownMenuContent className="w-56">
<DropdownMenuLabel>My Account</DropdownMenuLabel>
<DropdownMenuSeparator />
<DropdownMenuGroup>
<DropdownMenuItem>
<User className="mr-2 h-4 w-4" />
<Link href="/user-profile">Profile</Link>
{/* <DropdownMenuShortcut>⇧⌘P</DropdownMenuShortcut> */}
</DropdownMenuItem>
</DropdownMenuGroup>
<DropdownMenuSeparator />
<DropdownMenuLabel>Organizations</DropdownMenuLabel>
<DropdownMenuSeparator />
<DropdownMenuGroup>
{organizationList?.map((o) => (
<DropdownMenuCheckboxItem
checked={o.membership.organization.id === orgId}
onCheckedChange={() => {
setActive({ organization: o.membership.organization.id });
}}
key={o.membership.organization.id}
>
<Avatar className="mr-2 h-4 w-4">
<AvatarImage src={o.organization.imageUrl} />
<AvatarFallback>{o.organization.name[0]}</AvatarFallback>
</Avatar>
<span>{o.membership.organization.name}</span>
</DropdownMenuCheckboxItem>
))}
<DropdownMenuItem>
<Settings className="mr-2 h-4 w-4" />
<Link href="/organization-profile">Manage Organization</Link>
<Dialog>
<DropdownMenu>
<DropdownMenuTrigger asChild className="cursor-pointer">
<Avatar>
<AvatarImage src={user?.imageUrl} />
<AvatarFallback>{user?.firstName}</AvatarFallback>
</Avatar>
</DropdownMenuTrigger>
<DropdownMenuContent className="w-56">
<DropdownMenuLabel>My Account</DropdownMenuLabel>
<DropdownMenuSeparator />
<DropdownMenuGroup>
<DropdownMenuItem>
<User className="mr-2 h-4 w-4" />
{/* <Link href="/user-profile">Profile</Link> */}

<DialogTrigger onClick={() => setIsPersonalProfile(true)}>
Profile
</DialogTrigger>

{/* <DropdownMenuShortcut>⇧⌘P</DropdownMenuShortcut> */}
</DropdownMenuItem>
</DropdownMenuGroup>
<DropdownMenuSeparator />
<DropdownMenuLabel>Organizations</DropdownMenuLabel>
<DropdownMenuSeparator />
<DropdownMenuGroup>
{organizationList?.map((o) => (
<DropdownMenuCheckboxItem
checked={o.membership.organization.id === orgId}
onCheckedChange={() => {
setActive({ organization: o.membership.organization.id });
}}
key={o.membership.organization.id}
>
<Avatar className="mr-2 h-4 w-4">
<AvatarImage src={o.organization.imageUrl} />
<AvatarFallback>{o.organization.name[0]}</AvatarFallback>
</Avatar>
<span>{o.membership.organization.name}</span>
</DropdownMenuCheckboxItem>
))}
<DropdownMenuItem>
<Settings className="mr-2 h-4 w-4" />
<DialogTrigger onClick={() => setIsPersonalProfile(false)}>
Manage Organization
</DialogTrigger>
</DropdownMenuItem>
</DropdownMenuGroup>
<DropdownMenuSeparator />
<DropdownMenuItem onClick={() => signOut()}>
<LogOut className="mr-2 h-4 w-4" />
<span>Log out</span>
</DropdownMenuItem>
</DropdownMenuGroup>
<DropdownMenuSeparator />
<DropdownMenuItem onClick={() => signOut()}>
<LogOut className="mr-2 h-4 w-4" />
<span>Log out</span>
</DropdownMenuItem>
</DropdownMenuContent>
</DropdownMenu>
</DropdownMenuContent>
</DropdownMenu>
<DialogContent className="md:max-w-[900px] md:max-h-[480px] overflow-hidden">
<div className="grid max-h-52 md:max-h-[432px] overflow-scroll">
{isPersonalProfile ? <UserProfile /> : <OrganizationProfile />}
</div>
</DialogContent>
</Dialog>
</div>
);
};