diff --git a/packages/app/components/profile/deleteAccount/DeleteAccount.story.tsx b/packages/app/components/profile/deleteAccount/DeleteAccount.story.tsx new file mode 100644 index 0000000..e5b6cb4 --- /dev/null +++ b/packages/app/components/profile/deleteAccount/DeleteAccount.story.tsx @@ -0,0 +1,19 @@ +import React from 'react'; +import { storiesOf } from '@storybook/react'; +import { action } from '@storybook/addon-actions'; + +import { ProfileLayout } from 'app/components/profile/Profile.story'; + +import DeleteAccount from './DeleteAccount'; + +storiesOf('Components/Profile', module).add('DeleteAccount', () => ( + + { + action('onSubmit')(); + + return Promise.resolve(); + }} + /> + +)); diff --git a/packages/app/components/profile/deleteAccount/DeleteAccount.tsx b/packages/app/components/profile/deleteAccount/DeleteAccount.tsx new file mode 100644 index 0000000..998c11c --- /dev/null +++ b/packages/app/components/profile/deleteAccount/DeleteAccount.tsx @@ -0,0 +1,163 @@ +import React, { ComponentType } from 'react'; +import { FormattedMessage as Message } from 'react-intl'; +import { Helmet } from 'react-helmet-async'; + +import { Button, Form } from 'app/components/ui/form'; + +import siteName from 'app/pages/root/siteName.intl'; +import appName from 'app/components/auth/appInfo/appName.intl'; + +import { BackButton } from '../ProfileForm'; +import styles from '../profileForm.scss'; +import ownStyles from './deleteAccount.scss'; + +interface Props { + onSubmit?: () => Promise; +} + +const DeleteAccount: ComponentType = ({ onSubmit }) => ( +
+
+ + +
+
+ + {(pageTitle) => ( +

+ + {pageTitle} +

+ )} +
+ +
+

+ +

+

+ +

+
+ +
+
+ +
+
+ +
+
+ {/* TODO: missing colon */} + +
+
+
    +
  • + +
  • +
  • + +
  • +
  • + +
  • +
  • + +
  • +
  • + +
  • +
+
+
+ +
+ +
+
+ {/* TODO: missing colon */} + +
+
+
    +
  • + +
  • +
  • + +
  • +
  • + +
  • +
+
+
+ +
+ +
+
Chrly:
+
+
    +
  • + +
  • +
+
+
+ +
+ +
+
+ +
+
+ +
+
+ {/* TODO: missing colon */} + +
+
+
    +
  • + +
  • +
  • + +
  • +
+
+
+ +
+

+ +

+
+
+ + +
+
+ +); + +export default DeleteAccount; diff --git a/packages/app/components/profile/deleteAccount/deleteAccount.scss b/packages/app/components/profile/deleteAccount/deleteAccount.scss new file mode 100644 index 0000000..06d9266 --- /dev/null +++ b/packages/app/components/profile/deleteAccount/deleteAccount.scss @@ -0,0 +1,35 @@ +@import '~app/components/ui/fonts.scss'; + +.removableDataRow { + composes: formRow from '~app/components/profile/profileForm.scss'; + + display: flex; +} + +.serviceName { + font-family: $font-family-title; + width: 50%; + color: #444; +} + +.serviceContents { + width: 50%; + font-size: 12px; + color: #666; + + li { + position: relative; + padding-left: 11px; + + &:before { + content: '—'; + position: absolute; + left: 0; + top: 2px; + } + + span { + line-height: 16px; + } + } +} diff --git a/packages/app/components/profile/deleteAccount/index.ts b/packages/app/components/profile/deleteAccount/index.ts new file mode 100644 index 0000000..cf774d4 --- /dev/null +++ b/packages/app/components/profile/deleteAccount/index.ts @@ -0,0 +1 @@ +export { default } from './DeleteAccount'; diff --git a/packages/app/components/profile/multiFactorAuth/MfaStatus.tsx b/packages/app/components/profile/multiFactorAuth/MfaStatus.tsx index 8935d9e..b12ec89 100644 --- a/packages/app/components/profile/multiFactorAuth/MfaStatus.tsx +++ b/packages/app/components/profile/multiFactorAuth/MfaStatus.tsx @@ -18,7 +18,7 @@ const MfaStatus: ComponentType = ({ onProceed }) => (
-

+

{ + const context = useContext(ProfileContext); + const dispatch = useReduxDispatch(); + const { current: form } = useRef(new FormModel()); + const onSubmit = useCallback( + () => + context + .onSubmit({ + form, + // TODO: rework + sendData: () => changePassword(context.userId, form.serialize()), + }) + .then(() => { + dispatch( + updateUser({ + passwordChangedAt: Date.now() / 1000, + }), + ); + context.goToProfile(); + }), + [context], + ); + + return ; +}; + +export default DeleteAccountPage; diff --git a/packages/app/pages/profile/ProfileController.tsx b/packages/app/pages/profile/ProfileController.tsx index 7ca1f40..332b6a3 100644 --- a/packages/app/pages/profile/ProfileController.tsx +++ b/packages/app/pages/profile/ProfileController.tsx @@ -20,6 +20,7 @@ import ChangePasswordPage from 'app/pages/profile/ChangePasswordPage'; import ChangeUsernamePage from 'app/pages/profile/ChangeUsernamePage'; import ChangeEmailPage from 'app/pages/profile/ChangeEmailPage'; import MultiFactorAuthPage from 'app/pages/profile/MultiFactorAuthPage'; +import DeleteAccountPage from 'app/pages/profile/DeleteAccountPage'; interface Props { userId: number; @@ -50,6 +51,7 @@ const ProfileController: ComponentType = ({ userId, onSubmit, refreshUser +