From 85a7a7df2bccd6fc5c768a5d4ac7b877090f7f75 Mon Sep 17 00:00:00 2001 From: Aaryan Khandelwal <65252264+aaryan610@users.noreply.github.com> Date: Tue, 1 Aug 2023 13:31:16 +0530 Subject: [PATCH] chore: profile dropdown in the sidebar (#1737) * chore: profile dropdown in the sidebar * style: update spacing and font sizes --- .../components/workspace/sidebar-dropdown.tsx | 282 +++++++++++------- 1 file changed, 167 insertions(+), 115 deletions(-) diff --git a/apps/app/components/workspace/sidebar-dropdown.tsx b/apps/app/components/workspace/sidebar-dropdown.tsx index b8f68cf9a..c9addf8db 100644 --- a/apps/app/components/workspace/sidebar-dropdown.tsx +++ b/apps/app/components/workspace/sidebar-dropdown.tsx @@ -16,7 +16,7 @@ import useToast from "hooks/use-toast"; import userService from "services/user.service"; import authenticationService from "services/authentication.service"; // components -import { Avatar, Loader } from "components/ui"; +import { Avatar, Icon, Loader } from "components/ui"; // icons import { CheckIcon, PlusIcon } from "@heroicons/react/24/outline"; // helpers @@ -40,6 +40,19 @@ const userLinks = (workspaceSlug: string, userId: string) => [ }, ]; +const profileLinks = (workspaceSlug: string, userId: string) => [ + { + name: "View profile", + icon: "account_circle", + link: `/${workspaceSlug}/profile/${userId}`, + }, + { + name: "Settings", + icon: "settings", + link: `/${workspaceSlug}/me/profile`, + }, +]; + export const WorkspaceSidebarDropdown = () => { const router = useRouter(); const { workspaceSlug } = router.query; @@ -90,8 +103,8 @@ export const WorkspaceSidebarDropdown = () => { }; return ( - -
+
+
{
- {!sidebarCollapse && ( - - -
- -
-
- - )} -
- - - -
-
{user?.email}
- Workspace - {workspaces ? ( -
- {workspaces.length > 0 ? ( - workspaces.map((workspace) => ( - - {({ active }) => ( - - )} +
+ {truncateText(workspace.name, 18)} +
+
+ + + + + )} + + )) + ) : ( +

No workspace found!

+ )} + { + router.push("/create-workspace"); + }} + className="flex w-full items-center gap-1 text-sm text-custom-sidebar-text-200" + > + + Create Workspace + +
+ ) : ( +
+ + + + +
+ )} +
+
+ {userLinks(workspaceSlug?.toString() ?? "", user?.id ?? "").map((link, index) => ( + + + {link.name} + + + ))} +
+
+ + Sign out + +
+ + +
+ + {!sidebarCollapse && ( + + + + + + + +
+ {profileLinks(workspaceSlug?.toString() ?? "", user?.id ?? "").map( + (link, index) => ( + + + + + {link.name} + + - )) - ) : ( -

No workspace found!

+ ) )} +
+
{ - router.push("/create-workspace"); - }} - className="flex w-full items-center gap-1 text-sm text-custom-sidebar-text-200" + className="flex w-full items-center gap-2 rounded px-2 py-1 hover:bg-custom-sidebar-background-80" + onClick={handleSignOut} > - - Create Workspace + + Log out
- ) : ( -
- - - - -
- )} - -
- {userLinks(workspaceSlug?.toString() ?? "", user?.id ?? "").map((link, index) => ( - - - {link.name} - - - ))} -
-
- - Sign out - -
-
-
-
+ + + + )} + ); };