feat: 完成多品牌隔离专项验收
This commit is contained in:
1 parent
1a2f179e15
commit
dcb40f629b
16 files changed
+197
-51
No files matched your search
@@ -14,12 +14,7 @@ import {
|
||||
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
|
||||
import { createApiClient } from "../../lib/api.js";
|
||||
import { ApiClientError } from "@personal-brand/api-client";
|
||||
import type {
|
||||
BrandFieldDefinition,
|
||||
BrandModule,
|
||||
InquiryForm,
|
||||
PublicWorkspace,
|
||||
} from "@personal-brand/api-client";
|
||||
import type { BrandFieldDefinition, BrandModule, InquiryForm } from "@personal-brand/api-client";
|
||||
import { useState } from "react";
|
||||
import { AdminPageHeader } from "../../components/AdminPageHeader.js";
|
||||
import { MutationError } from "../../components/QueryState.js";
|
||||
@@ -32,7 +27,7 @@ export function WorkspacePage() {
|
||||
const [editingForm, setEditingForm] = useState<InquiryForm | null>(null);
|
||||
const [visualTarget, setVisualTarget] = useState<string | null>(null);
|
||||
const [industryTarget, setIndustryTarget] = useState<{
|
||||
key: "personal" | "food";
|
||||
key: "personal" | "food" | "doors";
|
||||
name: string;
|
||||
description: string;
|
||||
capabilities: string[];
|
||||
@@ -82,7 +77,7 @@ export function WorkspacePage() {
|
||||
},
|
||||
});
|
||||
const install = useMutation({
|
||||
mutationFn: (key: "personal" | "food") => client.installAdminTemplate(key),
|
||||
mutationFn: (key: "personal" | "food" | "doors") => client.installAdminTemplate(key),
|
||||
onSuccess: () => {
|
||||
message.success("模板已安装");
|
||||
void queryClient.invalidateQueries({ queryKey: ["admin-workspace"] });
|
||||
@@ -150,7 +145,12 @@ export function WorkspacePage() {
|
||||
});
|
||||
const updateForm = useMutation({
|
||||
mutationFn: ({ id, body }: { id: string; body: Partial<InquiryForm> }) =>
|
||||
client.updateAdminInquiryForm(id, body),
|
||||
client.updateAdminInquiryForm(id, {
|
||||
...(body.name === undefined ? {} : { name: body.name }),
|
||||
...(body.offeringId == null ? {} : { offeringId: body.offeringId }),
|
||||
...(body.fieldsSnapshot === undefined ? {} : { fieldsSnapshot: body.fieldsSnapshot }),
|
||||
...(body.isEnabled === undefined ? {} : { isEnabled: body.isEnabled }),
|
||||
}),
|
||||
onSuccess: () => {
|
||||
message.success("咨询表单已更新");
|
||||
setFormOpen(false);
|
||||
@@ -673,13 +673,20 @@ export function WorkspacePage() {
|
||||
layout="vertical"
|
||||
onFinish={(values) =>
|
||||
(() => {
|
||||
const rawPurpose = String(values.purpose);
|
||||
const purpose: InquiryForm["purpose"] =
|
||||
rawPurpose === "booking" || rawPurpose === "quote-request" ? rawPurpose : "inquiry";
|
||||
const targetType: InquiryForm["targetType"] = values.offeringId
|
||||
? "offering"
|
||||
: "brand";
|
||||
const submissionAction: InquiryForm["submissionAction"] =
|
||||
purpose === "quote-request" ? "create-quote" : "create-inquiry";
|
||||
const body = {
|
||||
name: typeof values.name === "string" ? values.name : "",
|
||||
offeringId: typeof values.offeringId === "string" ? values.offeringId : undefined,
|
||||
purpose: values.purpose as InquiryForm["purpose"],
|
||||
targetType: values.offeringId ? "offering" : "brand",
|
||||
submissionAction:
|
||||
values.purpose === "quote-request" ? "create-quote" : "create-inquiry",
|
||||
...(typeof values.offeringId === "string" ? { offeringId: values.offeringId } : {}),
|
||||
purpose,
|
||||
targetType,
|
||||
submissionAction,
|
||||
fieldsSnapshot: (Array.isArray(values.fieldsSnapshot)
|
||||
? values.fieldsSnapshot
|
||||
: []
|
||||
@@ -687,8 +694,9 @@ export function WorkspacePage() {
|
||||
const item = field as Record<string, unknown>;
|
||||
if (typeof item.optionsText !== "string") return item;
|
||||
try {
|
||||
const options = JSON.parse(item.optionsText);
|
||||
const { optionsText: _optionsText, ...rest } = item;
|
||||
const options = JSON.parse(item.optionsText) as unknown;
|
||||
const { optionsText, ...rest } = item;
|
||||
void optionsText;
|
||||
return { ...rest, options };
|
||||
} catch {
|
||||
return item;
|
||||
@@ -759,7 +767,7 @@ export function WorkspacePage() {
|
||||
<Form.Item noStyle shouldUpdate>
|
||||
{({ getFieldValue }) =>
|
||||
["select", "radio"].includes(
|
||||
getFieldValue(["fieldsSnapshot", name, "type"]),
|
||||
String(getFieldValue(["fieldsSnapshot", name, "type"])),
|
||||
) ? (
|
||||
<Form.Item {...restField} name={[name, "optionsText"]}>
|
||||
<Input placeholder="选项 JSON" />
|
||||
|
||||
Reference in new issue
Block a user