tianji/src/client/pages/Dashboard.tsx

62 lines
1.7 KiB
TypeScript
Raw Normal View History

2023-10-06 07:04:55 +00:00
import React, { Fragment } from 'react';
import { ArrowRightOutlined, EditOutlined } from '@ant-design/icons';
import { Button, Divider } from 'antd';
2023-10-06 14:08:15 +00:00
import { WebsiteOverview } from '../components/website/WebsiteOverview';
import { useCurrentWorkspaceId } from '../store/user';
import { Loading } from '../components/Loading';
2023-10-06 07:04:55 +00:00
import { useWorspaceWebsites } from '../api/model/website';
import { NoWorkspaceTip } from '../components/NoWorkspaceTip';
import { useNavigate } from 'react-router';
2023-08-31 16:11:47 +00:00
export const Dashboard: React.FC = React.memo(() => {
2023-10-06 07:04:55 +00:00
const workspaceId = useCurrentWorkspaceId()!;
const { isLoading, websites } = useWorspaceWebsites(workspaceId);
const navigate = useNavigate();
if (!workspaceId) {
2023-10-06 07:04:55 +00:00
return <NoWorkspaceTip />;
}
if (isLoading) {
return <Loading />;
}
2023-09-01 16:52:43 +00:00
return (
<div>
<div className="h-24 flex items-center">
<div className="text-2xl flex-1">Dashboard</div>
<div>
<Button icon={<EditOutlined />} size="large">
Edit
</Button>
</div>
</div>
<div>
2023-10-06 07:04:55 +00:00
{websites.map((website, i) => (
<Fragment key={website.id}>
{i !== 0 && <Divider />}
<WebsiteOverview
website={website}
actions={
<>
<Button
type="primary"
size="large"
onClick={() => {
navigate(`/website/${website.id}`);
}}
>
View Details <ArrowRightOutlined />
</Button>
</>
}
/>
</Fragment>
))}
2023-09-01 16:52:43 +00:00
</div>
</div>
);
2023-08-31 16:11:47 +00:00
});
Dashboard.displayName = 'Dashboard';