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:
Arthur Bassi 2026-08-19 14:48:04 -03:00
parent 2c14b08945
commit 8ab56d9782

View file

@ -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}
/>
);
}