File tree 2 files changed +79
-0
lines changed
src/app/(main)/profile/(home)
2 files changed +79
-0
lines changed Original file line number Diff line number Diff line change @@ -9,6 +9,7 @@ import AvatarWithUpload from '@/features/AvatarWithUpload';
9
9
import UserAvatar from '@/features/User/UserAvatar' ;
10
10
import { useUserStore } from '@/store/user' ;
11
11
import { authSelectors , userProfileSelectors } from '@/store/user/selectors' ;
12
+ import SSOProvidersList from './features/SSOProvidersList' ;
12
13
13
14
type SettingItemGroup = ItemGroup ;
14
15
@@ -42,6 +43,14 @@ const Client = memo<{ mobile?: boolean }>(() => {
42
43
label : t ( 'profile.email' ) ,
43
44
minWidth : undefined ,
44
45
} ,
46
+ {
47
+ children : < SSOProvidersList /> ,
48
+ hidden : ! isLoginWithNextAuth ,
49
+ label : 'profile.ssoProviders' ,
50
+ minWidth : undefined ,
51
+ layout : 'vertical' ,
52
+ labelAlign : 'left'
53
+ } ,
45
54
] ,
46
55
title : t ( 'tab.profile' ) ,
47
56
} ;
Original file line number Diff line number Diff line change
1
+ import {
2
+ ActionEvent ,
3
+ ActionIcon ,
4
+ ActionIconGroup ,
5
+ type ActionIconGroupProps ,
6
+ List ,
7
+ } from '@lobehub/ui' ;
8
+ import { Copy , RotateCw , Unlink } from 'lucide-react' ;
9
+ import { type AdapterAccount } from 'next-auth/adapters' ;
10
+ import { memo } from 'react' ;
11
+ import { Flexbox } from 'react-layout-kit' ;
12
+
13
+ import { useOnlyFetchOnceSWR } from '@/libs/swr' ;
14
+ import { userService } from '@/services/user' ;
15
+
16
+ const { Item } = List ;
17
+
18
+ const handleActionClick = ( e : ActionEvent , item : AdapterAccount ) => {
19
+ console . log ( e , item ) ;
20
+ } ;
21
+
22
+ export const SSOProvidersList = memo ( ( ) => {
23
+ const { data, isLoading } = useOnlyFetchOnceSWR ( 'profile-sso-providers' , async ( ) =>
24
+ userService . getUserSSOProviders ( ) ,
25
+ ) ;
26
+ return (
27
+ < >
28
+ { isLoading ? (
29
+ < Flexbox align = { 'center' } gap = { 4 } horizontal >
30
+ < ActionIcon icon = { RotateCw } spin />
31
+ { 'stats.modelsRank.loading' }
32
+ </ Flexbox >
33
+ ) : (
34
+ < Flexbox >
35
+ { data ?. map ( ( item , index ) => {
36
+ const dropdownMenu : ActionIconGroupProps [ 'dropdownMenu' ] = [
37
+ {
38
+ icon : Copy ,
39
+ key : 'copy' ,
40
+ label : 'copy' ,
41
+ } ,
42
+ {
43
+ icon : Unlink ,
44
+ key : 'unlink' ,
45
+ label : 'unlink' ,
46
+ } ,
47
+ ] ;
48
+ return (
49
+ < Item
50
+ actions = {
51
+ < ActionIconGroup
52
+ dropdownMenu = { dropdownMenu }
53
+ onActionClick = { ( e ) => handleActionClick ( e , item ) }
54
+ />
55
+ }
56
+ date = { item . expires_at }
57
+ description = { item . providerAccountId }
58
+ key = { index }
59
+ showAction = { true }
60
+ title = { item . provider }
61
+ />
62
+ ) ;
63
+ } ) }
64
+ </ Flexbox >
65
+ ) }
66
+ </ >
67
+ ) ;
68
+ } ) ;
69
+
70
+ export default SSOProvidersList ;
You can’t perform that action at this time.
0 commit comments