Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cu 86bz9q0gr save unique to golden record fields to local storage #265

Merged
Show file tree
Hide file tree
Changes from 15 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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