forked from jappel/leistungsbilanz-ts
Added power sum per distributionboard
This commit is contained in:
parent
245a5b1485
commit
81d47ce16f
9 changed files with 501 additions and 31 deletions
|
|
@ -3,6 +3,7 @@ import type {
|
|||
CreateConsumerInput,
|
||||
DistributionBoardDto,
|
||||
ProjectDto,
|
||||
UpdateConsumerInput,
|
||||
} from "../types";
|
||||
|
||||
async function request<T>(url: string, init?: RequestInit): Promise<T> {
|
||||
|
|
@ -54,3 +55,18 @@ export function createConsumer(input: CreateConsumerInput) {
|
|||
body: JSON.stringify(input),
|
||||
});
|
||||
}
|
||||
|
||||
export function updateConsumer(consumerId: string, input: UpdateConsumerInput) {
|
||||
return request<ConsumerWithCalculatedValues>(`/api/consumers/${consumerId}`, {
|
||||
method: "PUT",
|
||||
body: JSON.stringify(input),
|
||||
});
|
||||
}
|
||||
|
||||
export async function deleteConsumer(consumerId: string) {
|
||||
const response = await fetch(`/api/consumers/${consumerId}`, { method: "DELETE" });
|
||||
if (!response.ok) {
|
||||
const details = await response.text();
|
||||
throw new Error(details || `Request failed with ${response.status}`);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue