Added GroupProvider

This commit is contained in:
Sebastian Seedorf
2022-08-10 15:58:03 +02:00
parent 8dfc844c24
commit e4250f0344
6 changed files with 208 additions and 126 deletions

View File

@@ -21,7 +21,7 @@ export function useLocalStorage<T>(key: string, initialValue: T): [T, SetValue<T
// Get from local storage then
// parse stored json or return initialValue
const readValue = useCallback((): T => {
// Prevent build error "window is undefined" but keep keep working
// Prevent build error "window is undefined" but keep working
if (typeof window === 'undefined') {
return initialValue
}
@@ -88,7 +88,9 @@ export function useLocalStorage<T>(key: string, initialValue: T): [T, SetValue<T
// See: useLocalStorage()
useEventListener('local-storage', handleStorageChange)
return [storedValue, setValue]
const [clientStoredValue, setClientStoredValue] = useState<T>(initialValue)
useEffect(() => setClientStoredValue(storedValue), [storedValue])
return [clientStoredValue, setValue]
}
// A wrapper for "JSON.parse()"" to support "undefined" value

View File

@@ -14,10 +14,20 @@ export interface Entity extends UnfetchedEntity {
recipe?: Recipe
}
export interface Group {
export type Group = OldGroup|NewGroup
export interface OldGroup {
name: string
isExported?: boolean
factories: string[]
intermediates: string[]
inputs: string[]
}
export interface NewGroup {
name: string
inputs: string[]
intermediates: string[]
exports: string[]
malls: string[]
}