Added reading and using of spool orders in locations
This commit is contained in:
@@ -19,21 +19,6 @@ 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]);
|
||||
}
|
||||
|
||||
export async function renameSpoolLocation(location: string, newName: string): Promise<string> {
|
||||
const response = await fetch(getAPIURL() + "/location/" + location, {
|
||||
method: "PATCH",
|
||||
@@ -49,3 +34,33 @@ export async function renameSpoolLocation(location: string, newName: string): Pr
|
||||
}
|
||||
return await response.text();
|
||||
}
|
||||
|
||||
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]);
|
||||
}
|
||||
|
||||
export function useLocationsSpoolOrders(): Record<string, number[]> {
|
||||
const query = useGetSetting("locations_spoolorders");
|
||||
|
||||
return useMemo(() => {
|
||||
if (!query.data) return {};
|
||||
|
||||
try {
|
||||
return JSON.parse(query.data.value) as Record<string, number[]>;
|
||||
} catch {
|
||||
console.warn("Failed to parse locations spool orders", query.data.value);
|
||||
return {};
|
||||
}
|
||||
}, [query.data]);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user