feat: 在后台展示当前行业模板定义
This commit is contained in:
1 parent
c6785892ed
commit
6ee0dffdb8
2 files changed
+19
-1
No files matched your search
@@ -8,6 +8,11 @@ export function BrandPage() {
|
|||||||
const queryClient = useQueryClient();
|
const queryClient = useQueryClient();
|
||||||
const [form] = Form.useForm<BrandProfile>();
|
const [form] = Form.useForm<BrandProfile>();
|
||||||
const brand = useQuery({ queryKey: ["admin-brand"], queryFn: () => client.getAdminBrand() });
|
const brand = useQuery({ queryKey: ["admin-brand"], queryFn: () => client.getAdminBrand() });
|
||||||
|
const template = useQuery({
|
||||||
|
queryKey: ["template", brand.data?.templateKey],
|
||||||
|
queryFn: () => client.getPublicTemplate(brand.data!.templateKey as "personal" | "food"),
|
||||||
|
enabled: Boolean(brand.data?.templateKey),
|
||||||
|
});
|
||||||
const save = useMutation({
|
const save = useMutation({
|
||||||
mutationFn: (values: Partial<BrandProfile>) => client.updateAdminBrand(values),
|
mutationFn: (values: Partial<BrandProfile>) => client.updateAdminBrand(values),
|
||||||
onSuccess: () => {
|
onSuccess: () => {
|
||||||
@@ -18,7 +23,10 @@ export function BrandPage() {
|
|||||||
if (brand.isLoading) return <Card loading />;
|
if (brand.isLoading) return <Card loading />;
|
||||||
if (brand.isError || !brand.data) return <Card>品牌配置加载失败</Card>;
|
if (brand.isError || !brand.data) return <Card>品牌配置加载失败</Card>;
|
||||||
return (
|
return (
|
||||||
<Card title="品牌信任配置">
|
<Card
|
||||||
|
title="品牌信任配置"
|
||||||
|
extra={template.data ? `${template.data.name}:${template.data.description}` : undefined}
|
||||||
|
>
|
||||||
<Form
|
<Form
|
||||||
form={form}
|
form={form}
|
||||||
layout="vertical"
|
layout="vertical"
|
||||||
|
|||||||
@@ -101,6 +101,13 @@ export interface ApiErrorBody {
|
|||||||
error: { code: string; message: string };
|
error: { code: string; message: string };
|
||||||
requestId: string | null;
|
requestId: string | null;
|
||||||
}
|
}
|
||||||
|
export interface BrandTemplateDefinition {
|
||||||
|
key: "personal" | "food";
|
||||||
|
name: string;
|
||||||
|
description: string;
|
||||||
|
serviceCategories: string[];
|
||||||
|
trustContentTypes: string[];
|
||||||
|
}
|
||||||
|
|
||||||
export class ApiClientError extends Error {
|
export class ApiClientError extends Error {
|
||||||
constructor(
|
constructor(
|
||||||
@@ -208,6 +215,9 @@ export class ApiClient {
|
|||||||
updateAdminBrand(body: BrandUpdate): Promise<BrandProfile> {
|
updateAdminBrand(body: BrandUpdate): Promise<BrandProfile> {
|
||||||
return this.request("/admin/config/brand", { method: "PATCH", body });
|
return this.request("/admin/config/brand", { method: "PATCH", body });
|
||||||
}
|
}
|
||||||
|
getPublicTemplate(key: "personal" | "food"): Promise<BrandTemplateDefinition> {
|
||||||
|
return this.request(`/public/templates/${key}`);
|
||||||
|
}
|
||||||
updateAdminService(id: string, body: ServiceUpdate): Promise<PublicService> {
|
updateAdminService(id: string, body: ServiceUpdate): Promise<PublicService> {
|
||||||
return this.request(`/admin/config/services/${encodeURIComponent(id)}`, {
|
return this.request(`/admin/config/services/${encodeURIComponent(id)}`, {
|
||||||
method: "PATCH",
|
method: "PATCH",
|
||||||
|
|||||||
Reference in new issue
Block a user