Skip to content

Commit

Permalink
Reset password disable button and add loading spinner
Browse files Browse the repository at this point in the history
  • Loading branch information
Tudor-Barsan committed Aug 26, 2024
1 parent 40ca014 commit 9d0503c
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 3 deletions.
14 changes: 13 additions & 1 deletion frontend/src/components/auth/ForgotPassword.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
FormLabel,
Input,
Link,
Spinner,
Text,
VStack,
useToast,
Expand Down Expand Up @@ -152,6 +153,7 @@ const ForgotPassword = () => {
bgColor="#272D77"
_hover={{ bgColor: "#272D77" }}
borderRadius="6px"
disabled={forgotPasswordLoading}
onClick={() => {
if (isValidEmail(email)) {
setEmailError(false);
Expand All @@ -161,7 +163,17 @@ const ForgotPassword = () => {
}
}}
>
{forgotPasswordLoading ? "Loading..." : "Reset"}
{forgotPasswordLoading ? (
<Spinner
thickness="4px"
speed="0.65s"
emptyColor="gray.200"
color="primary.green"
size="lg"
/>
) : (
"Reset"
)}
</Button>
{!emailError && (
<Text
Expand Down
18 changes: 16 additions & 2 deletions frontend/src/pages/Settings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,10 @@ const Settings = (): React.ReactElement => {
const [createOnsiteContact] = useMutation(CREATE_ONSITE_CONTACT);
const [updateOnsiteContact] = useMutation(UPDATE_ONSITE_CONTACT);
const [deleteOnsiteContact] = useMutation(DELETE_ONSITE_CONTACT);
const [forgotPassword] = useMutation(FORGOT_PASSWORD);
const [
forgotPassword,
{ loading: forgotPasswordLoading },
] = useMutation(FORGOT_PASSWORD);

// OnsiteContact query

Expand Down Expand Up @@ -336,9 +339,20 @@ const Settings = (): React.ReactElement => {
borderColor="primary.green"
borderRadius="6px"
_hover={{ color: "text.white", bgColor: "primary.green" }}
disabled={forgotPasswordLoading}
onClick={onClickResetPassword}
>
Reset Password
{forgotPasswordLoading ? (
<Spinner
thickness="4px"
speed="0.65s"
emptyColor="gray.200"
color="primary.green"
size="lg"
/>
) : (
"Reset Password"
)}
</Button>
</HStack>
</Flex>
Expand Down

0 comments on commit 9d0503c

Please sign in to comment.