Changed api call body's container model to available container + Fix API nullable values

This commit is contained in:
Eric NGUYEN 2022-08-31 16:15:38 +02:00
parent 4588aa9443
commit 8034652bdb
5 changed files with 12 additions and 14 deletions

View file

@ -42,6 +42,9 @@ export async function SetContainerList(request: ISetContainerListRequest): Promi
if (window.fetch) { if (window.fetch) {
return await fetch(url, { return await fetch(url, {
method: 'POST', method: 'POST',
headers: new Headers({
'Content-Type': 'application/json'
}),
body: dataParsed body: dataParsed
}) })
.then(async(response) => .then(async(response) =>
@ -56,6 +59,7 @@ export async function SetContainerList(request: ISetContainerListRequest): Promi
resolve(JSON.parse(this.responseText)); resolve(JSON.parse(this.responseText));
} }
}; };
xhr.setRequestHeader('Content-type', 'application/json');
xhr.send(dataParsed); xhr.send(dataParsed);
}); });
} }

View file

@ -68,7 +68,7 @@ function HandleSetContainerList(
setNewHistory( setNewHistory(
AddContainers( AddContainers(
selectedContainer.children.length, selectedContainer.children.length,
response.Containers.map(container => container.properties.type), response.Containers.map(container => container.Type),
selectedContainer.properties.id, selectedContainer.properties.id,
configuration, configuration,
history, history,
@ -104,7 +104,7 @@ function HandleReplace(
const index = selectedContainer.parent.children.indexOf(selectedContainer); const index = selectedContainer.parent.children.indexOf(selectedContainer);
const types = response.Containers.map(container => container.properties.type); const types = response.Containers.map(container => container.Type);
const newHistoryBeforeDelete = AddContainers( const newHistoryBeforeDelete = AddContainers(
index + 1, index + 1,
types, types,

View file

@ -62,7 +62,7 @@ function InitActions(
// API Actions // API Actions
for (const availableContainer of configuration.AvailableContainers) { for (const availableContainer of configuration.AvailableContainers) {
if (availableContainer.Actions === undefined) { if (availableContainer.Actions === undefined || availableContainer.Actions === null) {
continue; continue;
} }

View file

@ -1,6 +1,6 @@
/* eslint-disable @typescript-eslint/naming-convention */ /* eslint-disable @typescript-eslint/naming-convention */
import { IContainerModel } from './IContainerModel'; import { IAvailableContainer } from './IAvailableContainer';
export interface ISetContainerListResponse { export interface ISetContainerListResponse {
Containers: IContainerModel[] Containers: IAvailableContainer[]
} }

View file

@ -219,19 +219,13 @@ const FillHoleWithChassis = (request) => {
const SplitRemplissage = (request) => { const SplitRemplissage = (request) => {
const lstModels = [ const lstModels = [
{ {
properties: { Type: 'Remplissage'
type: 'Remplissage'
}
}, },
{ {
properties: { Type: 'Montant'
type: 'Montant'
}
}, },
{ {
properties: { Type: 'Remplissage'
type: 'Remplissage'
}
}, },
]; ];