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

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

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

				message.success('更新腾讯地图AppKey成功');
			}}
			submitter={{
				render: (_, dom) => {
					return (
						<Row>
							<Col span={14} offset={4}>
								<Space>{dom}</Space>
							</Col>
						</Row>
					);
				},
			}}
		>
			<ProFormText name="appKey" label="腾讯地图AppKey" />
		</ProForm>
	);
}
