mirror of
https://github.com/Sea-Haven-Industries/shoc-frontend-new.git
synced 2026-10-06 17:02:05 +00:00
refactor(work-orders): extract WoTable loading and empty shells
Keep the list table under the changed-file function length gate.
This commit is contained in:
parent
2c14b08945
commit
8ab56d9782
1 changed files with 39 additions and 20 deletions
|
|
@ -40,6 +40,34 @@ type WoTableProps = {
|
||||||
onPatch: (id: string | number, patch: WorkOrderTablePatch) => void;
|
onPatch: (id: string | number, patch: WorkOrderTablePatch) => void;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
type WoTableEmptyShellProps = {
|
||||||
|
message: string;
|
||||||
|
actionLabel: string;
|
||||||
|
onAction?: () => void;
|
||||||
|
};
|
||||||
|
|
||||||
|
function WoTableLoading({
|
||||||
|
weekMonday,
|
||||||
|
selectedDayIso,
|
||||||
|
}: {
|
||||||
|
weekMonday: string;
|
||||||
|
selectedDayIso?: string;
|
||||||
|
}) {
|
||||||
|
return (
|
||||||
|
<WoTableShell>
|
||||||
|
<WoTableSkeleton weekMonday={weekMonday} selectedDayIso={selectedDayIso} />
|
||||||
|
</WoTableShell>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function WoTableEmptyShell({ message, actionLabel, onAction }: WoTableEmptyShellProps) {
|
||||||
|
return (
|
||||||
|
<WoTableShell>
|
||||||
|
<WoTableEmptyState message={message} actionLabel={actionLabel} onAction={onAction} />
|
||||||
|
</WoTableShell>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
export function WoTable({
|
export function WoTable({
|
||||||
tableData,
|
tableData,
|
||||||
users,
|
users,
|
||||||
|
|
@ -125,12 +153,7 @@ export function WoTable({
|
||||||
|
|
||||||
if (tableData.isLoading) {
|
if (tableData.isLoading) {
|
||||||
return (
|
return (
|
||||||
<WoTableShell>
|
<WoTableLoading weekMonday={weekMonday} selectedDayIso={tableData.displayGroups[0]?.date} />
|
||||||
<WoTableSkeleton
|
|
||||||
weekMonday={weekMonday}
|
|
||||||
selectedDayIso={tableData.displayGroups[0]?.date}
|
|
||||||
/>
|
|
||||||
</WoTableShell>
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -138,25 +161,21 @@ export function WoTable({
|
||||||
|
|
||||||
if (emptyAdv) {
|
if (emptyAdv) {
|
||||||
return (
|
return (
|
||||||
<WoTableShell>
|
<WoTableEmptyShell
|
||||||
<WoTableEmptyState
|
message="No work orders match these filters"
|
||||||
message="No work orders match these filters"
|
actionLabel="Adjust filters"
|
||||||
actionLabel="Adjust filters"
|
onAction={onOpenAdvancedFilters}
|
||||||
onAction={onOpenAdvancedFilters}
|
/>
|
||||||
/>
|
|
||||||
</WoTableShell>
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!tableData.advActive && tableData.noSearchResults) {
|
if (!tableData.advActive && tableData.noSearchResults) {
|
||||||
return (
|
return (
|
||||||
<WoTableShell>
|
<WoTableEmptyShell
|
||||||
<WoTableEmptyState
|
message="No work orders match your search"
|
||||||
message="No work orders match your search"
|
actionLabel="Clear search"
|
||||||
actionLabel="Clear search"
|
onAction={onClearSearch}
|
||||||
onAction={onClearSearch}
|
/>
|
||||||
/>
|
|
||||||
</WoTableShell>
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue