2023-09-29 12:29:22 +00:00
|
|
|
'use client';
|
2024-01-29 09:32:05 +00:00
|
|
|
import { Key, useState } from 'react';
|
|
|
|
|
import { Item, Loading, Tabs } from 'react-basics';
|
2023-09-29 12:29:22 +00:00
|
|
|
import UserEditForm from '../UserEditForm';
|
2022-12-27 00:57:59 +00:00
|
|
|
import PageHeader from 'components/layout/PageHeader';
|
2024-01-29 09:32:05 +00:00
|
|
|
import { useMessages, useUser } from 'components/hooks';
|
|
|
|
|
import UserWebsites from './UserWebsites';
|
2022-12-27 00:57:59 +00:00
|
|
|
|
2024-01-29 09:32:05 +00:00
|
|
|
export function UserSettings({ userId }: { userId: string }) {
|
|
|
|
|
const { formatMessage, labels } = useMessages();
|
2023-12-06 03:22:14 +00:00
|
|
|
const [tab, setTab] = useState<Key>('details');
|
2024-01-29 09:32:05 +00:00
|
|
|
const { data: user, isLoading } = useUser(userId, { gcTime: 0 });
|
2022-12-27 00:57:59 +00:00
|
|
|
|
2024-01-29 09:32:05 +00:00
|
|
|
if (isLoading) {
|
2023-12-06 03:22:14 +00:00
|
|
|
return <Loading />;
|
2023-09-29 12:29:22 +00:00
|
|
|
}
|
|
|
|
|
|
2022-12-27 00:57:59 +00:00
|
|
|
return (
|
2023-09-29 12:29:22 +00:00
|
|
|
<>
|
2024-01-29 09:32:05 +00:00
|
|
|
<PageHeader title={user?.username} />
|
2022-12-27 00:57:59 +00:00
|
|
|
<Tabs selectedKey={tab} onSelect={setTab} style={{ marginBottom: 30, fontSize: 14 }}>
|
2023-01-25 15:42:46 +00:00
|
|
|
<Item key="details">{formatMessage(labels.details)}</Item>
|
|
|
|
|
<Item key="websites">{formatMessage(labels.websites)}</Item>
|
2022-12-27 00:57:59 +00:00
|
|
|
</Tabs>
|
2024-01-29 09:32:05 +00:00
|
|
|
{tab === 'details' && <UserEditForm userId={userId} data={user} />}
|
2023-01-25 15:42:46 +00:00
|
|
|
{tab === 'websites' && <UserWebsites userId={userId} />}
|
2023-09-29 12:29:22 +00:00
|
|
|
</>
|
2022-12-27 00:57:59 +00:00
|
|
|
);
|
|
|
|
|
}
|
2023-04-21 15:00:42 +00:00
|
|
|
|
|
|
|
|
export default UserSettings;
|