Skip to content

Commit 8b58eb5

Browse files
committed
Merge branch 'dev' of github.com:topcoder-platform/platform-ui into dev
2 parents 58215fd + cb3015e commit 8b58eb5

File tree

32 files changed

+789
-70
lines changed

32 files changed

+789
-70
lines changed
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
11
import { ReactComponent as MFAImage } from './mfa.svg'
2+
import { ReactComponent as AppleStore } from './apple-store.svg'
23
import diceIdLogo from './dicelogo.png'
4+
import diceIdLogoBig from './dicelogobig.png'
5+
import googlePlay from './google-play.png'
36

47
export {
8+
AppleStore,
59
diceIdLogo,
10+
diceIdLogoBig,
11+
googlePlay,
612
MFAImage,
713
}

src/apps/accounts/src/settings/tabs/AccountSettingsTabs.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { Dispatch, FC, SetStateAction, useMemo, useState } from 'react'
22
import { useLocation } from 'react-router-dom'
33

4-
import { UserProfile } from '~/libs/core'
4+
import { useMemberTraits, UserProfile, UserTraits } from '~/libs/core'
55
import { TabsNavbar } from '~/libs/ui'
66

77
import { AccountSettingsTabsConfig, AccountSettingsTabViews, getHashFromTabId, getTabIdFromHash } from './config'
@@ -22,6 +22,8 @@ const AccountSettingsTabs: FC<AccountSettingsTabsProps> = (props: AccountSetting
2222
const [activeTab, setActiveTab]: [string, Dispatch<SetStateAction<string>>]
2323
= useState<string>(activeTabHash)
2424

25+
const memberTraits: UserTraits[] | undefined = useMemberTraits(props.profile.handle)
26+
2527
function handleTabChange(tabId: string): void {
2628
setActiveTab(tabId)
2729
window.location.hash = getHashFromTabId(tabId)
@@ -36,7 +38,7 @@ const AccountSettingsTabs: FC<AccountSettingsTabsProps> = (props: AccountSetting
3638
/>
3739

3840
{activeTab === AccountSettingsTabViews.account && (
39-
<AccountTab profile={props.profile} />
41+
<AccountTab profile={props.profile} memberTraits={memberTraits} />
4042
)}
4143

4244
{activeTab === AccountSettingsTabViews.preferences && (

src/apps/accounts/src/settings/tabs/account/AccountTab.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { FC } from 'react'
22

3-
import { UserProfile } from '~/libs/core'
3+
import { UserProfile, UserTraits } from '~/libs/core'
44

55
import { AccountRole } from './account-role'
66
import { SecuritySection } from './security'
@@ -9,6 +9,7 @@ import styles from './AccountTab.module.scss'
99

1010
interface AccountTabProps {
1111
profile: UserProfile
12+
memberTraits: UserTraits[] | undefined
1213
}
1314

1415
const AccountTab: FC<AccountTabProps> = (props: AccountTabProps) => (
@@ -17,9 +18,9 @@ const AccountTab: FC<AccountTabProps> = (props: AccountTabProps) => (
1718

1819
<AccountRole profile={props.profile} />
1920

20-
<UserAndPassword profile={props.profile} />
21+
<UserAndPassword profile={props.profile} memberTraits={props.memberTraits} />
2122

22-
<SecuritySection />
23+
<SecuritySection profile={props.profile} />
2324
</div>
2425
)
2526

src/apps/accounts/src/settings/tabs/account/security/Security.tsx

Lines changed: 35 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,43 @@
1-
import { Dispatch, FC, SetStateAction, useState } from 'react'
1+
import { Dispatch, FC, SetStateAction, useEffect, useState } from 'react'
2+
import { toast } from 'react-toastify'
23

34
import { Button, Collapsible, FormToggleSwitch } from '~/libs/ui'
45
import { diceIdLogo, MFAImage, SettingSection } from '~/apps/accounts/src/lib'
6+
import { MemberMFAStatus, updateMemberMFAStatusAsync, useMemberMFAStatus, UserProfile } from '~/libs/core'
57

68
import { DiceSetupModal } from './dice-setup-modal'
79
import styles from './Security.module.scss'
810

9-
const Security: FC<{}> = () => {
10-
const [mfaStatus, setMFAStatus]: [boolean, Dispatch<SetStateAction<boolean>>] = useState(false)
11+
interface SecurityProps {
12+
profile: UserProfile
13+
}
14+
15+
const Security: FC<SecurityProps> = (props: SecurityProps) => {
1116
const [setupDiceModalOpen, setSetupDiceModalOpen]: [boolean, Dispatch<SetStateAction<boolean>>] = useState(false)
1217

13-
function handleUserMFAChange(event: any): void {
14-
console.log('handleUserMFAChange', event)
15-
setMFAStatus(!mfaStatus)
18+
const mfaStatusData: MemberMFAStatus | undefined = useMemberMFAStatus(props.profile.userId)
19+
20+
const [mfaEnabled, setMFAEnabled]: [boolean, Dispatch<SetStateAction<boolean>>] = useState(false)
21+
22+
useEffect(() => {
23+
if (mfaStatusData) {
24+
setMFAEnabled(mfaStatusData.mfaEnabled)
25+
}
26+
}, [mfaStatusData])
27+
28+
function handleUserMFAChange(): void {
29+
updateMemberMFAStatusAsync(props.profile.userId, {
30+
param: {
31+
mfaEnabled: !mfaEnabled,
32+
},
33+
})
34+
.then(() => {
35+
setMFAEnabled(!mfaEnabled)
36+
toast.success('Your Multi Factor Authentication (MFA) status was updated.')
37+
})
38+
.catch(() => {
39+
toast.error('Something went wrong. Please try again later.')
40+
})
1641
}
1742

1843
function handleDiceModalStatus(): void {
@@ -38,7 +63,8 @@ const Security: FC<{}> = () => {
3863
<FormToggleSwitch
3964
name='mfaStatus'
4065
onChange={handleUserMFAChange}
41-
value={mfaStatus}
66+
value={mfaEnabled}
67+
disabled={mfaStatusData?.diceEnabled}
4268
/>
4369
)}
4470
/>
@@ -58,13 +84,15 @@ const Security: FC<{}> = () => {
5884
size='lg'
5985
className={styles.diceIdButton}
6086
onClick={handleDiceModalStatus}
87+
disabled={!mfaEnabled || mfaStatusData?.diceEnabled}
6188
/>
6289
)}
6390
/>
6491

6592
{setupDiceModalOpen && (
6693
<DiceSetupModal
6794
onClose={handleDiceModalStatus}
95+
profile={props.profile}
6896
/>
6997
)}
7098
</Collapsible>
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
@import '@libs/ui/styles/includes';
2+
3+
.diceModal {
4+
:global(.react-responsive-modal-closeButton) {
5+
display: flex;
6+
}
7+
8+
.appSoresWrap {
9+
display: flex;
10+
justify-content: space-evenly;
11+
margin: $sp-4 0;
12+
13+
.appStoreCard {
14+
display: flex;
15+
flex-direction: column;
16+
align-items: center;
17+
}
18+
}
19+
20+
.qrCode {
21+
margin: auto;
22+
}
23+
24+
.ctaButtons {
25+
display: flex;
26+
justify-content: space-between;
27+
width: 100%;
28+
flex: 1;
29+
}
30+
}

0 commit comments

Comments
 (0)