From f8449fa6fb7eaaf8a3de6717313f0eb015233d53 Mon Sep 17 00:00:00 2001 From: Fingertips Date: Thu, 26 Sep 2024 12:33:00 +0800 Subject: [PATCH] Add change password API route; fix tooltip dropshadow and dynamic colors - Implemented a new API route for changing the user's password. - Consumed the change password API in the client, allowing users to update their passwords. - Fixed the drop-shadow issue on tooltips, ensuring proper shadow rendering. - Made both tooltip and page switcher colors dynamic based on the current theme or state. - Created a `useResize` hook to dynamically change the size of the icon button on small screens. - Integrated the `useResize` hook into the icon button component for responsive design. - Improved overall UI consistency and user experience through these updates. --- client/src/App.tsx | 21 ++-- client/src/components/hint.tsx | 3 +- client/src/components/icon-button.tsx | 12 ++- client/src/components/page-switcher.tsx | 63 ++++++++++++ client/src/components/switch-auth.tsx | 34 ------- client/src/constants/keys.ts | 1 + client/src/constants/routes.ts | 1 + client/src/index.css | 16 ++++ client/src/lib/DTO/change-dto.ts | 5 + client/src/lib/hooks/use-resize.tsx | 29 ++++++ client/src/lib/services/auth-service.ts | 23 +++++ .../_components/change-password-back.tsx | 11 +++ .../_components/change-password-form.tsx | 96 +++++++++++++++++++ client/src/pages/change-password/page.tsx | 18 ++++ .../_components/forgot-password-back.tsx | 4 +- .../_components/reset-password-back.tsx | 4 +- .../_components/reset-password-form.tsx | 9 +- .../_components/content/change-password.tsx | 19 ++++ .../pages/root/_components/content/index.tsx | 5 +- .../root/_components/content/info-pair.tsx | 6 +- .../pages/root/_components/footer/index.tsx | 6 +- .../sign-in/_components/no-account-yet.tsx | 4 +- .../_components/already-have-account.tsx | 4 +- constants/routes.go | 1 + controllers/auth_controller.go | 42 +++++++- routes/auth_route.go | 1 + 26 files changed, 372 insertions(+), 66 deletions(-) create mode 100644 client/src/components/page-switcher.tsx delete mode 100644 client/src/components/switch-auth.tsx create mode 100644 client/src/lib/DTO/change-dto.ts create mode 100644 client/src/lib/hooks/use-resize.tsx create mode 100644 client/src/pages/change-password/_components/change-password-back.tsx create mode 100644 client/src/pages/change-password/_components/change-password-form.tsx create mode 100644 client/src/pages/change-password/page.tsx create mode 100644 client/src/pages/root/_components/content/change-password.tsx diff --git a/client/src/App.tsx b/client/src/App.tsx index 30811c4..0282717 100644 --- a/client/src/App.tsx +++ b/client/src/App.tsx @@ -2,6 +2,7 @@ import { Route, Routes } from "react-router-dom"; import { ForgotPasswordPage } from "@/pages/forgot-password/page"; import { ResetPasswordPage } from "@/pages/reset-password/page"; +import { ChangePasswordPage } from "@/pages/change-password/page"; import VerifyEmailPage from "@/pages/verify-email/page"; import PrivateGuard from "@/guards/private-guard"; import { AppRoutes } from "@/constants/routes"; @@ -16,20 +17,24 @@ function App() { }> } /> + } + /> }> } /> } /> } /> + } + /> + } + /> - } - /> - } - /> ); diff --git a/client/src/components/hint.tsx b/client/src/components/hint.tsx index 0cc62c6..b40da3e 100644 --- a/client/src/components/hint.tsx +++ b/client/src/components/hint.tsx @@ -22,8 +22,9 @@ const Hint = ({ id, content, isSecondary, isAccent }: HintProps) => { & React.RefAttributes >; - size?: number; onClick: () => void; disabled?: boolean; loading?: boolean; @@ -12,14 +13,19 @@ interface IconButtonProps { const IconButton = ({ icon: Icon, - size = 22, onClick, disabled, loading, }: IconButtonProps) => { + const { width } = useResize(); + + const lg = width > 1024; + + const size = lg ? 22 : 16; + return (