From 95f0529e46c08bb0b4cc8c0ac0f31610f3d82f16 Mon Sep 17 00:00:00 2001 From: Bethany Dunfield Date: Mon, 13 May 2024 15:43:50 -0600 Subject: [PATCH] Update useDatastore to return more accurate values and count --- src/services/useDatastore/useDatastore.jsx | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/services/useDatastore/useDatastore.jsx b/src/services/useDatastore/useDatastore.jsx index 56125195..701f6dcc 100644 --- a/src/services/useDatastore/useDatastore.jsx +++ b/src/services/useDatastore/useDatastore.jsx @@ -10,12 +10,9 @@ const useDatastore = ( ) => { const keys = options.keys ? options.keys : true; const { prepareColumns } = options; - - const [values, setValues] = useState([]); const [id, setResource] = useState(resourceId); const [rootUrl, setRootUrl] = useState(rootAPIUrl); const [limit, setLimit] = useState(options.limit ? options.limit : 20); - const [count, setCount] = useState(null); const [columns, setColumns] = useState([]); const [offset, setOffset] = useState(options.offset ? options.offset : 0); const [conditions, setConditions] = useState( @@ -67,7 +64,6 @@ const useDatastore = ( data.schema && data.schema[id] && data.schema[id].fields ? Object.keys(data.schema[id].fields) : []; - setValues(data.results), setCount(data.count); if (propertyKeys.length) { setColumns(prepareColumns ? prepareColumns(propertyKeys) : propertyKeys); } @@ -79,8 +75,8 @@ const useDatastore = ( return { loading: enabled ? isPending : false, - values, - count, + values: data ? data.results : undefined, + count: data ? data.count : null, columns, limit, offset,