mirror of
https://github.com/Sea-Haven-Industries/shoc-frontend-new.git
synced 2026-10-07 06:59:01 +00:00
refactor(vendor-portal): extract document row from VendorPortalDocuments
The changed-file maintainability gate caps functions at 150 lines; VendorPortalDocuments reached 156. Move the per-document row into VendorPortalDocumentRow with no behavior change.
This commit is contained in:
parent
6012ebabe7
commit
d573ab59a9
1 changed files with 66 additions and 39 deletions
|
|
@ -21,6 +21,64 @@ type VendorPortalDocumentsProps = {
|
||||||
onChanged: () => Promise<void>;
|
onChanged: () => Promise<void>;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
type VendorPortalDocumentRowProps = {
|
||||||
|
document: VendorPortalDocument;
|
||||||
|
locked: boolean;
|
||||||
|
uploading: boolean;
|
||||||
|
onDownload: () => void;
|
||||||
|
onReplace: () => void;
|
||||||
|
};
|
||||||
|
|
||||||
|
function VendorPortalDocumentRow({
|
||||||
|
document,
|
||||||
|
locked,
|
||||||
|
uploading,
|
||||||
|
onDownload,
|
||||||
|
onReplace,
|
||||||
|
}: VendorPortalDocumentRowProps) {
|
||||||
|
return (
|
||||||
|
<article className="vp-uplift-row">
|
||||||
|
<div className="vp-row">
|
||||||
|
<strong>File</strong>
|
||||||
|
<span>
|
||||||
|
{document.originalFileName} · v{document.version}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
<div className="vp-row">
|
||||||
|
<strong>Security scan</strong>
|
||||||
|
<span>{document.scanStatus}</span>
|
||||||
|
</div>
|
||||||
|
<div className="vp-row">
|
||||||
|
<strong>Review</strong>
|
||||||
|
<span>{document.reviewStatus}</span>
|
||||||
|
</div>
|
||||||
|
{Boolean(document.rejectionReason) && (
|
||||||
|
<VendorPortalFeedback tone="error">{document.rejectionReason}</VendorPortalFeedback>
|
||||||
|
)}
|
||||||
|
<div className="vp-actions">
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
className="vp-btn vp-btn-ghost"
|
||||||
|
disabled={!document.canDownload}
|
||||||
|
onClick={onDownload}
|
||||||
|
>
|
||||||
|
{document.canDownload ? "Download" : "Quarantined"}
|
||||||
|
</button>
|
||||||
|
{!locked && (
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
className="vp-btn vp-btn-ghost"
|
||||||
|
disabled={uploading}
|
||||||
|
onClick={onReplace}
|
||||||
|
>
|
||||||
|
Replace
|
||||||
|
</button>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
</article>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
type UploadRequest = {
|
type UploadRequest = {
|
||||||
file: File;
|
file: File;
|
||||||
replacementId?: number;
|
replacementId?: number;
|
||||||
|
|
@ -112,45 +170,14 @@ export function VendorPortalDocuments({
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{documents.map((document) => (
|
{documents.map((document) => (
|
||||||
<article key={document.id} className="vp-uplift-row">
|
<VendorPortalDocumentRow
|
||||||
<div className="vp-row">
|
key={document.id}
|
||||||
<strong>File</strong>
|
document={document}
|
||||||
<span>
|
locked={locked}
|
||||||
{document.originalFileName} · v{document.version}
|
uploading={uploadMutation.isPending}
|
||||||
</span>
|
onDownload={() => void vendorPortalApi.downloadDocument(token, dispatchId, document)}
|
||||||
</div>
|
onReplace={() => chooseFile(document.id)}
|
||||||
<div className="vp-row">
|
/>
|
||||||
<strong>Security scan</strong>
|
|
||||||
<span>{document.scanStatus}</span>
|
|
||||||
</div>
|
|
||||||
<div className="vp-row">
|
|
||||||
<strong>Review</strong>
|
|
||||||
<span>{document.reviewStatus}</span>
|
|
||||||
</div>
|
|
||||||
{Boolean(document.rejectionReason) && (
|
|
||||||
<VendorPortalFeedback tone="error">{document.rejectionReason}</VendorPortalFeedback>
|
|
||||||
)}
|
|
||||||
<div className="vp-actions">
|
|
||||||
<button
|
|
||||||
type="button"
|
|
||||||
className="vp-btn vp-btn-ghost"
|
|
||||||
disabled={!document.canDownload}
|
|
||||||
onClick={() => void vendorPortalApi.downloadDocument(token, dispatchId, document)}
|
|
||||||
>
|
|
||||||
{document.canDownload ? "Download" : "Quarantined"}
|
|
||||||
</button>
|
|
||||||
{!locked && (
|
|
||||||
<button
|
|
||||||
type="button"
|
|
||||||
className="vp-btn vp-btn-ghost"
|
|
||||||
disabled={uploadMutation.isPending}
|
|
||||||
onClick={() => chooseFile(document.id)}
|
|
||||||
>
|
|
||||||
Replace
|
|
||||||
</button>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
</article>
|
|
||||||
))}
|
))}
|
||||||
|
|
||||||
{progress !== undefined && (
|
{progress !== undefined && (
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue