I’ve created a smart collection based on a API call.
const { collection } = require('forest-express-sequelize');
collection('sageProviders', {
actions: [{
name: 'Générer un ODS',
type: 'single',
fields: [{
field: 'Copropriétaire',
type: 'Enum',
enums: []
}, {
field: 'Type ODS',
type: 'Enum',
enums: [
'Avec devis',
'Sans devis',
'Demande de devis'
]
}, {
field: 'Descriptif intervention',
type: 'String'
}, {
field: 'Date intervention souhaitée',
type: 'Date'
}, {
field: 'Informations détaillées pour le fournisseur',
type: 'String'
}],
hooks: {
load: ({ fields, record }) => {
console.log('record: ', record);
return fields;
}
},
}],
fields: [{
field: 'id',
type: 'String',
get: record => record.matricule
}, {
field: 'matricule',
type: 'String',
}, {
field: 'siret',
type: 'String'
}, {
field: 'raison_sociale',
type: 'String'
}, {
field: 'site_adresse',
type: 'String'
}, {
field: 'site_ville',
type: 'String'
}, {
field: 'site_codepostal',
type: 'String'
}, {
field: 'telephone',
type: 'String'
}, {
field: 'email',
type: 'String'
}, {
field: 'bic',
type: 'String'
}, {
field: 'iban',
type: 'String'
}, {
field: 'street_number',
type: 'String'
}, {
field: 'street',
type: 'String'
}]
});
routes/
// Get a list of sageProviders
router.get('/sageProviders', permissionMiddlewareCreator.list(), (request, response, next) => {
const recordSerializer = new RecordSerializer({ name: 'sageProviders' });
const params = {
provider_name: '',
siret: '',
matricule: ''
};
axios.get(
`${API_URL}/forest_admin/sage_providers`, {
headers: {
'Authorization': `Bearer ${process.env.ACCESS_TOKEN}`,
'X-CURRENT-USER-EMAIL': request.user.email
},
params
}).then(async res => {
response.send({
...(await recordSerializer.serialize(res.data)),
meta: {
count: res.data.length
}
});
}).catch(err => {
response.status(400).send({ error: err.response.data.error.message });
});
});
///////////////////////////////////////////////////////////////////////////////
// Get a sageProvider
router.get('/sageProviders/:matricule', permissionMiddlewareCreator.details(), (request, response, next) => {
const recordSerializer = new RecordSerializer({ name: 'sageProviders' });
const matricule = request.params.matricule;
const params = {
provider_name: '',
siret: '',
matricule
};
axios.get(
`${API_URL}/forest_admin/sage_providers`, {
headers: {
'Authorization': `Bearer ${process.env.ACCESS_TOKEN}`,
'X-CURRENT-USER-EMAIL': request.user.email
},
params
}).then(async res => {
response.send({
...(await recordSerializer.serialize(res.data[0])),
meta: {
count: res.data.length
}
});
}).catch(err => {
response.status(400).send({ error: err.response.data.error.message });
});
});
when I open my smart action, I get
POST /forest/actions/generer-un-ods/values 404 176 - 26.590 ms
POST /forest/actions/generer-un-ods/hooks/load 404 180 - 19.146 ms
I guess I need to recreate these routes but I have no idea how to do it.