feat: add scheduled maintenance tasks (#320)

* add scheduled maintenance tasks

* fix failing typecheck
This commit is contained in:
Hayden 2023-02-26 18:42:23 -09:00 committed by GitHub
parent 70297b9d27
commit 025521431e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
25 changed files with 521 additions and 121 deletions

View file

@ -135,7 +135,8 @@ describe("user should be able to create an item and add an attachment", () => {
const { response, data } = await api.items.maintenance.create(item.id, {
name: faker.vehicle.model(),
description: faker.lorem.paragraph(1),
date: faker.date.past(1),
completedDate: faker.date.past(1),
scheduledDate: "null",
cost: faker.datatype.number(100).toString(),
});

View file

@ -59,9 +59,14 @@ export class FieldsAPI extends BaseAPI {
}
}
type MaintenanceEntryQuery = {
scheduled?: boolean;
completed?: boolean;
};
export class MaintenanceAPI extends BaseAPI {
getLog(itemId: string) {
return this.http.get<MaintenanceLog>({ url: route(`/items/${itemId}/maintenance`) });
getLog(itemId: string, q: MaintenanceEntryQuery = {}) {
return this.http.get<MaintenanceLog>({ url: route(`/items/${itemId}/maintenance`, q) });
}
create(itemId: string, data: MaintenanceEntryCreate) {

View file

@ -227,28 +227,37 @@ export interface LocationUpdate {
}
export interface MaintenanceEntry {
/** Sold */
completedDate: Date | string;
/** @example "0" */
cost: string;
date: Date | string;
description: string;
id: string;
name: string;
/** Sold */
scheduledDate: Date | string;
}
export interface MaintenanceEntryCreate {
/** Sold */
completedDate: Date | string;
/** @example "0" */
cost: string;
date: Date | string;
description: string;
name: string;
/** Sold */
scheduledDate: Date | string;
}
export interface MaintenanceEntryUpdate {
/** Sold */
completedDate: Date | string;
/** @example "0" */
cost: string;
date: Date | string;
description: string;
name: string;
/** Sold */
scheduledDate: Date | string;
}
export interface MaintenanceLog {