feat: 完成多品牌隔离专项验收

This commit is contained in:
que01 committed 2026-09-23 13:22:28 +08:00
1 parent 1a2f179e15
commit dcb40f629b
16 files changed
+197 -51

No files matched your search

+1 -1
View File
@@ -10,7 +10,7 @@ export function QueryState({
loading?: boolean;
error?: unknown;
onRetry?: () => void;
children: ReactNode;
children?: ReactNode;
}) {
if (loading)
return (
@@ -1,5 +1,5 @@
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
import { Alert, Button, Card, Form, Input, Select, Space, Table, Tag, message } from "antd";
import { Alert, Button, Card, Form, Input, Select, Table, Tag, message } from "antd";
import type { CapabilityInstallation } from "@personal-brand/api-client";
import { AdminPageHeader } from "../../components/AdminPageHeader.js";
import { QueryState } from "../../components/QueryState.js";
@@ -28,11 +28,11 @@ export function CapabilitiesPage() {
createApiClient().updateAdminCapability(key, {
capabilityVersion: values.capabilityVersion,
status: values.status,
config: values.configText ? JSON.parse(values.configText) : {},
config: values.configText ? (JSON.parse(values.configText) as Record<string, unknown>) : {},
}),
onSuccess: () => {
message.success("能力配置已更新");
queryClient.invalidateQueries({ queryKey: ["admin", "capabilities"] });
void queryClient.invalidateQueries({ queryKey: ["admin", "capabilities"] });
},
onError: (error) => message.error(error instanceof Error ? error.message : "更新失败"),
});
@@ -222,12 +222,14 @@ export function InquiriesPage() {
{
title: "来源业务",
dataIndex: ["offering", "name"],
render: (value) => value || "品牌咨询",
render: (value: string | null | undefined) => value || "品牌咨询",
},
{
title: "状态",
dataIndex: "status",
render: (value) => <Tag>{inquiryLabels[value] ?? value}</Tag>,
render: (value: InquirySubmission["status"]) => (
<Tag>{inquiryLabels[value] ?? value}</Tag>
),
},
{ title: "版本", dataIndex: "formVersion", render: (value) => `v${value}` },
{
@@ -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" />
+3 -1
View File
@@ -146,7 +146,9 @@ function Dashboard({ onLogout }: { onLogout: () => void }) {
size="small"
value={brand.data?.id}
loading={memberships.isLoading}
onChange={(value) => void switchBrand(value)}
onChange={(value) => {
if (value) void switchBrand(value);
}}
options={(memberships.data ?? []).map((item) => ({
value: item.brand.id,
label: item.brand.name,