import { business } from '@/services';
import { formLayout } from '@/utils/formLayout';
import { ProForm, ProFormTextArea } from '@ant-design/pro-components';
import { Col, message, Row, Space } from 'antd';

export default function SmartRecognitionPromptConfig() {
	return (
		<ProForm
			{...formLayout()}
			request={async () => {
				const { data } = await business.setting.showSetting({
					settingShowQry: {
						settingKey: 'SMART_RECOGNITION_PROMPT',
					},
				});

				return {
					...data?.settingValue,
				};
			}}
			onFinish={async (values) => {
				await business.setting.updateSetting({
					settingKey: 'SMART_RECOGNITION_PROMPT',
					settingValue: {
						...values,
						settingKey: 'SMART_RECOGNITION_PROMPT',
					},
				});

				message.success('智能识别提示词');
			}}
			submitter={{
				render: (_, dom) => {
					return (
						<Row>
							<Col span={14} offset={4}>
								<Space>{dom}</Space>
							</Col>
						</Row>
					);
				},
			}}
		>
			<ProFormTextArea name="prompt" label="智能识别提示词" />
		</ProForm>
	);
}
