1
+ import { UserInfo } from '@/api/auth' ;
2
+ import PasswordModify from '@/components/account/AccountCenter/PasswordModify' ;
3
+ import { useConfigStore } from '@/stores/config' ;
4
+ import useSessionStore from '@/stores/session' ;
5
+ import { ValueOf } from '@/types' ;
1
6
import {
7
+ Badge ,
8
+ Center ,
2
9
Flex ,
3
- Text ,
10
+ HStack ,
11
+ IconButton ,
12
+ IconButtonProps ,
13
+ Image ,
4
14
Modal ,
5
15
ModalBody ,
6
16
ModalCloseButton ,
7
17
ModalContent ,
8
- ModalOverlay ,
9
- useDisclosure ,
10
- IconButton ,
11
- IconButtonProps ,
12
18
ModalHeader ,
19
+ ModalOverlay ,
13
20
Spinner ,
14
- Image ,
15
- HStack ,
16
- VStack ,
17
- Center ,
18
- Badge
21
+ Text ,
22
+ useDisclosure ,
23
+ VStack
19
24
} from '@chakra-ui/react' ;
20
- import { useMemo , useState } from 'react ' ;
25
+ import { CloseIcon , LeftArrowIcon , SettingIcon } from '@sealos/ui ' ;
21
26
import { useQuery } from '@tanstack/react-query' ;
22
- import useSessionStore from '@/stores/session' ;
23
27
import { useTranslation } from 'next-i18next' ;
24
- import { SettingIcon , LeftArrowIcon , CloseIcon } from '@sealos/ui' ;
25
- import { UserInfo } from '@/api/auth' ;
26
- import PasswordModify from '@/components/account/AccountCenter/PasswordModify' ;
27
- import { PhoneBind , EmailBind } from './SmsModify/SmsBind' ;
28
- import { PhoneUnBind , EmailUnBind } from './SmsModify/SmsUnbind' ;
29
- import { PhoneChange , EmailChange } from './SmsModify/SmsChange' ;
30
- import { BindingModifyButton , BINDING_STATE_MODIFY_BEHAVIOR } from './BindingModifyButton' ;
31
- import { ConfigItem } from './ConfigItem' ;
28
+ import { useMemo , useState } from 'react' ;
29
+ import { RealNameAuthForm } from '../RealNameModal' ;
32
30
import { AuthModifyList } from './AuthModifyList' ;
31
+ import { BINDING_STATE_MODIFY_BEHAVIOR , BindingModifyButton } from './BindingModifyButton' ;
32
+ import { ConfigItem } from './ConfigItem' ;
33
33
import DeleteAccount from './DeleteAccountModal' ;
34
- import { ValueOf } from '@/types ' ;
35
- import { RealNameAuthForm } from '../RealNameModal ' ;
36
- import { useConfigStore } from '@/stores/config ' ;
34
+ import { EmailBind , PhoneBind } from './SmsModify/SmsBind ' ;
35
+ import { EmailChange , PhoneChange } from './SmsModify/SmsChange ' ;
36
+ import { EmailUnBind , PhoneUnBind } from './SmsModify/SmsUnbind ' ;
37
37
enum _PageState {
38
38
INDEX = 0
39
39
// WECHAT_BIND,
@@ -68,6 +68,7 @@ const PageState = Object.assign(
68
68
export default function Index ( props : Omit < IconButtonProps , 'aria-label' > ) {
69
69
const { commonConfig } = useConfigStore ( ) ;
70
70
const { session } = useSessionStore ( ( s ) => s ) ;
71
+ const conf = useConfigStore ( ) ;
71
72
const { t } = useTranslation ( ) ;
72
73
const logo = '/images/default-user.svg' ;
73
74
const { isOpen, onOpen, onClose } = useDisclosure ( ) ;
@@ -236,7 +237,7 @@ export default function Index(props: Omit<IconButtonProps, 'aria-label'>) {
236
237
}
237
238
/>
238
239
) }
239
- { providerState . PASSWORD . isBinding && (
240
+ { conf . authConfig ?. idp . password . enabled && providerState . PASSWORD . isBinding && (
240
241
< ConfigItem
241
242
LeftElement = { < Text > { t ( 'common:password' ) } </ Text > }
242
243
RightElement = {
@@ -252,40 +253,42 @@ export default function Index(props: Omit<IconButtonProps, 'aria-label'>) {
252
253
}
253
254
/>
254
255
) }
255
- < ConfigItem
256
- LeftElement = { < Text > { t ( 'common:phone' ) } </ Text > }
257
- RightElement = {
258
- < >
259
- < Text >
260
- { providerState . PHONE . isBinding
261
- ? providerState . PHONE . id . replace ( / ( \d { 3 } ) \d + ( \d { 4 } ) / , '$1****$2' )
262
- : t ( 'common:unbound' ) }
263
- </ Text >
264
- < Flex gap = { '5px' } >
265
- < BindingModifyButton
266
- modifyBehavior = {
267
- providerState . PHONE . isBinding
268
- ? BINDING_STATE_MODIFY_BEHAVIOR . CHANGE_BINDING
269
- : BINDING_STATE_MODIFY_BEHAVIOR . BINDING
270
- }
271
- onClick = { ( ) => {
272
- providerState . PHONE . isBinding
273
- ? setPageState ( PageState . PHONE_CHANGE_BIND )
274
- : setPageState ( PageState . PHONE_BIND ) ;
275
- } }
276
- />
277
- { providerState . PHONE . isBinding && providerState . total > 1 && (
256
+ { conf . authConfig ?. idp . sms . enabled && (
257
+ < ConfigItem
258
+ LeftElement = { < Text > { t ( 'common:phone' ) } </ Text > }
259
+ RightElement = {
260
+ < >
261
+ < Text >
262
+ { providerState . PHONE . isBinding
263
+ ? providerState . PHONE . id . replace ( / ( \d { 3 } ) \d + ( \d { 4 } ) / , '$1****$2' )
264
+ : t ( 'common:unbound' ) }
265
+ </ Text >
266
+ < Flex gap = { '5px' } >
278
267
< BindingModifyButton
279
- modifyBehavior = { BINDING_STATE_MODIFY_BEHAVIOR . UNBINDING }
268
+ modifyBehavior = {
269
+ providerState . PHONE . isBinding
270
+ ? BINDING_STATE_MODIFY_BEHAVIOR . CHANGE_BINDING
271
+ : BINDING_STATE_MODIFY_BEHAVIOR . BINDING
272
+ }
280
273
onClick = { ( ) => {
281
- setPageState ( PageState . PHONE_UNBIND ) ;
274
+ providerState . PHONE . isBinding
275
+ ? setPageState ( PageState . PHONE_CHANGE_BIND )
276
+ : setPageState ( PageState . PHONE_BIND ) ;
282
277
} }
283
278
/>
284
- ) }
285
- </ Flex >
286
- </ >
287
- }
288
- />
279
+ { providerState . PHONE . isBinding && providerState . total > 1 && (
280
+ < BindingModifyButton
281
+ modifyBehavior = { BINDING_STATE_MODIFY_BEHAVIOR . UNBINDING }
282
+ onClick = { ( ) => {
283
+ setPageState ( PageState . PHONE_UNBIND ) ;
284
+ } }
285
+ />
286
+ ) }
287
+ </ Flex >
288
+ </ >
289
+ }
290
+ />
291
+ ) }
289
292
< ConfigItem
290
293
LeftElement = { < Text > { t ( 'common:email' ) } </ Text > }
291
294
RightElement = {
0 commit comments