2021-10-10 20:13:10 +00:00
|
|
|
import { Model, UUID } from '@/api/admin/index';
|
|
|
|
import { Egg } from '@/api/admin/egg';
|
|
|
|
import http, { QueryBuilderParams, withQueryBuilderParams } from '@/api/http';
|
2022-02-27 16:26:13 +00:00
|
|
|
import Transformers from '@definitions/admin/transformers';
|
2021-10-10 20:13:10 +00:00
|
|
|
|
|
|
|
export interface Nest extends Model {
|
|
|
|
id: number;
|
|
|
|
uuid: UUID;
|
|
|
|
author: string;
|
|
|
|
name: string;
|
|
|
|
description?: string;
|
|
|
|
createdAt: Date;
|
|
|
|
updatedAt: Date;
|
|
|
|
relationships: {
|
|
|
|
eggs?: Egg[];
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
export const searchNests = async (params: QueryBuilderParams<'name'>): Promise<Nest[]> => {
|
|
|
|
const { data } = await http.get('/api/application/nests', {
|
|
|
|
params: withQueryBuilderParams(params),
|
|
|
|
});
|
|
|
|
|
2022-02-27 16:26:13 +00:00
|
|
|
return data.data.map(Transformers.toNest);
|
2021-10-10 20:13:10 +00:00
|
|
|
};
|