From 1412f1d9828a379ef5a99533fc0d273f0f960f3e Mon Sep 17 00:00:00 2001 From: Philipinho <16838612+Philipinho@users.noreply.github.com> Date: Thu, 4 Apr 2024 22:19:15 +0100 Subject: [PATCH] client: updates * work on groups ui * move settings to its own page * other fixes and refactoring --- apps/client/src/App.tsx | 38 +++-- .../layouts/components/breadcrumb.tsx | 2 +- .../components/layouts/dashboard/aside.tsx | 42 ++++++ .../layouts/dashboard/aside/aside.tsx | 39 ----- .../dashboard-layout.tsx} | 7 +- .../components/layouts/dashboard/header.tsx | 45 +++--- .../components/layouts/dashboard/shell.tsx | 65 +++++---- .../layouts/settings/settings-layout.tsx | 13 ++ .../layouts/settings/settings-shell.tsx | 36 +++++ .../layouts/settings/settings-sidebar.tsx | 108 ++++++++++++++ .../layouts/settings/settings-title.tsx | 13 ++ .../layouts/settings/settings.module.css | 71 ++++++++++ apps/client/src/components/navbar/navbar.tsx | 17 +-- apps/client/src/components/ui/user-avatar.tsx | 35 ++--- .../features/auth/components/auth.module.css | 6 + .../features/auth/components/login-form.tsx | 23 +-- .../features/auth/components/sign-up-form.tsx | 2 +- .../comment/components/comment-dialog.tsx | 2 +- .../components/add-group-member-modal.tsx | 45 ++++++ .../group/components/create-group-form.tsx | 82 +++++++++++ .../group/components/create-group-modal.tsx | 18 +++ .../group/components/edit-group-form.tsx | 88 ++++++++++++ .../group/components/edit-group-modal.tsx | 21 +++ .../group/components/group-action-menu.tsx | 79 +++++++++++ .../group/components/group-details.tsx | 33 +++++ .../features/group/components/group-list.tsx | 70 +++++++++ .../group/components/group-members.tsx | 102 +++++++++++++ .../group/components/multi-user-select.tsx | 73 ++++++++++ .../src/features/group/queries/group-query.ts | 134 ++++++++++++++++++ .../features/group/services/group-service.ts | 46 ++++++ .../src/features/group/types/group.types.ts | 12 ++ .../features/home/components/home-tabs.tsx | 2 +- .../page-history/components/history-item.tsx | 2 +- .../features/page/services/page-service.ts | 2 +- .../src/features/page/tree/page-tree.tsx | 118 ++++++++------- .../modal/atoms/settings-modal-atom.ts | 3 - .../features/settings/modal/modal.module.css | 76 ---------- .../settings/modal/settings-modal.tsx | 30 ---- .../settings/modal/settings-sidebar.tsx | 101 ------------- .../features/user/atoms/current-user-atom.ts | 4 +- .../user/components/account-avatar.tsx | 60 ++++++++ .../user/components/account-name-form.tsx | 76 ++++++++++ .../features/user/components/change-email.tsx | 94 ++++++++++++ .../user/components/change-password.tsx | 84 +++++++++++ .../features/user/hooks/use-current-user.ts | 4 +- .../features/user/services/user-service.ts | 13 +- .../src/features/user/types/user.types.ts | 6 +- .../components/workspace-invite-form.tsx | 2 +- .../components/workspace-invite-modal.tsx | 24 ++-- .../components/workspace-invite-section.tsx | 2 +- .../components/workspace-members-table.tsx | 2 +- .../components/workspace-name-form.tsx | 6 +- .../workspace/queries/workspace-query.ts | 10 ++ .../workspace/services/workspace-service.ts | 18 +-- .../workspace/types/workspace.types.ts | 2 - apps/client/src/lib/api-client.ts | 15 +- apps/client/src/lib/types.ts | 5 + apps/client/src/main.tsx | 2 +- .../settings/account/account-settings.tsx | 26 ++++ .../src/pages/settings/group/group-info.tsx | 13 ++ .../src/pages/settings/group/groups.tsx | 18 +++ .../settings/workspace/workspace-members.tsx | 26 ++++ .../settings/workspace/workspace-settings.tsx | 11 ++ apps/client/src/theme.ts | 20 ++- 64 files changed, 1770 insertions(+), 474 deletions(-) create mode 100644 apps/client/src/components/layouts/dashboard/aside.tsx delete mode 100644 apps/client/src/components/layouts/dashboard/aside/aside.tsx rename apps/client/src/components/layouts/{layout.tsx => dashboard/dashboard-layout.tsx} (51%) create mode 100644 apps/client/src/components/layouts/settings/settings-layout.tsx create mode 100644 apps/client/src/components/layouts/settings/settings-shell.tsx create mode 100644 apps/client/src/components/layouts/settings/settings-sidebar.tsx create mode 100644 apps/client/src/components/layouts/settings/settings-title.tsx create mode 100644 apps/client/src/components/layouts/settings/settings.module.css create mode 100644 apps/client/src/features/auth/components/auth.module.css create mode 100644 apps/client/src/features/group/components/add-group-member-modal.tsx create mode 100644 apps/client/src/features/group/components/create-group-form.tsx create mode 100644 apps/client/src/features/group/components/create-group-modal.tsx create mode 100644 apps/client/src/features/group/components/edit-group-form.tsx create mode 100644 apps/client/src/features/group/components/edit-group-modal.tsx create mode 100644 apps/client/src/features/group/components/group-action-menu.tsx create mode 100644 apps/client/src/features/group/components/group-details.tsx create mode 100644 apps/client/src/features/group/components/group-list.tsx create mode 100644 apps/client/src/features/group/components/group-members.tsx create mode 100644 apps/client/src/features/group/components/multi-user-select.tsx create mode 100644 apps/client/src/features/group/queries/group-query.ts create mode 100644 apps/client/src/features/group/services/group-service.ts create mode 100644 apps/client/src/features/group/types/group.types.ts delete mode 100644 apps/client/src/features/settings/modal/atoms/settings-modal-atom.ts delete mode 100644 apps/client/src/features/settings/modal/modal.module.css delete mode 100644 apps/client/src/features/settings/modal/settings-modal.tsx delete mode 100644 apps/client/src/features/settings/modal/settings-sidebar.tsx create mode 100644 apps/client/src/features/user/components/account-avatar.tsx create mode 100644 apps/client/src/features/user/components/account-name-form.tsx create mode 100644 apps/client/src/features/user/components/change-email.tsx create mode 100644 apps/client/src/features/user/components/change-password.tsx create mode 100644 apps/client/src/features/workspace/queries/workspace-query.ts create mode 100644 apps/client/src/lib/types.ts create mode 100644 apps/client/src/pages/settings/account/account-settings.tsx create mode 100644 apps/client/src/pages/settings/group/group-info.tsx create mode 100644 apps/client/src/pages/settings/group/groups.tsx create mode 100644 apps/client/src/pages/settings/workspace/workspace-members.tsx create mode 100644 apps/client/src/pages/settings/workspace/workspace-settings.tsx diff --git a/apps/client/src/App.tsx b/apps/client/src/App.tsx index 13d342e7..339358c3 100644 --- a/apps/client/src/App.tsx +++ b/apps/client/src/App.tsx @@ -1,25 +1,39 @@ -import { Route, Routes } from 'react-router-dom'; -import { Welcome } from '@/pages/welcome'; -import SignUpPage from '@/pages/auth/signup'; -import LoginPage from '@/pages/auth/login'; -import DashboardLayout from '@/components/layouts/layout'; -import Home from '@/pages/dashboard/home'; -import Page from '@/pages/page/page'; +import { Route, Routes } from "react-router-dom"; +import { Welcome } from "@/pages/welcome"; +import SignUpPage from "@/pages/auth/signup"; +import LoginPage from "@/pages/auth/login"; +import DashboardLayout from "@/components/layouts/dashboard/dashboard-layout.tsx"; +import Home from "@/pages/dashboard/home"; +import Page from "@/pages/page/page"; +import AccountSettings from "@/pages/settings/account/account-settings"; +import WorkspaceMembers from "@/pages/settings/workspace/workspace-members"; +import SettingsLayout from "@/components/layouts/settings/settings-layout.tsx"; +import WorkspaceSettings from "@/pages/settings/workspace/workspace-settings"; +import Groups from "@/pages/settings/group/groups"; +import GroupInfo from "./pages/settings/group/group-info"; export default function App() { - return ( <> } /> - } /> - } /> + } /> + } /> }> - } /> - } /> + } /> + } /> + }> + } /> + } /> + } /> + } /> + } /> + } /> + } /> + ); diff --git a/apps/client/src/components/layouts/components/breadcrumb.tsx b/apps/client/src/components/layouts/components/breadcrumb.tsx index aeb6d308..122e736d 100644 --- a/apps/client/src/components/layouts/components/breadcrumb.tsx +++ b/apps/client/src/components/layouts/components/breadcrumb.tsx @@ -66,7 +66,7 @@ export default function Breadcrumb() { , - + diff --git a/apps/client/src/components/layouts/dashboard/aside.tsx b/apps/client/src/components/layouts/dashboard/aside.tsx new file mode 100644 index 00000000..8049c3f4 --- /dev/null +++ b/apps/client/src/components/layouts/dashboard/aside.tsx @@ -0,0 +1,42 @@ +import { Box, ScrollArea, Text } from "@mantine/core"; +import CommentList from "@/features/comment/components/comment-list.tsx"; +import { useAtom } from "jotai"; +import { asideStateAtom } from "@/components/navbar/atoms/sidebar-atom.ts"; +import React from "react"; + +export default function Aside() { + const [{ tab }] = useAtom(asideStateAtom); + + let title; + let component; + + switch (tab) { + case "comments": + component = ; + title = "Comments"; + break; + default: + component = null; + title = null; + } + + return ( + + {component && ( + <> + + {title} + + + +
{component}
+
+ + )} +
+ ); +} diff --git a/apps/client/src/components/layouts/dashboard/aside/aside.tsx b/apps/client/src/components/layouts/dashboard/aside/aside.tsx deleted file mode 100644 index 007ff854..00000000 --- a/apps/client/src/components/layouts/dashboard/aside/aside.tsx +++ /dev/null @@ -1,39 +0,0 @@ -import { Box, ScrollArea, Text } from '@mantine/core'; -import CommentList from '@/features/comment/components/comment-list'; -import { useAtom } from 'jotai'; -import { asideStateAtom } from '@/components/navbar/atoms/sidebar-atom'; -import React from 'react'; - -export default function Aside() { - const [{ tab }] = useAtom(asideStateAtom); - - let title; - let component; - - switch (tab) { - case 'comments': - component = ; - title = 'Comments'; - break; - default: - component = null; - title = null; - } - - - return ( - - {component && ( - <> - {title} - - -
- {component} -
-
- - )} -
- ); -} diff --git a/apps/client/src/components/layouts/layout.tsx b/apps/client/src/components/layouts/dashboard/dashboard-layout.tsx similarity index 51% rename from apps/client/src/components/layouts/layout.tsx rename to apps/client/src/components/layouts/dashboard/dashboard-layout.tsx index ed953ea6..7b2e51d2 100644 --- a/apps/client/src/components/layouts/layout.tsx +++ b/apps/client/src/components/layouts/dashboard/dashboard-layout.tsx @@ -1,9 +1,8 @@ -import { UserProvider } from '@/features/user/user-provider'; -import Shell from './shell'; -import { Outlet } from 'react-router-dom'; +import { UserProvider } from "@/features/user/user-provider.tsx"; +import Shell from "./shell.tsx"; +import { Outlet } from "react-router-dom"; export default function DashboardLayout() { - return ( diff --git a/apps/client/src/components/layouts/dashboard/header.tsx b/apps/client/src/components/layouts/dashboard/header.tsx index e05cc82c..bdf4012d 100644 --- a/apps/client/src/components/layouts/dashboard/header.tsx +++ b/apps/client/src/components/layouts/dashboard/header.tsx @@ -1,8 +1,4 @@ -import { - ActionIcon, - Menu, - Button, -} from '@mantine/core'; +import { ActionIcon, Menu, Button } from "@mantine/core"; import { IconDots, IconFileInfo, @@ -12,22 +8,26 @@ import { IconShare, IconTrash, IconMessage, -} from '@tabler/icons-react'; -import React from 'react'; -import useToggleAside from '@/hooks/use-toggle-aside'; -import { useAtom } from 'jotai'; -import { historyAtoms } from '@/features/page-history/atoms/history-atoms'; +} from "@tabler/icons-react"; +import React from "react"; +import useToggleAside from "@/hooks/use-toggle-aside.tsx"; +import { useAtom } from "jotai"; +import { historyAtoms } from "@/features/page-history/atoms/history-atoms.ts"; export default function Header() { const toggleAside = useToggleAside(); return ( <> - - toggleAside('comments')}> + toggleAside("comments")} + > @@ -53,38 +53,33 @@ function PageActionMenu() { arrowPosition="center" > - + - }> + }> Page info - } - > + }> Copy link - }> + }> Share } - onClick={openHistoryModal}> + onClick={openHistoryModal} + > Page history - }> + }> Lock - }> + }> Delete diff --git a/apps/client/src/components/layouts/dashboard/shell.tsx b/apps/client/src/components/layouts/dashboard/shell.tsx index 2a38862e..242925c5 100644 --- a/apps/client/src/components/layouts/dashboard/shell.tsx +++ b/apps/client/src/components/layouts/dashboard/shell.tsx @@ -1,22 +1,25 @@ -import { asideStateAtom, desktopSidebarAtom } from '@/components/navbar/atoms/sidebar-atom'; -import { useToggleSidebar } from '@/components/navbar/hooks/use-toggle-sidebar'; -import { Navbar } from '@/components/navbar/navbar'; -import { AppShell, Burger, Group } from '@mantine/core'; -import { useDisclosure } from '@mantine/hooks'; -import { useAtom } from 'jotai'; -import classes from './shell.module.css'; -import Header from '@/components/layouts/header'; -import Breadcrumb from '@/components/layouts/components/breadcrumb'; -import Aside from '@/components/aside/aside'; -import { useMatchPath } from '@/hooks/use-match-path'; -import React from 'react'; +import { + asideStateAtom, + desktopSidebarAtom, +} from "@/components/navbar/atoms/sidebar-atom.ts"; +import { useToggleSidebar } from "@/components/navbar/hooks/use-toggle-sidebar.ts"; +import { Navbar } from "@/components/navbar/navbar.tsx"; +import { AppShell, Burger, Group } from "@mantine/core"; +import { useDisclosure } from "@mantine/hooks"; +import { useAtom } from "jotai"; +import classes from "./shell.module.css"; +import Header from "@/components/layouts/dashboard/header.tsx"; +import Breadcrumb from "@/components/layouts/components/breadcrumb.tsx"; +import Aside from "@/components/layouts/dashboard/aside.tsx"; +import { useMatchPath } from "@/hooks/use-match-path.tsx"; +import React from "react"; export default function Shell({ children }: { children: React.ReactNode }) { const [mobileOpened, { toggle: toggleMobile }] = useDisclosure(); const [desktopOpened] = useAtom(desktopSidebarAtom); const toggleDesktop = useToggleSidebar(desktopSidebarAtom); const matchPath = useMatchPath(); - const isPageRoute = matchPath('/p/:pageId'); + const isPageRoute = matchPath("/p/:pageId"); const [{ isAsideOpen }] = useAtom(asideStateAtom); return ( @@ -25,23 +28,25 @@ export default function Shell({ children }: { children: React.ReactNode }) { header={{ height: 45 }} navbar={{ width: 300, - breakpoint: 'sm', + breakpoint: "sm", collapsed: { mobile: !mobileOpened, desktop: !desktopOpened }, }} aside={{ width: 300, - breakpoint: 'md', - collapsed: { mobile: (!isAsideOpen), desktop: (!isAsideOpen) }, + breakpoint: "md", + collapsed: { mobile: !isAsideOpen, desktop: !isAsideOpen }, }} padding="md" > - - + - - + } - { - isPageRoute && + {isPageRoute && (
- } + )} - - - {children} - + {children} - { - isPageRoute && + {isPageRoute && (