refactor(intake): extract product patent domain

This commit is contained in:
WuYongJie 2026-06-09 15:51:25 +08:00
parent b02bb244ec
commit bc945b3328
2 changed files with 129 additions and 38 deletions

View File

@ -7,7 +7,6 @@ import type {
ChangeEvent,
ClipboardEvent,
CompositionEvent,
ComponentType,
} from "react";
import {
Fragment,
@ -48,8 +47,14 @@ import { DocumentAttachmentWorkspace } from "./DocumentAttachmentWorkspace";
import { FirstQualityWorkspace } from "./FirstQualityWorkspace";
import { InstallationWorkspace } from "./InstallationWorkspace";
import { OpeningReferenceWorkspace } from "./OpeningReferenceWorkspace";
import { PatentApplicationWorkspace } from "./PatentApplicationWorkspace";
import { PlanningLayoutWorkspace } from "./PlanningLayoutWorkspace";
import {
ProductPatentApplicationDomain,
ProductPatentLedgerDomain,
type LinkEntryProductPatentDashboardComponent,
type LinkEntryProductPatentDashboardUser,
type ProductPatentLedgerTarget,
} from "./ProductPatentDomain";
import { ProductLimitWorkspace } from "./ProductLimitWorkspace";
import { ProductPricingWorkspace } from "./ProductPricingWorkspace";
import { ProjectReviewWorkspace } from "./ProjectReviewWorkspace";
@ -803,14 +808,6 @@ import {
} from "@/lib/open-product/platform-view";
type DocumentWorkspaceView = "detail" | "document";
type ProductPatentLedgerTarget = {
productId?: string;
patentGroupKey?: string;
applicationNo?: string;
patentNo?: string;
spu?: string;
patentName?: string;
};
type LinkEntryWorkspaceTab =
| {
id: string;
@ -824,22 +821,6 @@ type LinkEntryWorkspaceTab =
label: string;
target: ProductPatentLedgerTarget;
};
type LinkEntryProductPatentDashboardUser = {
id: string;
name: string;
email: string;
role: string;
businessRoles?: string[];
departmentPaths?: string[];
avatar: string | null;
department: { id: string; name: string } | null;
};
type LinkEntryProductPatentDashboardComponent = ComponentType<{
products: NonIntegratedProductRecord[];
user: LinkEntryProductPatentDashboardUser;
target?: ProductPatentLedgerTarget;
readOnly?: boolean;
}>;
type InstallationStyleEntry = {
key: string;
label: string;
@ -18599,7 +18580,7 @@ export default function NonIntegratedDetailClient({
}
function renderPatentApplicationWorkspace() {
return (
<PatentApplicationWorkspace
<ProductPatentApplicationDomain
patentApplication={patentApplication}
openingReference={openingReference}
formSpu={formValues.spu}
@ -19306,20 +19287,12 @@ export default function NonIntegratedDetailClient({
);
}
if (!LinkEntryProductPatentDashboard) {
return (
<div className="flex h-full min-h-0 items-center justify-center rounded-apple-xl border border-apple-separator bg-apple-bg-primary text-sm text-apple-label-secondary shadow-apple-xs">
正在打开产品专利明细...
</div>
);
}
return (
<LinkEntryProductPatentDashboard
products={existingProduct ? [existingProduct] : []}
<ProductPatentLedgerDomain
dashboard={LinkEntryProductPatentDashboard}
product={existingProduct}
user={linkEntryProductPatentDashboardUser}
target={tab.target}
readOnly
/>
);
}

View File

@ -0,0 +1,118 @@
"use client";
import type { ComponentType, ReactNode } from "react";
import type { PatentApplicationFieldKey } from "./openingReferenceHelpers";
import type {
NonIntegratedOpeningReference,
NonIntegratedPatentApplication,
NonIntegratedProductRecord,
} from "./nonIntegratedStorage";
import { PatentApplicationWorkspace } from "./PatentApplicationWorkspace";
export type ProductPatentLedgerTarget = {
productId?: string;
patentGroupKey?: string;
applicationNo?: string;
patentNo?: string;
spu?: string;
patentName?: string;
};
export type LinkEntryProductPatentDashboardUser = {
id: string;
name: string;
email: string;
role: string;
businessRoles?: string[];
departmentPaths?: string[];
avatar: string | null;
department: { id: string; name: string } | null;
};
export type LinkEntryProductPatentDashboardComponent = ComponentType<{
products: NonIntegratedProductRecord[];
user: LinkEntryProductPatentDashboardUser;
target?: ProductPatentLedgerTarget;
readOnly?: boolean;
}>;
type ProductPatentApplicationDomainProps = {
patentApplication: NonIntegratedPatentApplication;
openingReference: NonIntegratedOpeningReference;
formSpu: string;
formDesigner: string;
copiedFromSpu?: string;
currentProductDisplayName: string;
sharedProductImage: string;
sharedProductImageName: string;
isReadOnly: boolean;
confirmationAction: ReactNode;
onFieldChange: (field: PatentApplicationFieldKey, value: string) => void;
onPreviewImage: (src: string, alt: string) => void;
onOpenLedger: () => void;
};
type ProductPatentLedgerDomainProps = {
dashboard: LinkEntryProductPatentDashboardComponent | null;
product: NonIntegratedProductRecord | null;
user: LinkEntryProductPatentDashboardUser;
target: ProductPatentLedgerTarget;
};
export function ProductPatentApplicationDomain({
patentApplication,
openingReference,
formSpu,
formDesigner,
copiedFromSpu,
currentProductDisplayName,
sharedProductImage,
sharedProductImageName,
isReadOnly,
confirmationAction,
onFieldChange,
onPreviewImage,
onOpenLedger,
}: ProductPatentApplicationDomainProps) {
return (
<PatentApplicationWorkspace
patentApplication={patentApplication}
openingReference={openingReference}
formSpu={formSpu}
formDesigner={formDesigner}
copiedFromSpu={copiedFromSpu}
currentProductDisplayName={currentProductDisplayName}
sharedProductImage={sharedProductImage}
sharedProductImageName={sharedProductImageName}
isReadOnly={isReadOnly}
confirmationAction={confirmationAction}
onFieldChange={onFieldChange}
onPreviewImage={onPreviewImage}
onOpenLedger={onOpenLedger}
/>
);
}
export function ProductPatentLedgerDomain({
dashboard: Dashboard,
product,
user,
target,
}: ProductPatentLedgerDomainProps) {
if (!Dashboard) {
return (
<div className="flex h-full min-h-0 items-center justify-center rounded-apple-xl border border-apple-separator bg-apple-bg-primary text-sm text-apple-label-secondary shadow-apple-xs">
正在打开产品专利明细...
</div>
);
}
return (
<Dashboard
products={product ? [product] : []}
user={user}
target={target}
readOnly
/>
);
}