mirror of
https://github.com/suyiiyii/nonebot-bison.git
synced 2025-06-04 02:26:11 +08:00
55 lines
1.5 KiB
TypeScript
55 lines
1.5 KiB
TypeScript
import React, { useState } from 'react';
|
|
import { Form, Input, Modal } from '@arco-design/web-react';
|
|
import { useNewCookieMutation } from './cookieConfigSlice';
|
|
|
|
interface CookieModalProps {
|
|
visible: boolean;
|
|
setVisible: (arg0: boolean) => void;
|
|
siteName: string;
|
|
}
|
|
|
|
function CookieModal({ visible, setVisible, siteName }: CookieModalProps) {
|
|
const FormItem = Form.Item;
|
|
const [content, setContent] = useState<string>('');
|
|
const [confirmLoading, setConfirmLoading] = useState(false);
|
|
const [newCoookie] = useNewCookieMutation();
|
|
|
|
const onSubmit = () => {
|
|
const postPromise: ReturnType<typeof newCoookie> = newCoookie({ siteName, content });
|
|
setConfirmLoading(true);
|
|
postPromise.then(() => {
|
|
setConfirmLoading(false);
|
|
setVisible(false);
|
|
setContent('');
|
|
});
|
|
};
|
|
|
|
return (
|
|
<Modal
|
|
title="添加 Cookie"
|
|
visible={visible}
|
|
onCancel={() => setVisible(false)}
|
|
confirmLoading={confirmLoading}
|
|
onOk={onSubmit}
|
|
style={{ maxWidth: '90vw' }}
|
|
>
|
|
|
|
<Form autoComplete="off">
|
|
<FormItem label="Site Name" required>
|
|
<Input placeholder="Please enter site name" value={siteName} disabled />
|
|
</FormItem>
|
|
<FormItem label="Content" required>
|
|
<Input.TextArea
|
|
placeholder="Please enter content"
|
|
value={content}
|
|
onChange={setContent}
|
|
/>
|
|
</FormItem>
|
|
|
|
</Form>
|
|
</Modal>
|
|
);
|
|
}
|
|
|
|
export default CookieModal;
|