-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[frontend] use context to prefill the dynamic entity mapping column (#…
…7400) Co-authored-by: Landry Trebon <[email protected]>
- Loading branch information
1 parent
00813e7
commit d79eff0
Showing
3 changed files
with
63 additions
and
20 deletions.
There are no files selected for viewing
27 changes: 27 additions & 0 deletions
27
opencti-platform/opencti-front/src/private/components/data/csvMapper/CsvMapperContext.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,27 @@ | ||
import React, { createContext, ReactNode, useContext, useState } from 'react'; | ||
|
||
interface CsvMapperContextProps { | ||
dynamicMappingColumn: string | null; | ||
setDynamicMappingColumn: (index: string) => void; | ||
} | ||
|
||
interface CsvMapperProviderProps { | ||
children: ReactNode; | ||
} | ||
|
||
const CsvMapperContext = createContext<CsvMapperContextProps | undefined>(undefined); | ||
export const CsvMapperProvider: React.FC<CsvMapperProviderProps> = ({ children }) => { | ||
const [dynamicMappingColumn, setDynamicMappingColumn] = useState<string | null>(null); | ||
return ( | ||
<CsvMapperContext.Provider value={{ dynamicMappingColumn, setDynamicMappingColumn }}> | ||
{children} | ||
</CsvMapperContext.Provider> | ||
); | ||
}; | ||
export const useCsvMapperContext = () => { | ||
const context = useContext(CsvMapperContext); | ||
if (!context) { | ||
throw new Error('useCsvMapperContext must be used within a CsvMapperProvider'); | ||
} | ||
return context; | ||
}; |
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