Locations can now be drag-dropped around
This commit is contained in:
@@ -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]);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user