From dbdc63238191b752e1e1bcf9b0b26369100cc5f6 Mon Sep 17 00:00:00 2001 From: Gao Sun Date: Thu, 7 Sep 2023 17:35:27 +0800 Subject: [PATCH] refactor(ui): align hook style --- packages/ui/src/hooks/use-password-action.ts | 6 ++---- packages/ui/src/pages/Continue/SetPassword/index.tsx | 2 +- packages/ui/src/pages/RegisterPassword/index.tsx | 2 +- packages/ui/src/pages/ResetPassword/index.tsx | 2 +- 4 files changed, 5 insertions(+), 7 deletions(-) diff --git a/packages/ui/src/hooks/use-password-action.ts b/packages/ui/src/hooks/use-password-action.ts index 9432308a6..e6275d055 100644 --- a/packages/ui/src/hooks/use-password-action.ts +++ b/packages/ui/src/hooks/use-password-action.ts @@ -26,7 +26,7 @@ const usePasswordAction = ({ errorHandlers, setErrorMessage, successHandler, -}: UsePasswordApiInit) => { +}: UsePasswordApiInit): [PasswordAction] => { const asyncAction = useApi(api); const handleError = useErrorHandler(); const { getErrorMessage, getErrorMessageFromBody } = usePasswordErrorMessage(); @@ -72,9 +72,7 @@ const usePasswordAction = ({ ] ); - return { - action, - }; + return [action]; }; export default usePasswordAction; diff --git a/packages/ui/src/pages/Continue/SetPassword/index.tsx b/packages/ui/src/pages/Continue/SetPassword/index.tsx index c0a79ebe3..a6131dd89 100644 --- a/packages/ui/src/pages/Continue/SetPassword/index.tsx +++ b/packages/ui/src/pages/Continue/SetPassword/index.tsx @@ -35,7 +35,7 @@ const SetPassword = () => { window.location.replace(result.redirectTo); } }, []); - const { action } = usePasswordAction({ + const [action] = usePasswordAction({ api: async (password) => addProfile({ password }), setErrorMessage, errorHandlers, diff --git a/packages/ui/src/pages/RegisterPassword/index.tsx b/packages/ui/src/pages/RegisterPassword/index.tsx index 9db7f7a84..1adf665d9 100644 --- a/packages/ui/src/pages/RegisterPassword/index.tsx +++ b/packages/ui/src/pages/RegisterPassword/index.tsx @@ -37,7 +37,7 @@ const RegisterPassword = () => { } }, []); - const { action } = usePasswordAction({ + const [action] = usePasswordAction({ api: setUserPassword, setErrorMessage, errorHandlers, diff --git a/packages/ui/src/pages/ResetPassword/index.tsx b/packages/ui/src/pages/ResetPassword/index.tsx index b55faea9a..68b691501 100644 --- a/packages/ui/src/pages/ResetPassword/index.tsx +++ b/packages/ui/src/pages/ResetPassword/index.tsx @@ -42,7 +42,7 @@ const ResetPassword = () => { [navigate, setToast, t] ); - const { action } = usePasswordAction({ + const [action] = usePasswordAction({ api: setUserPassword, setErrorMessage, errorHandlers,