Files
twenty/packages/twenty-front/src/modules/settings/profile/components/ChangePassword.tsx
T
Abdullah d1cbd709bd Extract typography components from twenty-front to twenty-ui. (#5466)
Removed the following components from twenty-front and moved them to
twenty-ui.
- H1Title.
- H2Title.
- H3Title.

Moving components in smaller chunks to ease the process of resolving
conflicts.

<img width="1255" alt="image"
src="https://github.com/twentyhq/twenty/assets/125115953/a3953659-5dfd-4d03-a6de-50b064129d55">

Co-authored-by: Charles Bochet <charles@twenty.com>
2024-05-22 10:52:35 +02:00

60 lines
1.6 KiB
TypeScript

import { useRecoilValue } from 'recoil';
import { H2Title } from 'twenty-ui';
import { currentUserState } from '@/auth/states/currentUserState';
import { useSnackBar } from '@/ui/feedback/snack-bar-manager/hooks/useSnackBar';
import { Button } from '@/ui/input/button/components/Button';
import { useEmailPasswordResetLinkMutation } from '~/generated/graphql';
export const ChangePassword = () => {
const { enqueueSnackBar } = useSnackBar();
const currentUser = useRecoilValue(currentUserState);
const [emailPasswordResetLink] = useEmailPasswordResetLinkMutation();
const handlePasswordResetClick = async () => {
if (!currentUser?.email) {
enqueueSnackBar('Invalid email', {
variant: 'error',
});
return;
}
try {
const { data } = await emailPasswordResetLink({
variables: {
email: currentUser.email,
},
});
if (data?.emailPasswordResetLink?.success === true) {
enqueueSnackBar('Password reset link has been sent to the email', {
variant: 'success',
});
} else {
enqueueSnackBar('There was some issue', {
variant: 'error',
});
}
} catch (error) {
enqueueSnackBar((error as Error).message, {
variant: 'error',
});
}
};
return (
<>
<H2Title
title="Change Password"
description="Receive an email containing password update link"
/>
<Button
onClick={handlePasswordResetClick}
variant="secondary"
title="Change Password"
/>
</>
);
};