mirror of
https://github.com/Sea-Haven-Industries/shoc-frontend-new.git
synced 2026-10-01 13:13:11 +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;
|
||||
};
|
||||
|
||||
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({
|
||||
tableData,
|
||||
users,
|
||||
|
|
@ -125,12 +153,7 @@ export function WoTable({
|
|||
|
||||
if (tableData.isLoading) {
|
||||
return (
|
||||
<WoTableShell>
|
||||
<WoTableSkeleton
|
||||
weekMonday={weekMonday}
|
||||
selectedDayIso={tableData.displayGroups[0]?.date}
|
||||
/>
|
||||
</WoTableShell>
|
||||
<WoTableLoading weekMonday={weekMonday} selectedDayIso={tableData.displayGroups[0]?.date} />
|
||||
);
|
||||
}
|
||||
|
||||
|
|
@ -138,25 +161,21 @@ export function WoTable({
|
|||
|
||||
if (emptyAdv) {
|
||||
return (
|
||||
<WoTableShell>
|
||||
<WoTableEmptyState
|
||||
message="No work orders match these filters"
|
||||
actionLabel="Adjust filters"
|
||||
onAction={onOpenAdvancedFilters}
|
||||
/>
|
||||
</WoTableShell>
|
||||
<WoTableEmptyShell
|
||||
message="No work orders match these filters"
|
||||
actionLabel="Adjust filters"
|
||||
onAction={onOpenAdvancedFilters}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
if (!tableData.advActive && tableData.noSearchResults) {
|
||||
return (
|
||||
<WoTableShell>
|
||||
<WoTableEmptyState
|
||||
message="No work orders match your search"
|
||||
actionLabel="Clear search"
|
||||
onAction={onClearSearch}
|
||||
/>
|
||||
</WoTableShell>
|
||||
<WoTableEmptyShell
|
||||
message="No work orders match your search"
|
||||
actionLabel="Clear search"
|
||||
onAction={onClearSearch}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue