Fix typo artiste lifecycles

This commit is contained in:
Cédric FAMIBELLE-PRONZOLA
2022-05-12 19:53:07 +04:00
parent 90885aed4c
commit 54f16a8b77
2 changed files with 11 additions and 8 deletions
@@ -8,34 +8,37 @@
const slugify = require('slugify')
const jwennTeksEpiId = async data => {
const teks = await strapi.query('paroles').find({id_in: data})
const teks = await strapi.db.query('api::parole.parole').find({id_in: data})
return teks
}
const jwennAwtisEpiId = async id => {
const artiste = await strapi.query('artiste').find({id})
const artiste = await strapi.db.query('api::artiste.artiste').findOne({id})
return artiste
}
module.exports = {
beforeUpdate: async event => {
let {data} = event
console.log('event', event)
let {data} = event.params
if (!data.slug) {
if (!data.slug || data.slug !== slugify(data.alias, {lower: true, remove: /[*#+~.()'"!:@]/g})) {
data.slug = slugify(data.alias, {lower: true, remove: /[*#+~.()'"!:@]/g})
}
},
beforeCreate: async event => {
let {data} = event
let {data} = event.params
data.slug = slugify(data.alias, {lower: true, remove: /[*#+~.()'"!:@]/g})
},
afterUpdate: async event => {
let {data} = event
console.log('event', event)
let {data} = event.params
const {id} = data
const artiste = await jwennAwtisEpiId(id)
if (artiste.teks && artiste.paroles.length >= 1) {
if (artiste.paroles && artiste.paroles.length >= 1) {
const paroles = await jwennTeksEpiId(artiste.paroles)
Promise.all(paroles.map(async t => {
const {id, tit, slug, artiste} = t
@@ -14,7 +14,7 @@
"name": "Apache 2.0",
"url": "https://www.apache.org/licenses/LICENSE-2.0.html"
},
"x-generation-date": "2022-05-12T15:07:13.371Z"
"x-generation-date": "2022-05-12T15:51:28.188Z"
},
"x-strapi-config": {
"path": "/documentation",