fix artistes error when saving
This commit is contained in:
@@ -25,21 +25,21 @@ const isSlugExists = async existingSlug => {
|
||||
return Boolean(slugs)
|
||||
}
|
||||
|
||||
const jwennAwtisEpiId = async id => {
|
||||
if (!id) {
|
||||
const jwennAwtisEpiId = async artistesIds => {
|
||||
if (!artistesIds) {
|
||||
throw new ValidationError('Champ obligatoire. Veuillez choisir au moins un artiste.');
|
||||
}
|
||||
|
||||
const artiste = await strapi.db.query('api::artiste.artiste').findMany({
|
||||
const artistes = await strapi.db.query('api::artiste.artiste').findMany({
|
||||
select: ['alias'],
|
||||
where: {
|
||||
id: {
|
||||
$in: id
|
||||
$in: artistesIds.map(({id}) => id)
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
return artiste.map(a => a.alias).join('-')
|
||||
return artistes.map(a => a.alias).join('-')
|
||||
}
|
||||
|
||||
const jwennUserEpiId = async userId => {
|
||||
@@ -120,7 +120,7 @@ module.exports = {
|
||||
}
|
||||
|
||||
if (data.titre && !data.forceSlug) {
|
||||
const artiste = await jwennAwtisEpiId(data.artistes)
|
||||
const artiste = await jwennAwtisEpiId(data.artistes.connect)
|
||||
data.slug = getSlug(artiste, data.titre)
|
||||
}
|
||||
|
||||
@@ -150,7 +150,7 @@ module.exports = {
|
||||
if(!data.publishedAt && data.titre && data.transcription) {
|
||||
strapi.service('api::parole.parole').validateParoles(data.titre, data.transcription)
|
||||
if (data.titre && !data.forceSlug) {
|
||||
const artiste = await jwennAwtisEpiId(data.artistes)
|
||||
const artiste = await jwennAwtisEpiId(data.artistes.connect)
|
||||
data.slug = getSlug(artiste, data.titre)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user