mirror of
https://github.com/hay-kot/homebox.git
synced 2025-05-27 23:52:32 +00:00
style updates
This commit is contained in:
parent
f4f7123073
commit
6bbe62823d
19 changed files with 337 additions and 107 deletions
54
frontend/lib/api/classes/items.ts
Normal file
54
frontend/lib/api/classes/items.ts
Normal file
|
@ -0,0 +1,54 @@
|
|||
import { BaseAPI, UrlBuilder } from '../base';
|
||||
import { Label } from './labels';
|
||||
import { Location } from './locations';
|
||||
import { Results } from './types';
|
||||
|
||||
export interface ItemCreate {
|
||||
name: string;
|
||||
description: string;
|
||||
locationId: string;
|
||||
labelIds: string[];
|
||||
}
|
||||
|
||||
export interface Item {
|
||||
createdAt: string;
|
||||
description: string;
|
||||
id: string;
|
||||
labels: Label[];
|
||||
location: Location;
|
||||
manufacturer: string;
|
||||
modelNumber: string;
|
||||
name: string;
|
||||
notes: string;
|
||||
purchaseFrom: string;
|
||||
purchasePrice: number;
|
||||
purchaseTime: string;
|
||||
serialNumber: string;
|
||||
soldNotes: string;
|
||||
soldPrice: number;
|
||||
soldTime: string;
|
||||
soldTo: string;
|
||||
updatedAt: string;
|
||||
}
|
||||
|
||||
export class ItemsApi extends BaseAPI {
|
||||
async getAll() {
|
||||
return this.http.get<Results<Item>>(UrlBuilder('/items'));
|
||||
}
|
||||
|
||||
async create(item: ItemCreate) {
|
||||
return this.http.post<ItemCreate, Item>(UrlBuilder('/items'), item);
|
||||
}
|
||||
|
||||
async get(id: string) {
|
||||
return this.http.get<Item>(UrlBuilder(`/items/${id}`));
|
||||
}
|
||||
|
||||
async delete(id: string) {
|
||||
return this.http.delete<void>(UrlBuilder(`/items/${id}`));
|
||||
}
|
||||
|
||||
async update(id: string, item: ItemCreate) {
|
||||
return this.http.put<ItemCreate, Item>(UrlBuilder(`/items/${id}`), item);
|
||||
}
|
||||
}
|
|
@ -1,4 +1,5 @@
|
|||
import { BaseAPI, UrlBuilder } from '../base';
|
||||
import { Item } from './items';
|
||||
import { Details, OutType, Results } from './types';
|
||||
|
||||
export type LocationCreate = Details;
|
||||
|
@ -6,6 +7,8 @@ export type LocationCreate = Details;
|
|||
export type Location = LocationCreate &
|
||||
OutType & {
|
||||
groupId: string;
|
||||
items: Item[];
|
||||
itemCount: number;
|
||||
};
|
||||
|
||||
export type LocationUpdate = LocationCreate;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue