Skip to content

Commit 4c3e9c6

Browse files
committed
🚧 wip: provider list
1 parent dda159f commit 4c3e9c6

File tree

2 files changed

+79
-0
lines changed

2 files changed

+79
-0
lines changed

src/app/(main)/profile/(home)/Client.tsx

+9
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import AvatarWithUpload from '@/features/AvatarWithUpload';
99
import UserAvatar from '@/features/User/UserAvatar';
1010
import { useUserStore } from '@/store/user';
1111
import { authSelectors, userProfileSelectors } from '@/store/user/selectors';
12+
import SSOProvidersList from './features/SSOProvidersList';
1213

1314
type SettingItemGroup = ItemGroup;
1415

@@ -42,6 +43,14 @@ const Client = memo<{ mobile?: boolean }>(() => {
4243
label: t('profile.email'),
4344
minWidth: undefined,
4445
},
46+
{
47+
children: <SSOProvidersList />,
48+
hidden: !isLoginWithNextAuth,
49+
label: 'profile.ssoProviders',
50+
minWidth: undefined,
51+
layout: 'vertical',
52+
labelAlign: 'left'
53+
},
4554
],
4655
title: t('tab.profile'),
4756
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
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;

0 commit comments

Comments
 (0)