fix: 完成管理端类型安全收口
This commit is contained in:
1 parent
2712517e64
commit
665a88eb30
5 files changed
+38
-18
No files matched your search
@@ -22,9 +22,11 @@ export function OverviewPage() {
|
|||||||
const error = results.find((result) => result.isError)?.error;
|
const error = results.find((result) => result.isError)?.error;
|
||||||
const retry = () => results.forEach((result) => void result.refetch());
|
const retry = () => results.forEach((result) => void result.refetch());
|
||||||
const brand = results[0].data;
|
const brand = results[0].data;
|
||||||
const workspace = results[1].data;
|
const workspace = results[1].data as
|
||||||
|
| { inquiryForm?: { isEnabled?: boolean }; modules?: Array<{ isEnabled?: boolean }> }
|
||||||
|
| undefined;
|
||||||
const trust = results[2].data;
|
const trust = results[2].data;
|
||||||
const offerings = results[3].data;
|
const offerings = results[3].data as Array<{ isEnabled?: boolean }> | undefined;
|
||||||
const submissions = results[4].data;
|
const submissions = results[4].data;
|
||||||
const checklist = [
|
const checklist = [
|
||||||
{ label: "品牌定位已填写", done: Boolean(brand?.name && brand.tagline) },
|
{ label: "品牌定位已填写", done: Boolean(brand?.name && brand.tagline) },
|
||||||
@@ -78,7 +80,7 @@ export function OverviewPage() {
|
|||||||
<Card>
|
<Card>
|
||||||
<Statistic
|
<Statistic
|
||||||
title="工作空间模块"
|
title="工作空间模块"
|
||||||
value={workspace?.modules.filter((item) => item.isEnabled).length ?? 0}
|
value={workspace?.modules?.filter((item) => item.isEnabled).length ?? 0}
|
||||||
suffix="个启用"
|
suffix="个启用"
|
||||||
/>
|
/>
|
||||||
</Card>
|
</Card>
|
||||||
|
|||||||
@@ -129,7 +129,7 @@ export function ServicesPage() {
|
|||||||
package: "套餐",
|
package: "套餐",
|
||||||
subscription: "订阅",
|
subscription: "订阅",
|
||||||
} as Record<string, string>
|
} as Record<string, string>
|
||||||
)[value] ?? value}
|
)[String(value)] ?? String(value)}
|
||||||
</Tag>
|
</Tag>
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
@@ -154,7 +154,7 @@ export function ServicesPage() {
|
|||||||
还没有公开业务提供项。创建后,小程序服务页会优先读取这些内容。
|
还没有公开业务提供项。创建后,小程序服务页会优先读取这些内容。
|
||||||
</Typography.Paragraph>
|
</Typography.Paragraph>
|
||||||
)}
|
)}
|
||||||
<Divider orientation="left">兼容旧版服务</Divider>
|
<Divider>兼容旧版服务</Divider>
|
||||||
<Table
|
<Table
|
||||||
rowKey="id"
|
rowKey="id"
|
||||||
size="small"
|
size="small"
|
||||||
@@ -201,7 +201,7 @@ export function ServicesPage() {
|
|||||||
<Form
|
<Form
|
||||||
form={offeringForm}
|
form={offeringForm}
|
||||||
layout="vertical"
|
layout="vertical"
|
||||||
onFinish={(values) => saveOffering.mutate(values)}
|
onFinish={(values) => saveOffering.mutate(values as Record<string, unknown>)}
|
||||||
>
|
>
|
||||||
<Form.Item name="kind" label="类型" rules={[{ required: true }]}>
|
<Form.Item name="kind" label="类型" rules={[{ required: true }]}>
|
||||||
<Select
|
<Select
|
||||||
@@ -324,7 +324,11 @@ export function ServicesPage() {
|
|||||||
onOk={() => form.submit()}
|
onOk={() => form.submit()}
|
||||||
confirmLoading={save.isPending}
|
confirmLoading={save.isPending}
|
||||||
>
|
>
|
||||||
<Form form={form} layout="vertical" onFinish={(values) => save.mutate(values)}>
|
<Form
|
||||||
|
form={form}
|
||||||
|
layout="vertical"
|
||||||
|
onFinish={(values) => save.mutate(values as Record<string, unknown>)}
|
||||||
|
>
|
||||||
<Form.Item name="name" label="服务名称" rules={[{ required: true }]}>
|
<Form.Item name="name" label="服务名称" rules={[{ required: true }]}>
|
||||||
<Input />
|
<Input />
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
|
|||||||
@@ -65,9 +65,9 @@ export function TrustContentPage() {
|
|||||||
? {
|
? {
|
||||||
type: item.type,
|
type: item.type,
|
||||||
title: item.title,
|
title: item.title,
|
||||||
summary: item.summary ?? undefined,
|
...(item.summary ? { summary: item.summary } : {}),
|
||||||
content: item.content,
|
content: item.content,
|
||||||
coverUrl: item.coverUrl ?? undefined,
|
...(item.coverUrl ? { coverUrl: item.coverUrl } : {}),
|
||||||
isPublished: item.isPublished,
|
isPublished: item.isPublished,
|
||||||
}
|
}
|
||||||
: { type: "profile", isPublished: false },
|
: { type: "profile", isPublished: false },
|
||||||
@@ -97,7 +97,11 @@ export function TrustContentPage() {
|
|||||||
),
|
),
|
||||||
},
|
},
|
||||||
{ title: "标题", dataIndex: "title" },
|
{ title: "标题", dataIndex: "title" },
|
||||||
{ title: "摘要", dataIndex: "summary", render: (value) => value || "未填写" },
|
{
|
||||||
|
title: "摘要",
|
||||||
|
dataIndex: "summary",
|
||||||
|
render: (value) => (typeof value === "string" && value ? value : "未填写"),
|
||||||
|
},
|
||||||
{
|
{
|
||||||
title: "状态",
|
title: "状态",
|
||||||
dataIndex: "isPublished",
|
dataIndex: "isPublished",
|
||||||
|
|||||||
@@ -24,8 +24,8 @@ export function WorkspacePage() {
|
|||||||
const queryClient = useQueryClient();
|
const queryClient = useQueryClient();
|
||||||
const [fieldOpen, setFieldOpen] = useState(false);
|
const [fieldOpen, setFieldOpen] = useState(false);
|
||||||
const [formOpen, setFormOpen] = useState(false);
|
const [formOpen, setFormOpen] = useState(false);
|
||||||
const [form] = Form.useForm();
|
const [form] = Form.useForm<Record<string, unknown>>();
|
||||||
const [inquiryForm] = Form.useForm();
|
const [inquiryForm] = Form.useForm<Record<string, unknown>>();
|
||||||
const query = useQuery({
|
const query = useQuery({
|
||||||
queryKey: ["admin-workspace"],
|
queryKey: ["admin-workspace"],
|
||||||
queryFn: () => client.getAdminWorkspace(),
|
queryFn: () => client.getAdminWorkspace(),
|
||||||
@@ -222,9 +222,9 @@ export function WorkspacePage() {
|
|||||||
render: (value, item: BrandModule) => (
|
render: (value, item: BrandModule) => (
|
||||||
<Select
|
<Select
|
||||||
size="small"
|
size="small"
|
||||||
value={value}
|
value={Boolean(value)}
|
||||||
onChange={(next) =>
|
onChange={(next) =>
|
||||||
updateModule.mutate({ id: item.id, body: { isEnabled: next } })
|
updateModule.mutate({ id: item.id, body: { isEnabled: Boolean(next) } })
|
||||||
}
|
}
|
||||||
options={[
|
options={[
|
||||||
{ value: true, label: "启用" },
|
{ value: true, label: "启用" },
|
||||||
@@ -240,7 +240,7 @@ export function WorkspacePage() {
|
|||||||
<Input
|
<Input
|
||||||
size="small"
|
size="small"
|
||||||
type="number"
|
type="number"
|
||||||
defaultValue={value}
|
defaultValue={Number(value)}
|
||||||
onBlur={(event) =>
|
onBlur={(event) =>
|
||||||
updateModule.mutate({
|
updateModule.mutate({
|
||||||
id: item.id,
|
id: item.id,
|
||||||
@@ -299,10 +299,10 @@ export function WorkspacePage() {
|
|||||||
onFinish={(values) =>
|
onFinish={(values) =>
|
||||||
createField.mutate({
|
createField.mutate({
|
||||||
...values,
|
...values,
|
||||||
required: values.required ?? false,
|
required: Boolean(values.required),
|
||||||
isVisible: true,
|
isVisible: true,
|
||||||
sortOrder: 99,
|
sortOrder: 99,
|
||||||
})
|
} as Omit<BrandFieldDefinition, "id" | "source">)
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
<Form.Item name="scope" label="作用域" rules={[{ required: true }]}>
|
<Form.Item name="scope" label="作用域" rules={[{ required: true }]}>
|
||||||
@@ -355,7 +355,16 @@ export function WorkspacePage() {
|
|||||||
onOk={() => inquiryForm.submit()}
|
onOk={() => inquiryForm.submit()}
|
||||||
confirmLoading={createForm.isPending}
|
confirmLoading={createForm.isPending}
|
||||||
>
|
>
|
||||||
<Form form={inquiryForm} layout="vertical" onFinish={(values) => createForm.mutate(values)}>
|
<Form
|
||||||
|
form={inquiryForm}
|
||||||
|
layout="vertical"
|
||||||
|
onFinish={(values) =>
|
||||||
|
createForm.mutate({
|
||||||
|
name: typeof values.name === "string" ? values.name : "",
|
||||||
|
fieldsSnapshot: Array.isArray(values.fieldsSnapshot) ? values.fieldsSnapshot : [],
|
||||||
|
})
|
||||||
|
}
|
||||||
|
>
|
||||||
<Form.Item name="name" label="表单名称" rules={[{ required: true }]}>
|
<Form.Item name="name" label="表单名称" rules={[{ required: true }]}>
|
||||||
<Input placeholder="例如:合作咨询" />
|
<Input placeholder="例如:合作咨询" />
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
|
|||||||
@@ -34,6 +34,7 @@ export interface PublicService {
|
|||||||
priceText: string | null;
|
priceText: string | null;
|
||||||
priceAmount: number | null;
|
priceAmount: number | null;
|
||||||
bookingEnabled: boolean;
|
bookingEnabled: boolean;
|
||||||
|
isEnabled?: boolean;
|
||||||
categoryKey?: string;
|
categoryKey?: string;
|
||||||
config?: Record<string, unknown> | null;
|
config?: Record<string, unknown> | null;
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user