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

View file

@ -68,7 +68,7 @@ function HandleSetContainerList(
setNewHistory(
AddContainers(
selectedContainer.children.length,
response.Containers.map(container => container.properties.type),
response.Containers.map(container => container.Type),
selectedContainer.properties.id,
configuration,
history,
@ -104,7 +104,7 @@ function HandleReplace(
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(
index + 1,
types,

View file

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

View file

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

View file

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