From a63713032ff6b15b80348f724246e7abea40c8a4 Mon Sep 17 00:00:00 2001 From: Md Saban <45597394+mdsaban@users.noreply.github.com> Date: Sun, 23 Jun 2024 17:39:40 +0530 Subject: ui: Changes for user settings page (#251) * fix: ui refactoring for user settings page * fix: type error * fix: pr comments --- apps/web/app/dashboard/settings/page.tsx | 15 +++-- .../dashboard/settings/ApiKeySettings.tsx | 14 ++-- .../dashboard/settings/ChangePassword.tsx | 12 ++-- .../components/dashboard/settings/DeleteApiKey.tsx | 4 +- .../components/dashboard/settings/UserDetails.tsx | 33 ++++++++++ apps/web/components/dashboard/sidebar/Sidebar.tsx | 74 +++++++++++++++------- 6 files changed, 108 insertions(+), 44 deletions(-) create mode 100644 apps/web/components/dashboard/settings/UserDetails.tsx diff --git a/apps/web/app/dashboard/settings/page.tsx b/apps/web/app/dashboard/settings/page.tsx index 059660b7..bab76794 100644 --- a/apps/web/app/dashboard/settings/page.tsx +++ b/apps/web/app/dashboard/settings/page.tsx @@ -1,12 +1,17 @@ import ApiKeySettings from "@/components/dashboard/settings/ApiKeySettings"; import { ChangePassword } from "@/components/dashboard/settings/ChangePassword"; +import UserDetails from "@/components/dashboard/settings/UserDetails"; export default async function Settings() { return ( -
-

Settings

- - -
+ <> +
+ + +
+
+ +
+ ); } diff --git a/apps/web/components/dashboard/settings/ApiKeySettings.tsx b/apps/web/components/dashboard/settings/ApiKeySettings.tsx index 1455e1b6..4d43be7a 100644 --- a/apps/web/components/dashboard/settings/ApiKeySettings.tsx +++ b/apps/web/components/dashboard/settings/ApiKeySettings.tsx @@ -1,4 +1,3 @@ -import { Separator } from "@/components/ui/separator"; import { Table, TableBody, @@ -15,13 +14,12 @@ import DeleteApiKey from "./DeleteApiKey"; export default async function ApiKeys() { const keys = await api.apiKeys.list(); return ( -
- API Keys - -
-
- -
+
+
+
API Keys
+ +
+
diff --git a/apps/web/components/dashboard/settings/ChangePassword.tsx b/apps/web/components/dashboard/settings/ChangePassword.tsx index 070caee8..aa27f223 100644 --- a/apps/web/components/dashboard/settings/ChangePassword.tsx +++ b/apps/web/components/dashboard/settings/ChangePassword.tsx @@ -11,7 +11,6 @@ import { FormMessage, } from "@/components/ui/form"; import { Input } from "@/components/ui/input"; -import { Separator } from "@/components/ui/separator"; import { toast } from "@/components/ui/use-toast"; import { api } from "@/lib/trpc"; import { zodResolver } from "@hookform/resolvers/zod"; @@ -54,13 +53,14 @@ export function ChangePassword() { } return ( -
- Change Password - +
+
+ Change Password +
diff --git a/apps/web/components/dashboard/settings/DeleteApiKey.tsx b/apps/web/components/dashboard/settings/DeleteApiKey.tsx index cbbe8320..e2334c44 100644 --- a/apps/web/components/dashboard/settings/DeleteApiKey.tsx +++ b/apps/web/components/dashboard/settings/DeleteApiKey.tsx @@ -47,8 +47,8 @@ export default function DeleteApiKey({ )} > - ); diff --git a/apps/web/components/dashboard/settings/UserDetails.tsx b/apps/web/components/dashboard/settings/UserDetails.tsx new file mode 100644 index 00000000..3915782b --- /dev/null +++ b/apps/web/components/dashboard/settings/UserDetails.tsx @@ -0,0 +1,33 @@ +import { Input } from "@/components/ui/input"; +import { api } from "@/server/api/client"; + +export default async function UserDetails() { + const whoami = await api.users.whoami(); + + const details = [ + { + label: "Name", + value: whoami.name ?? undefined, + }, + { + label: "Email", + value: whoami.email ?? undefined, + }, + ]; + + return ( +
+
+ Basic Details +
+
+ {details.map(({ label, value }) => ( +
+
{label}
+ +
+ ))} +
+
+ ); +} diff --git a/apps/web/components/dashboard/sidebar/Sidebar.tsx b/apps/web/components/dashboard/sidebar/Sidebar.tsx index 08ad2936..84a10d2d 100644 --- a/apps/web/components/dashboard/sidebar/Sidebar.tsx +++ b/apps/web/components/dashboard/sidebar/Sidebar.tsx @@ -20,6 +20,51 @@ export default async function Sidebar() { const lists = await api.lists.list(); + const searchItem = serverConfig.meilisearch + ? [ + { + name: "Search", + icon: , + path: "/dashboard/search", + }, + ] + : []; + + const adminItem = + session.user.role == "admin" + ? [ + { + name: "Admin", + icon: , + path: "/dashboard/admin", + }, + ] + : []; + + const menu: { + name: string; + icon: JSX.Element; + path: string; + }[] = [ + { + name: "Home", + icon: , + path: "/dashboard/bookmarks", + }, + ...searchItem, + { + name: "Tags", + icon: , + path: "/dashboard/tags", + }, + { + name: "Settings", + icon: , + path: "/dashboard/settings", + }, + ...adminItem, + ]; + return (