64 lines
2.2 KiB
TypeScript
64 lines
2.2 KiB
TypeScript
import { Button, Card, Form, Input, Select, message } from "antd";
|
|
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
|
|
import type { BrandProfile } from "@personal-brand/api-client";
|
|
import { createApiClient } from "../../lib/api.js";
|
|
|
|
export function BrandPage() {
|
|
const client = createApiClient();
|
|
const queryClient = useQueryClient();
|
|
const [form] = Form.useForm<BrandProfile>();
|
|
const brand = useQuery({ queryKey: ["admin-brand"], queryFn: () => client.getAdminBrand() });
|
|
const save = useMutation({
|
|
mutationFn: (values: Partial<BrandProfile>) => client.updateAdminBrand(values),
|
|
onSuccess: () => {
|
|
message.success("品牌配置已保存");
|
|
void queryClient.invalidateQueries({ queryKey: ["admin-brand"] });
|
|
},
|
|
});
|
|
if (brand.isLoading) return <Card loading />;
|
|
if (brand.isError || !brand.data) return <Card>品牌配置加载失败</Card>;
|
|
return (
|
|
<Card title="品牌信任配置">
|
|
<Form
|
|
form={form}
|
|
layout="vertical"
|
|
initialValues={brand.data}
|
|
onFinish={(values) => save.mutate(values)}
|
|
>
|
|
<Form.Item name="templateKey" label="行业模板">
|
|
<Select
|
|
options={[
|
|
{ value: "personal", label: "个人品牌" },
|
|
{ value: "food", label: "餐饮模板" },
|
|
]}
|
|
/>
|
|
</Form.Item>
|
|
<Form.Item name="name" label="品牌名称" rules={[{ required: true }]}>
|
|
<Input />
|
|
</Form.Item>
|
|
<Form.Item name="tagline" label="一句话定位">
|
|
<Input />
|
|
</Form.Item>
|
|
<Form.Item name="description" label="品牌简介">
|
|
<Input.TextArea rows={5} />
|
|
</Form.Item>
|
|
<Form.Item name="hours" label="服务时间">
|
|
<Input />
|
|
</Form.Item>
|
|
<Form.Item name="address" label="所在位置">
|
|
<Input />
|
|
</Form.Item>
|
|
<Form.Item name="contactPhone" label="联系电话">
|
|
<Input />
|
|
</Form.Item>
|
|
<Form.Item name="contactWechat" label="微信号">
|
|
<Input />
|
|
</Form.Item>
|
|
<Button type="primary" htmlType="submit" loading={save.isPending}>
|
|
保存配置
|
|
</Button>
|
|
</Form>
|
|
</Card>
|
|
);
|
|
}
|