-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #105 from sainingo/main
Add multi-locations select functionality
- Loading branch information
Showing
6 changed files
with
109 additions
and
50 deletions.
There are no files selected for viewing
31 changes: 31 additions & 0 deletions
31
packages/esm-report-app/src/hooks/useSelectedLocations.tsx
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 |
---|---|---|
@@ -0,0 +1,31 @@ | ||
// eslint-disable-next-line @typescript-eslint/consistent-type-imports | ||
import React, { createContext, useContext, useState, ReactNode, FC } from 'react'; | ||
|
||
interface SelectedLocationsContextType { | ||
selectedLocations: any; | ||
setSelectedLocations: React.Dispatch<React.SetStateAction<any>>; | ||
} | ||
|
||
const SelectedLocationsContext = createContext<SelectedLocationsContextType | undefined>(undefined); | ||
|
||
export const useSelectedLocations = (): SelectedLocationsContextType => { | ||
const context = useContext(SelectedLocationsContext); | ||
if (!context) { | ||
throw new Error('useSelectedLocations must be used within a SelectedLocationsProvider'); | ||
} | ||
return context; | ||
}; | ||
|
||
interface SelectedLocationsProviderProps { | ||
children: ReactNode; | ||
} | ||
|
||
export const SelectedLocationsProvider: FC<SelectedLocationsProviderProps> = ({ children }) => { | ||
const [selectedLocations, setSelectedLocations] = useState<any>(); | ||
|
||
return ( | ||
<SelectedLocationsContext.Provider value={{ selectedLocations, setSelectedLocations }}> | ||
{children} | ||
</SelectedLocationsContext.Provider> | ||
); | ||
}; |
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,5 +1,14 @@ | ||
{ | ||
"extends": "../../tsconfig.json", | ||
"include": ["src/**/*"], | ||
"exclude": ["src/**/*.test.tsx"] | ||
"compilerOptions": { | ||
"jsx": "react", | ||
"esModuleInterop": true, | ||
"skipLibCheck": true | ||
}, | ||
"include": [ | ||
"src/**/*" | ||
], | ||
"exclude": [ | ||
"src/**/*.test.tsx" | ||
] | ||
} |