Recipe-app main
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
export type Product = {
|
||||
id: number;
|
||||
name: string;
|
||||
normalizedName: string;
|
||||
category: string | null;
|
||||
createdAt: string;
|
||||
updatedAt: string;
|
||||
};
|
||||
|
||||
export type InventoryItem = {
|
||||
id: number;
|
||||
productId: number;
|
||||
quantity: string;
|
||||
unit: string;
|
||||
location: string | null;
|
||||
priority: number | null;
|
||||
purchaseDate: string | null;
|
||||
opened: boolean | null;
|
||||
shelfNote: string | null;
|
||||
suitableFor: string | null;
|
||||
isOnSale: boolean | null;
|
||||
priceLevel: number | null;
|
||||
weeksRemaining: number | null;
|
||||
proteinType: string | null;
|
||||
isLeftover: boolean | null;
|
||||
comment: string | null;
|
||||
createdAt: string;
|
||||
updatedAt: string;
|
||||
product: Product;
|
||||
};
|
||||
@@ -0,0 +1,22 @@
|
||||
const API_BASE =
|
||||
process.env.NEXT_PUBLIC_API_URL_INTERNAL || 'http://recipe-api:8080';
|
||||
|
||||
export async function fetchJson<T>(path: string, init?: RequestInit): Promise<T> {
|
||||
const res = await fetch(`${API_BASE}${path}`, {
|
||||
...init,
|
||||
cache: 'no-store',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
...(init?.headers || {}),
|
||||
},
|
||||
});
|
||||
|
||||
if (!res.ok) {
|
||||
const text = await res.text();
|
||||
throw new Error(`API ${res.status}: ${text}`);
|
||||
}
|
||||
|
||||
return res.json();
|
||||
}
|
||||
|
||||
export { API_BASE };
|
||||
Reference in New Issue
Block a user