forked from mirrors/homebox
move to nuxt
This commit is contained in:
parent
890eb55d27
commit
26ecb5a9d4
93 changed files with 5273 additions and 4749 deletions
37
frontend/lib/api/classes/locations.ts
Normal file
37
frontend/lib/api/classes/locations.ts
Normal file
|
@ -0,0 +1,37 @@
|
|||
import { BaseAPI, UrlBuilder } from '../base';
|
||||
import { type Results } from '../base/base-types';
|
||||
|
||||
export type LocationCreate = {
|
||||
name: string;
|
||||
description: string;
|
||||
};
|
||||
|
||||
export type Location = LocationCreate & {
|
||||
id: string;
|
||||
groupId: string;
|
||||
createdAt: string;
|
||||
updatedAt: string;
|
||||
};
|
||||
|
||||
export type LocationUpdate = LocationCreate;
|
||||
|
||||
export class LocationsApi extends BaseAPI {
|
||||
async getAll() {
|
||||
return this.http.get<Results<Location>>(UrlBuilder('/locations'));
|
||||
}
|
||||
|
||||
async create(location: LocationCreate) {
|
||||
return this.http.post<LocationCreate, Location>(UrlBuilder('/locations'), location);
|
||||
}
|
||||
|
||||
async get(id: string) {
|
||||
return this.http.get<Location>(UrlBuilder(`/locations/${id}`));
|
||||
}
|
||||
async delete(id: string) {
|
||||
return this.http.delete<void>(UrlBuilder(`/locations/${id}`));
|
||||
}
|
||||
|
||||
async update(id: string, location: LocationUpdate) {
|
||||
return this.http.put<LocationUpdate, Location>(UrlBuilder(`/locations/${id}`), location);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue