wedding-planner-frontend/app/api/tableSimulations.tsx

20 lines
581 B
TypeScript
Raw Permalink Normal View History

2024-11-17 16:00:30 +00:00
/* Copyright (C) 2024 Manuel Bustillo*/
2024-11-17 16:45:42 +01:00
import { TableArrangement } from '@/app/lib/definitions';
import { getSlug } from '../lib/utils';
2024-11-17 16:45:42 +01:00
export function loadTableSimulations(onLoad?: (tableSimulations: TableArrangement[]) => void) {
fetch(`/api/${getSlug()}/tables_arrangements`)
2024-11-17 16:45:42 +01:00
.then((response) => response.json())
.then((data) => {
onLoad && onLoad(data.map((record: any) => {
return ({
id: record.id,
name: record.name,
discomfort: record.discomfort,
});
}));
}, (error) => {
return [];
});
}