import { Button, Form, Input, message, Popconfirm, Tabs } from 'antd';
import React from 'react';
import { useNavigate, useParams } from 'react-router';
import {
deleteWorkspaceWebsite,
updateWorkspaceWebsiteInfo,
useWorkspaceWebsiteInfo,
} from '../api/model/website';
import { useRequest } from '../hooks/useRequest';
import { useCurrentWorkspaceId } from '../store/user';
import { ErrorTip } from './ErrorTip';
import { Loading } from './Loading';
import { NoWorkspaceTip } from './NoWorkspaceTip';
export const WebsiteInfo: React.FC = React.memo(() => {
const { websiteId } = useParams<{
websiteId: string;
}>();
const currentWorkspaceId = useCurrentWorkspaceId();
const { website, isLoading } = useWorkspaceWebsiteInfo(
currentWorkspaceId!,
websiteId!
);
const navigate = useNavigate();
const [, handleSave] = useRequest(
async (values: { name: string; domain: string }) => {
await updateWorkspaceWebsiteInfo(currentWorkspaceId!, websiteId!, {
name: values.name,
domain: values.domain,
});
message.success('Save Success');
}
);
const [, handleDeleteWebsite] = useRequest(async () => {
await deleteWorkspaceWebsite(currentWorkspaceId!, websiteId!);
message.success('Delete Success');
navigate('/settings/websites');
});
if (!currentWorkspaceId) {
return