|
@@ -0,0 +1,20 @@
|
|
|
+import { useEffect, useState } from "react";
|
|
|
+import { getGenerators } from "../domain/apiMethods";
|
|
|
+
|
|
|
+
|
|
|
+const useAvailableGenerators = () => {
|
|
|
+ const [state, setState] = useState(null);
|
|
|
+
|
|
|
+ useEffect(() => {
|
|
|
+ const lookup = async() => {
|
|
|
+ const { generators } = await getGenerators();
|
|
|
+ const generatorMap = Object.fromEntries(generators.map(({ generationMethod, countryLocks }) => [generationMethod, countryLocks]));
|
|
|
+ setState(generatorMap);
|
|
|
+ }
|
|
|
+ lookup();
|
|
|
+ }, []);
|
|
|
+
|
|
|
+ return state;
|
|
|
+};
|
|
|
+
|
|
|
+export default useAvailableGenerators;
|