Skip to content

Commit

Permalink
Merge pull request #265 from jembi/CU-86bz9q0gr_Save-Unique-to-Golden…
Browse files Browse the repository at this point in the history
…-Record-Fields-to-Local-Storage

Cu 86bz9q0gr save unique to golden record fields to local storage
  • Loading branch information
MatthewErispe authored Jul 10, 2024
2 parents 0cbd301 + dd8c301 commit a602f81
Show file tree
Hide file tree
Showing 5 changed files with 160 additions and 119 deletions.
22 changes: 7 additions & 15 deletions JeMPI_Apps/JeMPI_UI/src/hooks/useUIConfiguration.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,36 +14,28 @@ export interface UIConfigurationProviderProps {
children: React.ReactNode
}

export const ConfigurationContext = createContext<
ConfigurationContextType | undefined
>(undefined)
export const ConfigurationContext = createContext<ConfigurationContextType | undefined>(undefined)

export const useConfiguration = () => {
const context = useContext(ConfigurationContext)
if (!context) {
throw new Error(
'useConfiguration must be used within a ConfigurationProvider'
)
throw new Error('useConfiguration must be used within a ConfigurationProvider')
}
return context
}

export const ConfigurationProvider = ({
children
}: UIConfigurationProviderProps) => {
export const ConfigurationProvider = ({ children }: UIConfigurationProviderProps) => {
const { apiClient } = useConfig()
const { data, error, isLoading, isError } = useQuery<Configuration>({
queryKey: ['configuration'],
queryFn: () => apiClient.fetchConfiguration(),
refetchOnWindowFocus: false
})

const [configuration, setConfiguration] = useState<Configuration | null>(
() => {
const savedConfig = localStorage.getItem('configuration')
return savedConfig ? JSON.parse(savedConfig) : null
}
)
const [configuration, setConfiguration] = useState<Configuration | null>(() => {
const savedConfig = localStorage.getItem('configuration')
return savedConfig ? JSON.parse(savedConfig) : null
})

useEffect(() => {
if (data && !configuration) {
Expand Down
2 changes: 1 addition & 1 deletion JeMPI_Apps/JeMPI_UI/src/pages/settings/Settings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ const Settings = () => {
<Typography variant="h5" sx={{ py: 3 }}>
Setup properties for Golden record lists
</Typography>
<GoldenRecordLists goldenRecordList={[]}/>
<GoldenRecordLists/>
</CustomTabPanel>
<CustomTabPanel value={value} index={4}>
<Deterministic
Expand Down
Loading

0 comments on commit a602f81

Please sign in to comment.