-
-
Notifications
You must be signed in to change notification settings - Fork 72
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
19 changed files
with
191 additions
and
197 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
2 changes: 1 addition & 1 deletion
2
src/features/settings/settingsManager.ts → src/features/account/accountManager.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
import Head from 'next/head'; | ||
import { TrashIcon } from '@heroicons/react/outline'; | ||
import withAnimation from 'shared/HOC/withAnimation'; | ||
import Header from 'shared/components/Header/Header'; | ||
import withProtectedRoute from 'shared/HOC/withProtectedRoute'; | ||
|
||
import withFeatureToggles from 'shared/HOC/withFeatureToggles'; | ||
import useTranslation from 'next-translate/useTranslation'; | ||
import { useAccountManager } from 'features/account/accountManager'; | ||
import Button, { ButtonVariant } from 'shared/components/Button/Button'; | ||
import StyledDialog from 'shared/components/StyledDialog/StyledDialog'; | ||
import Avatar from 'shared/components/Avatar/Avatar'; | ||
import { formatDateDistance } from 'shared/utilities/convertTime'; | ||
|
||
function AccountPage() { | ||
const { t } = useTranslation('account'); | ||
|
||
const { | ||
user, | ||
isOpen, | ||
openDeleteModal, | ||
closeDeleteModal, | ||
handleOnAccountDelete, | ||
isRemoving, | ||
} = useAccountManager(); | ||
|
||
return ( | ||
<> | ||
<Head> | ||
<title>{t('title')}</title> | ||
<meta name="description" content={t('content')} /> | ||
</Head> | ||
|
||
<Header>Your account</Header> | ||
|
||
{user ? ( | ||
<div className="mt-4 flex w-full items-center justify-center gap-12 text-left"> | ||
<Avatar size={160} src={user.image} classNames="border" /> | ||
|
||
<div className="mb-4"> | ||
<h2 className="mb-2 text-2xl">{user?.name}</h2> | ||
<p>{user?.email}</p> | ||
<p>Account created: {formatDateDistance(user.createdAt)}</p> | ||
</div> | ||
</div> | ||
) : ( | ||
<></> | ||
)} | ||
|
||
{process.env.NEXT_PUBLIC_REMOVE_ACCOUNT && ( | ||
<> | ||
<div className="flex flex-col items-center justify-center space-y-2"> | ||
<div className="flex w-full md:ml-2 md:w-auto"> | ||
<Button | ||
variant={ButtonVariant.DANGER} | ||
title={t('deleteAccountButtonTitle')} | ||
className="ml-2 mt-2 w-full justify-center px-3 sm:mt-0 md:w-auto" | ||
onClick={openDeleteModal} | ||
icon={<TrashIcon className="h-5 w-5" />} | ||
> | ||
{t('deleteAccountButton')} | ||
</Button> | ||
</div> | ||
</div> | ||
<StyledDialog | ||
isOpen={isOpen} | ||
onClose={closeDeleteModal} | ||
title={t('dialogTitle')} | ||
content={ | ||
<> | ||
<div className="mt-2"> | ||
<p className="text-sm text-red-500"> | ||
{t('dialogContentFirst')} | ||
<span className="font-bold"> | ||
{t('dialogContentSecond')} | ||
</span>{' '} | ||
{t('dialogContentThird')} | ||
</p> | ||
</div> | ||
<div className="mt-6 flex justify-between space-x-3"> | ||
<Button | ||
variant={ButtonVariant.SECONDARY} | ||
onClick={closeDeleteModal} | ||
className="uppercase" | ||
disabled={isRemoving} | ||
> | ||
{t('buttonCancle')} | ||
</Button> | ||
<Button | ||
variant={ButtonVariant.DANGER} | ||
onClick={handleOnAccountDelete} | ||
icon={<TrashIcon className="h-5 w-5" />} | ||
className="uppercase" | ||
isLoading={isRemoving} | ||
> | ||
{t('buttonConfirm')} | ||
</Button> | ||
</div> | ||
</> | ||
} | ||
/> | ||
</> | ||
)} | ||
</> | ||
); | ||
} | ||
|
||
export default withFeatureToggles( | ||
withProtectedRoute(withAnimation(AccountPage)), | ||
[process.env.NEXT_PUBLIC_PROFILE_SETTINGS] | ||
); |
Oops, something went wrong.
3f364db
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
formslab – ./
formslab-ryczko.vercel.app
formslab-git-main-ryczko.vercel.app
formslab.vercel.app