feat: enhanced search functions (#260)

* make login case insensitive

* expand query to support by Field and By AID search

* type generation

* new API callers

* rework search to support field queries

* improve unnecessary data fetches

* clear stores on logout

* change verbage

* add labels
This commit is contained in:
Hayden 2023-02-05 12:12:54 -09:00 committed by GitHub
parent 7b28973c60
commit bd06fdafaf
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
18 changed files with 637 additions and 133 deletions

View file

@ -21,6 +21,7 @@ export type ItemsQuery = {
locations?: string[];
labels?: string[];
q?: string;
fields?: string[];
};
export class AttachmentsAPI extends BaseAPI {
@ -48,6 +49,16 @@ export class AttachmentsAPI extends BaseAPI {
}
}
export class FieldsAPI extends BaseAPI {
getAll() {
return this.http.get<string[]>({ url: route("/items/fields") });
}
getAllValues(field: string) {
return this.http.get<string[]>({ url: route(`/items/fields/values`, { field }) });
}
}
export class MaintenanceAPI extends BaseAPI {
getLog(itemId: string) {
return this.http.get<MaintenanceLog>({ url: route(`/items/${itemId}/maintenance`) });
@ -75,9 +86,11 @@ export class MaintenanceAPI extends BaseAPI {
export class ItemsApi extends BaseAPI {
attachments: AttachmentsAPI;
maintenance: MaintenanceAPI;
fields: FieldsAPI;
constructor(http: Requests, token: string) {
super(http, token);
this.fields = new FieldsAPI(http);
this.attachments = new AttachmentsAPI(http);
this.maintenance = new MaintenanceAPI(http);
}

View file

@ -17,11 +17,11 @@ export interface DocumentOut {
}
export interface Group {
createdAt: Date;
createdAt: string;
currency: string;
id: string;
name: string;
updatedAt: Date;
updatedAt: string;
}
export interface GroupStatistics {
@ -39,11 +39,11 @@ export interface GroupUpdate {
}
export interface ItemAttachment {
createdAt: Date;
createdAt: string;
document: DocumentOut;
id: string;
type: string;
updatedAt: Date;
updatedAt: string;
}
export interface ItemAttachmentUpdate {
@ -76,7 +76,7 @@ export interface ItemOut {
assetId: string;
attachments: ItemAttachment[];
children: ItemSummary[];
createdAt: Date;
createdAt: string;
description: string;
fields: ItemField[];
id: string;
@ -103,16 +103,16 @@ export interface ItemOut {
/** @example "0" */
soldPrice: string;
/** Sold */
soldTime: Date;
soldTime: string;
soldTo: string;
updatedAt: Date;
updatedAt: string;
warrantyDetails: string;
warrantyExpires: Date;
warrantyExpires: string;
}
export interface ItemSummary {
archived: boolean;
createdAt: Date;
createdAt: string;
description: string;
id: string;
insured: boolean;
@ -123,7 +123,7 @@ export interface ItemSummary {
/** @example "0" */
purchasePrice: string;
quantity: number;
updatedAt: Date;
updatedAt: string;
}
export interface ItemUpdate {
@ -156,10 +156,10 @@ export interface ItemUpdate {
/** @example "0" */
soldPrice: string;
/** Sold */
soldTime: Date;
soldTime: string;
soldTo: string;
warrantyDetails: string;
warrantyExpires: Date;
warrantyExpires: string;
}
export interface LabelCreate {
@ -169,20 +169,20 @@ export interface LabelCreate {
}
export interface LabelOut {
createdAt: Date;
createdAt: string;
description: string;
id: string;
items: ItemSummary[];
name: string;
updatedAt: Date;
updatedAt: string;
}
export interface LabelSummary {
createdAt: Date;
createdAt: string;
description: string;
id: string;
name: string;
updatedAt: Date;
updatedAt: string;
}
export interface LocationCreate {
@ -193,30 +193,30 @@ export interface LocationCreate {
export interface LocationOut {
children: LocationSummary[];
createdAt: Date;
createdAt: string;
description: string;
id: string;
items: ItemSummary[];
name: string;
parent: LocationSummary;
updatedAt: Date;
updatedAt: string;
}
export interface LocationOutCount {
createdAt: Date;
createdAt: string;
description: string;
id: string;
itemCount: number;
name: string;
updatedAt: Date;
updatedAt: string;
}
export interface LocationSummary {
createdAt: Date;
createdAt: string;
description: string;
id: string;
name: string;
updatedAt: Date;
updatedAt: string;
}
export interface LocationUpdate {