Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Austenem/CAT-754 Refactor my lists #3668

Closed
wants to merge 16 commits into from
Prev Previous commit
Next Next commit
move logic to hooks
  • Loading branch information
austenem committed Jan 16, 2025
commit b0c654f64eccb6394a663fd1567273c8ec518cbf
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ const savedEntitiiesStoreInitializer: StoreInitializer = (set, get) => ({
set((state) => {
state.savedEntities = entities;
}),
setLists: (lists) =>
set((state) => {
state.savedLists = lists;
}),
saveEntity: (entityUUID) =>
!(entityUUID in get().savedEntities) &&
set((state) => {
Expand All @@ -35,13 +39,17 @@ const savedEntitiiesStoreInitializer: StoreInitializer = (set, get) => ({
createList: ({ title, description }) => {
const uuid = uuidv4();
set((state) => {
state.savedLists[uuid] = {
// the Donor, Sample, and Datasets are objects to avoid duplicates. Normally they would be sets, but objects work better with local storage
title,
savedEntities: {},
description,
dateSaved: Date.now(),
dateLastModified: Date.now(),
return {
savedLists: {
...state.savedLists,
[uuid]: {
title,
savedEntities: {},
description,
dateSaved: Date.now(),
dateLastModified: Date.now(),
},
},
};
});
},
Expand Down
Loading