1
0
mirror of https://github.com/LaCasemate/fab-manager.git synced 2025-01-31 20:52:21 +01:00

22 lines
834 B
TypeScript
Raw Normal View History

import apiClient from './clients/api-client';
import { AxiosResponse } from 'axios';
import { Order, OrderIndexFilter, OrderIndex } from '../models/order';
import ApiLib from '../lib/api';
2022-09-15 20:19:19 +02:00
export default class OrderAPI {
static async index (filters?: OrderIndexFilter): Promise<OrderIndex> {
const res: AxiosResponse<OrderIndex> = await apiClient.get(`/api/orders${ApiLib.filtersToQuery(filters)}`);
return res?.data;
}
static async get (id: number | string): Promise<Order> {
const res: AxiosResponse<Order> = await apiClient.get(`/api/orders/${id}`);
return res?.data;
}
2022-09-15 20:19:19 +02:00
static async updateState (order: Order, state: string, note?: string): Promise<Order> {
const res: AxiosResponse<Order> = await apiClient.patch(`/api/orders/${order.id}`, { order: { state, note } });
return res?.data;
}
}