More fixup for egg handling

This commit is contained in:
Dane Everitt 2021-10-10 13:21:21 -07:00
parent 85c8f4884f
commit 8486c914ae
No known key found for this signature in database
GPG Key ID: EEA66103B3D71F53
4 changed files with 6 additions and 6 deletions

View File

@ -51,18 +51,18 @@ export interface EggVariable extends Model {
export const getEgg = async (id: number | string): Promise<WithRelationships<Egg, 'nest' | 'variables'>> => { export const getEgg = async (id: number | string): Promise<WithRelationships<Egg, 'nest' | 'variables'>> => {
const { data } = await http.get(`/api/application/eggs/${id}`, { const { data } = await http.get(`/api/application/eggs/${id}`, {
params: { params: {
includes: [ 'nest', 'variables' ], include: [ 'nest', 'variables' ],
}, },
}); });
return withRelationships(AdminTransformers.toEgg(data.data), 'nest', 'variables'); return withRelationships(AdminTransformers.toEgg(data), 'nest', 'variables');
}; };
export const searchEggs = async (nestId: number, params: QueryBuilderParams<'name'>): Promise<WithRelationships<Egg, 'variables'>[]> => { export const searchEggs = async (nestId: number, params: QueryBuilderParams<'name'>): Promise<WithRelationships<Egg, 'variables'>[]> => {
const { data } = await http.get(`/api/application/nests/${nestId}/eggs`, { const { data } = await http.get(`/api/application/nests/${nestId}/eggs`, {
params: { params: {
...withQueryBuilderParams(params), ...withQueryBuilderParams(params),
includes: [ 'variables' ], include: [ 'variables' ],
}, },
}); });

View File

@ -60,7 +60,7 @@ export interface Node extends Model {
export const getNode = async (id: string | number): Promise<WithRelationships<Node, 'location'>> => { export const getNode = async (id: string | number): Promise<WithRelationships<Node, 'location'>> => {
const { data } = await http.get(`/api/application/nodes/${id}`, { const { data } = await http.get(`/api/application/nodes/${id}`, {
params: { params: {
includes: [ 'location' ], include: [ 'location' ],
}, },
}); });

View File

@ -79,7 +79,7 @@ type LoadedServer = WithRelationships<Server, 'allocations' | 'user' | 'node'>;
export const getServer = async (id: number | string): Promise<LoadedServer> => { export const getServer = async (id: number | string): Promise<LoadedServer> => {
const { data } = await http.get(`/api/application/servers/${id}`, { const { data } = await http.get(`/api/application/servers/${id}`, {
params: { params: {
includes: [ 'allocations', 'user', 'node' ], include: [ 'allocations', 'user', 'node' ],
}, },
}); });

View File

@ -88,7 +88,7 @@ export class AdminTransformers {
createdAt: new Date(attributes.created_at), createdAt: new Date(attributes.created_at),
updatedAt: new Date(attributes.updated_at), updatedAt: new Date(attributes.updated_at),
relationships: { relationships: {
location: transform(attributes.relationships!.location as FractalResponseData, this.toLocation), location: transform(attributes.relationships?.location as FractalResponseData, this.toLocation),
}, },
}; };
}; };