Skip to content

The open alternative to Salesforce, designed for AI.

1.0 KB
Raw Blame
import { useHandleResetPassword } from '@/auth/sign-in-up/hooks/useHandleResetPassword';
import { currentUserState } from '@/auth/states/currentUserState';
import { useLingui } from '@lingui/react/macro';
import { Section } from 'twenty-ui/components/layout';
import { Button } from 'twenty-ui/primitives/input';
import { useAtomStateValue } from '@/ui/utilities/state/jotai/hooks/useAtomStateValue';

export const SetOrChangePassword = () => {
  const { t } = useLingui();
  const currentUser = useAtomStateValue(currentUserState);

  const { handleResetPassword } = useHandleResetPassword();

  const hasPassword = currentUser?.hasPassword ?? false;
  const heading = hasPassword ? t`Change Password` : t`Set Password`;
  const description = hasPassword
    ? t`Receive an email containing password update link`
    : t`Receive an email containing password set link`;

  return (
    <>
      <Section.Header title={heading} description={description} />
      <Button onClick={handleResetPassword()} variant="outline">
        {heading}
      </Button>
    </>
  );
};