first commit
This commit is contained in:
commit
0e854110d3
49 files changed
+2292
No files matched your search
@@ -0,0 +1,25 @@
|
||||
import { useEffect, useMemo, useState } from "react";
|
||||
import { api, type AnatomicalSystem, type Structure } from "../lib/api.js";
|
||||
|
||||
export function useSystems() {
|
||||
const [systems, setSystems] = useState<AnatomicalSystem[]>([]);
|
||||
useEffect(() => {
|
||||
api.systems().then(setSystems).catch(console.error);
|
||||
}, []);
|
||||
return systems;
|
||||
}
|
||||
|
||||
export function useAllStructures() {
|
||||
const [structures, setStructures] = useState<Structure[]>([]);
|
||||
useEffect(() => {
|
||||
api.structures().then(setStructures).catch(console.error);
|
||||
}, []);
|
||||
|
||||
const bySlug = useMemo(() => {
|
||||
const map = new Map<string, Structure>();
|
||||
for (const s of structures) map.set(s.slug, s);
|
||||
return map;
|
||||
}, [structures]);
|
||||
|
||||
return { structures, bySlug };
|
||||
}
|
||||
Reference in new issue
Block a user