Locations can now be drag-dropped around

This commit is contained in:
Donkie
2024-11-20 20:12:08 +01:00
parent 3dc0082f0e
commit 8d6f2636c5
2 changed files with 159 additions and 59 deletions

View File

@@ -1,3 +1,5 @@
import { useMemo } from "react";
import { useGetSetting } from "../../utils/querySettings";
import { getAPIURL } from "../../utils/url";
import { ISpool } from "../spools/model";
@@ -16,3 +18,18 @@ export async function setSpoolLocation(spool_id: number, location: string | null
}
return response.json();
}
export function useLocations(): string[] {
const query = useGetSetting("locations");
return useMemo(() => {
if (!query.data) return [];
try {
return JSON.parse(query.data.value) as string[];
} catch {
console.warn("Failed to parse locations", query.data.value);
return [];
}
}, [query.data]);
}