IO-1285 Resolve production not saving sort order.

This commit is contained in:
Patrick Fic
2021-08-04 09:30:53 -07:00
parent 5ecd5a5a5c
commit a5fe54164e
2 changed files with 21 additions and 4 deletions

View File

@@ -25,6 +25,7 @@ export function ProductionListTable({
currentUser,
state,
setColumns,
setState,
}) {
const { t } = useTranslation();
const [updateDefaultProdView] = useMutation(UPDATE_ACTIVE_PROD_LIST_VIEW);
@@ -43,6 +44,10 @@ export function ProductionListTable({
};
})
);
setState(
bodyshop.production_config.filter((pc) => pc.name === value)[0].columns
.tableState
);
const assoc = bodyshop.associations.find(
(a) => a.useremail === currentUser.email
@@ -77,6 +82,8 @@ export function ProductionListTable({
};
})
);
setState(bodyshop.production_config[0].columns.tableState);
};
return (

View File

@@ -38,17 +38,26 @@ export function ProductionListTable({
);
return assoc && assoc.default_prod_list_view;
}, [bodyshop.associations, currentUser.email]);
console.log(
"🚀 ~ file: production-list-table.component.jsx ~ line 41 ~ defaultView",
defaultView
);
const [state, setState] = useState(
(bodyshop.production_config &&
bodyshop.production_config.find((p) => p.name === defaultView)
?.tableState) ||
bodyshop.production_config[0]?.tableState || {
bodyshop.production_config.find((p) => p.name === defaultView)?.columns
.tableState) ||
bodyshop.production_config[0]?.columns.tableState || {
sortedInfo: {},
filteredInfo: { text: "" },
}
);
console.log(
"🚀 ~ file: production-list-table.component.jsx ~ line 51 ~ bodyshop.production_config",
bodyshop.production_config
);
console.log("state", state);
const { t } = useTranslation();
const matchingColumnConfig = useMemo(() => {
@@ -155,7 +164,7 @@ export function ProductionListTable({
// }
// };
if (!!!columns) return <div>No columns found.</div>;
if (!!!columns || columns.length === 0) return <div>No columns found.</div>;
return (
<div>
@@ -173,6 +182,7 @@ export function ProductionListTable({
<ProductionListTableViewSelect
state={state}
setState={setState}
setColumns={setColumns}
/>