-
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.
- Loading branch information
1 parent
be9c333
commit 86d3fde
Showing
23 changed files
with
592 additions
and
339 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
14 changes: 14 additions & 0 deletions
14
app/contexts/string-map-context/search-params-context-creator.ts
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,14 @@ | ||
import { createStringMapContext } from './context-creator'; | ||
import { NameIdStringTuple } from '../../api/dtos/NameIdStringTupleSchema'; | ||
import { useContext } from 'react'; | ||
|
||
export const { | ||
mapContext: SearchParamsContext, | ||
dispatchContext: SearchParamsDispatchContext | ||
} = createStringMapContext<NameIdStringTuple>(); | ||
|
||
export function useSearchParamsContext() { | ||
const searchParamsMap = useContext(SearchParamsContext); | ||
const dispatchSearchParams = useContext(SearchParamsDispatchContext); | ||
return { searchParamsMap, dispatchSearchParams }; | ||
} |
20 changes: 20 additions & 0 deletions
20
app/contexts/string-map-context/search-params-context-provider.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,20 @@ | ||
import { PropsWithChildren } from 'react'; | ||
import { StringMapContextProvider } from './string-map-context-provider'; | ||
import { ObjectPlaceholder } from '../../generic/components/selective-context/selective-context-manager-function'; | ||
import { | ||
SearchParamsContext, | ||
SearchParamsDispatchContext | ||
} from './search-params-context-creator'; | ||
import { NameIdStringTuple } from '../../api/dtos/NameIdStringTupleSchema'; | ||
import { AccessorFunction } from '../../generic/components/tables/rating/rating-table'; | ||
|
||
const Provider = StringMapContextProvider<NameIdStringTuple> | ||
|
||
const KeyAccessor: AccessorFunction<NameIdStringTuple, string> = tuple => tuple.id | ||
export default function SearchParamsContextProvider({children}:PropsWithChildren) { | ||
return ( | ||
<Provider initialEntityMap={ObjectPlaceholder} mapContext={SearchParamsContext} dispatchContext={SearchParamsDispatchContext} mapKeyAccessor={KeyAccessor}> | ||
{children} | ||
</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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
'use client'; | ||
import { Dispatch, useReducer } from 'react'; | ||
import { Draft, produce } from 'immer'; | ||
|
||
|
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.