diff --git a/web/frontend/src/App.svelte b/web/frontend/src/App.svelte index dd23da9..5ad3c0c 100644 --- a/web/frontend/src/App.svelte +++ b/web/frontend/src/App.svelte @@ -1,27 +1,16 @@ + + diff --git a/web/frontend/src/lib/RestAPI.svelte.ts b/web/frontend/src/lib/RestAPI.svelte.ts new file mode 100644 index 0000000..280d642 --- /dev/null +++ b/web/frontend/src/lib/RestAPI.svelte.ts @@ -0,0 +1,26 @@ +export async function createResource( + endpoint: string, + data: T, +): Promise { + return fetch(endpoint, { + method: "POST", + headers: { "Content-Type": "application/json" }, + body: JSON.stringify(data), + }); +} + +export async function updateResource( + endpoint: string, + data: T, +): Promise { + return fetch(endpoint, { + method: "PUT", // or 'PATCH' + headers: { "Content-Type": "application/json" }, + body: JSON.stringify(data), + }); +} + +export async function fetchData(endpoint: string, data: T) { + const res = await fetch("http://localhost:8080/api/" + endpoint); + data = await res.json(); +} diff --git a/web/frontend/src/lib/RetailerForm.svelte b/web/frontend/src/lib/RetailerForm.svelte new file mode 100644 index 0000000..366e20e --- /dev/null +++ b/web/frontend/src/lib/RetailerForm.svelte @@ -0,0 +1,52 @@ + + + diff --git a/web/frontend/tsconfig.app.json b/web/frontend/tsconfig.app.json index 55a2f9b..667f6c4 100644 --- a/web/frontend/tsconfig.app.json +++ b/web/frontend/tsconfig.app.json @@ -3,6 +3,7 @@ "compilerOptions": { "target": "ESNext", "useDefineForClassFields": true, + "allowImportingTsExtensions": true, "module": "ESNext", "resolveJsonModule": true, /** diff --git a/web/frontend/tsconfig.node.json b/web/frontend/tsconfig.node.json index 9728af2..8fe989c 100644 --- a/web/frontend/tsconfig.node.json +++ b/web/frontend/tsconfig.node.json @@ -4,6 +4,7 @@ "target": "ES2022", "lib": ["ES2023"], "module": "ESNext", + "composite": true, "skipLibCheck": true, /* Bundler mode */