|
| 1 | +import classnames from 'classnames'; |
| 2 | +import isNull from 'lodash-es/isNull'; |
| 3 | +import map from 'lodash-es/map'; |
| 4 | +import PropTypes from 'prop-types'; |
| 5 | +import React from 'react'; |
| 6 | +import {t} from 'i18next'; |
| 7 | + |
| 8 | +import { |
| 9 | + AccountMigration as AccountMigrationRecord, |
| 10 | + UserAccount as UserAccountRecord, |
| 11 | +} from '../records'; |
| 12 | + |
| 13 | +import Modal from './Modal'; |
| 14 | + |
| 15 | +export default function AccountMigration({currentUserAccount, migration}) { |
| 16 | + if (isNull(currentUserAccount) || isNull(migration)) { |
| 17 | + return null; |
| 18 | + } |
| 19 | + |
| 20 | + return ( |
| 21 | + <Modal> |
| 22 | + <div className="account-migration"> |
| 23 | + <h1 className="account-migration__header"> |
| 24 | + {t('account-migration.header')} |
| 25 | + </h1> |
| 26 | + <div className="account-migration__accounts"> |
| 27 | + <div className="account-migration__account"> |
| 28 | + <p className="account-migration__account-label"> |
| 29 | + {t('account-migration.your-account')} |
| 30 | + </p> |
| 31 | + <img |
| 32 | + className="account-migration__avatar" |
| 33 | + src={currentUserAccount.avatarUrl} |
| 34 | + /> |
| 35 | + <div className="account-migration__user-name"> |
| 36 | + {currentUserAccount.displayName} |
| 37 | + </div> |
| 38 | + </div> |
| 39 | + <div |
| 40 | + className="account-migration__merge-icon u__icon u__icon_disabled" |
| 41 | + > |
| 42 | +  |
| 43 | + </div> |
| 44 | + <div className="account-migration__account"> |
| 45 | + <p className="account-migration__account-label"> |
| 46 | + {t('account-migration.account-to-merge')} |
| 47 | + </p> |
| 48 | + <img |
| 49 | + className="account-migration__avatar" |
| 50 | + src={migration.userAccountToMerge.avatarUrl} |
| 51 | + /> |
| 52 | + <div className="account-migration__user-name"> |
| 53 | + {migration.userAccountToMerge.displayName} |
| 54 | + </div> |
| 55 | + </div> |
| 56 | + </div> |
| 57 | + { |
| 58 | + map( |
| 59 | + t('account-migration.message', {returnObjects: true}), |
| 60 | + paragraph => ( |
| 61 | + <p key={paragraph}>{paragraph}</p> |
| 62 | + ), |
| 63 | + ) |
| 64 | + } |
| 65 | + <div className="account-migration__buttons"> |
| 66 | + <button |
| 67 | + className={classnames( |
| 68 | + 'account-migration__button', |
| 69 | + 'account-migration__button_confirm', |
| 70 | + )} |
| 71 | + > |
| 72 | + {t('account-migration.buttons.migrate')} |
| 73 | + </button> |
| 74 | + <button |
| 75 | + className={classnames( |
| 76 | + 'account-migration__button', |
| 77 | + 'account-migration__button_cancel', |
| 78 | + )} |
| 79 | + > |
| 80 | + {t('account-migration.buttons.cancel')} |
| 81 | + </button> |
| 82 | + </div> |
| 83 | + </div> |
| 84 | + </Modal> |
| 85 | + ); |
| 86 | +} |
| 87 | + |
| 88 | +AccountMigration.propTypes = { |
| 89 | + currentUserAccount: PropTypes.instanceOf(UserAccountRecord), |
| 90 | + migration: PropTypes.instanceOf(AccountMigrationRecord), |
| 91 | +}; |
| 92 | + |
| 93 | +AccountMigration.defaultProps = { |
| 94 | + currentUserAccount: null, |
| 95 | + migration: null, |
| 96 | +}; |
0 commit comments