Skip to content

Commit

Permalink
set the data store for all CREs all at once
Browse files Browse the repository at this point in the history
  • Loading branch information
dlicheva committed Jul 31, 2024
1 parent 8f02d47 commit ce53ed6
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions application/frontend/src/providers/DataProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -91,14 +91,13 @@ export const DataProvider = ({ children }: { children: React.ReactNode }) => {
async () => {
if (!Object.keys(dataStore).length) {
try {
const result = await axios.get(`${apiUrl}/all_cres`);
const result = await axios.get(`${apiUrl}/all_cres?page=1&per_page=1000`);
let data = result.data.data;
const page = result.data.page;
const total_pages = result.data.total_pages;
let store = {};

if (data.length && total_pages && page) {
for (let p = page; p < total_pages; p++) {
data.forEach((x) => {
store[getStoreKey(x)] = {
links: x.links,
Expand All @@ -107,9 +106,7 @@ export const DataProvider = ({ children }: { children: React.ReactNode }) => {
...x,
};
});
const result = await axios.get(`${apiUrl}/all_cres?page=${p}`);
data = result.data.data;
}

setLocalStorageObject(DATA_STORE_KEY, store, TWO_DAYS_MILLISECONDS);
setDataStore(store);
console.log('retrieved all cres');
Expand Down

0 comments on commit ce53ed6

Please sign in to comment.