Hello,
I have an issue using the smart actions, I got this error message “Unexpected error with Valider action”.
Here is my action in my collection in forest folder
collection('tETherapist', {
actions: [
{
name: 'Valider',
endpoint: '/forest/actions/therapist/valider'
},
{
name: 'Refuser',
endpoint: '/forest/actions/therapist/refuser'
},
],
fields: [],
segments: [],
});
Here is my smart action to update an enum field in the postgresql database in routes folder
router.post('/actions/therapist/valider', permissionMiddlewareCreator.smartAction(), (req, res) => {
return new RecordsGetter(tETherapist).getIdsFromRequest(req)
.then((therapistIds) => {
return tETherapist
.update({ registrationStatus: 'validated' }, { where: { id: therapistIds }})
.catch(() => {
res.send({ error: 'Le thérapeut n\'a pas pu être validé !' });
})
.then(() => {
res.send({ success: 'Thérapeut validé !' });
});
});
});
And here is the error log in the docker service from the docker compose
cajole_admin | POST /forest/actions/therapist/valider?timezone=Europe%2FParis 500 102 - 7.945 ms
cajole_admin | Executing (default): SELECT count("tETherapist"."id") AS "count" FROM "public"."t_e_therapist" AS "tETherapist" LEFT OUTER JOIN "public"."t_e_user" AS "user" ON "tETherapist"."user_id" = "user"."id" LEFT OUTER JOIN "public"."t_e_user" AS "sponsor" ON "tETherapist"."sponsor_id" = "sponsor"."id" WHERE "tETherapist"."id" IN ('f51fbde6-24f4-4a84-b069-64550767257e');
cajole_admin | [forest] 🌳🌳🌳 Unexpected error: Cannot read property 'timezone' of undefined
cajole_admin | {
cajole_admin | "stack": "TypeError: Cannot read property 'timezone' of undefined\n at new AbstractRecordService (/usr/src/app/node_modules/forest-express/dist/services/exposed/abstract-records-service.js:20:17)\n at RecordsGetter._createSuperInternal (/usr/src/app/node_modules/forest-express/dist/services/exposed/records-getter.js:27:317)\n at new RecordsGetter (/usr/src/app/node_modules/forest-express/dist/services/exposed/records-getter.js:46:19)\n at router.post (/usr/src/app/routes/t-e-therapist.js:14:10)\n at Layer.handle [as handle_request] (/usr/src/app/node_modules/express/lib/router/layer.js:95:5)\n at next (/usr/src/app/node_modules/express/lib/router/route.js:137:13)\n at _callee2$ (/usr/src/app/node_modules/forest-express/dist/middlewares/permissions.js:205:53)\n at tryCatch (/usr/src/app/node_modules/regenerator-runtime/runtime.js:63:40)\n at Generator.invoke [as _invoke] (/usr/src/app/node_modules/regenerator-runtime/runtime.js:294:22)\n at Generator.next (/usr/src/app/node_modules/regenerator-runtime/runtime.js:119:21)\n at asyncGeneratorStep (/usr/src/app/node_modules/@babel/runtime/helpers/asyncToGenerator.js:3:24)\n at _next (/usr/src/app/node_modules/@babel/runtime/helpers/asyncToGenerator.js:25:9)"