import { BarChartOutlined, EditOutlined, PlusOutlined, } from '@ant-design/icons'; import { Button, Form, Input, Modal, Table } from 'antd'; import { ColumnsType } from 'antd/es/table'; import React, { useMemo, useState } from 'react'; import { addWorkspaceWebsite, refreshWorkspaceWebsites, useWorspaceWebsites, WebsiteInfo, } from '../api/model/website'; import { Loading } from '../components/Loading'; import { NoWorkspaceTip } from '../components/NoWorkspaceTip'; import { useRequest } from '../hooks/useRequest'; import { useUserStore } from '../store/user'; export const Website: React.FC = React.memo(() => { const [isModalOpen, setIsModalOpen] = useState(false); const currentWorkspace = useUserStore( (state) => state.info?.currentWorkspace ); const [form] = Form.useForm(); const [{ loading }, handleAddWebsite] = useRequest(async () => { await form.validateFields(); const values = form.getFieldsValue(); await addWorkspaceWebsite(currentWorkspace!.id, values.name, values.domain); refreshWorkspaceWebsites(currentWorkspace!.id); setIsModalOpen(false); form.resetFields(); }); if (!currentWorkspace) { return ; } return (
Websites
handleAddWebsite()} onCancel={() => setIsModalOpen(false)} >
); }); Website.displayName = 'Website'; const WebsiteList: React.FC<{ workspaceId: string }> = React.memo((props) => { const { websites, isLoading } = useWorspaceWebsites(props.workspaceId); const columns = useMemo((): ColumnsType => { return [ { dataIndex: 'name', title: 'Name', }, { dataIndex: 'domain', title: 'Domain', }, { key: 'action', render: () => { return (
); }, }, ]; }, []); if (isLoading) { return ; } return ; }); WebsiteList.displayName = 'WebsiteList';