-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Site Data Refactor to make similar to CustomerData and InventoryData (#…
…83) SiteData now uses entity adapters similar to customerData and inventoryData
- Loading branch information
1 parent
fdc58c9
commit 17e87c1
Showing
17 changed files
with
155 additions
and
114 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,18 @@ | ||
import { setCurrSite } from './siteDataSlice'; | ||
import { store } from './store'; | ||
import { createSelector } from '@reduxjs/toolkit'; | ||
import { SiteRecord } from '../airtable/interface'; | ||
import { setCurrentSiteId } from './siteDataSlice'; | ||
import { store, RootState } from './store'; | ||
|
||
const setCurrentSite = (newSite: any): void => { | ||
store.dispatch(setCurrSite(newSite)); | ||
export const setCurrentSite = (newSite: any): void => { | ||
store.dispatch(setCurrentSiteId(newSite.id)) | ||
}; | ||
|
||
const getCurrentSiteId = (): string => { | ||
return store.getState().siteData.currentSite.id; | ||
} | ||
export const selectCurrentSiteId = (state: RootState) => state.siteData.currentSiteId; | ||
|
||
export { setCurrentSite, getCurrentSiteId }; | ||
export const selectCurrentSiteInformation = createSelector( | ||
selectCurrentSiteId, | ||
store.getState, | ||
(siteId, state) => state.siteData.sites[siteId].siteInformation) | ||
|
||
// Returns all SiteRecord[] information | ||
export const selectAllSitesInformation = (state: RootState): SiteRecord[] => Object.values(state.siteData.sites).map(site => site.siteInformation); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.