I created a smart collection :
const { collection } = require('forest-express-sequelize');
collection('sageProviders', {
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'
}, {
field: 'domiciliation',
type: 'String'
}]
});
I created the POST route :
// Create a sageProviders
router.post('/sageProviders', permissionMiddlewareCreator.create(), (request, response) => {
const recordCreator = new RecordCreator(models.buildings);
const data = request.body.data.attributes;
const body = {
matricule: '',
mail: data.email,
city: data.site_ville,
street: data.street,
company_name: data.raison_sociale,
iban: data.iban,
street_number: data.street_number,
phone_number: data.telephone,
siret: data.siret,
bic: data.bic,
domiciliation: data.domiciliation,
zip_code: data.site_codepostal
};
axios.post(`${API_URL}/forest_admin/sage_create_provider`, body, {
headers: {
'Authorization': `Bearer ${process.env.ACCESS_TOKEN}`,
'X-CURRENT-USER-EMAIL': request.user.email
},
}).then(postResponse => {
axios.get(
`${API_URL}/forest_admin/sage_providers`, {
headers: {
'Authorization': `Bearer ${process.env.ACCESS_TOKEN}`,
'X-CURRENT-USER-EMAIL': request.user.email
},
params: {
provider_name: '',
siret: '',
matricule: postResponse.data.matricule
}
}).then(async getResponse => {
response.send(await recordCreator.serialize(getResponse.data[0]));
}).catch(getError => {
response.status(400).send(getError.response.data.error);
});
}).catch(postError => {
response.status(400).send(postError.response.data.error);
});
});
After having created a record, I get the following message :
I would like to display my record summary view, as it would do for any regular collection (non smart).
How could I achieve that ? Thank you for your help.