Fix jwennAwtisEpiId error
This commit is contained in:
@@ -28,7 +28,6 @@ const isSlugExists = async existingSlug => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const jwennAwtisEpiId = async artistesIds => {
|
const jwennAwtisEpiId = async artistesIds => {
|
||||||
console.log('artistesIds', artistesIds)
|
|
||||||
if (artistesIds.length === 0) {
|
if (artistesIds.length === 0) {
|
||||||
throw new ApplicationError('Champ obligatoire. Veuillez choisir au moins un artiste.');
|
throw new ApplicationError('Champ obligatoire. Veuillez choisir au moins un artiste.');
|
||||||
}
|
}
|
||||||
@@ -37,7 +36,7 @@ const jwennAwtisEpiId = async artistesIds => {
|
|||||||
select: ['alias'],
|
select: ['alias'],
|
||||||
where: {
|
where: {
|
||||||
id: {
|
id: {
|
||||||
$in: artistesIds.map(({id}) => id)
|
$in: artistesIds.map(id => id)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@@ -122,8 +121,18 @@ module.exports = {
|
|||||||
data.userAdmin = userAdmin
|
data.userAdmin = userAdmin
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let artistesIds = []
|
||||||
|
|
||||||
|
if (data?.artistes?.connect) {
|
||||||
|
for (const artiste of data.artistes.connect) {
|
||||||
|
artistesIds.push(artiste.id)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
artistesIds = data.artistes
|
||||||
|
}
|
||||||
|
|
||||||
if (data.titre && !data.forceSlug) {
|
if (data.titre && !data.forceSlug) {
|
||||||
const artiste = await jwennAwtisEpiId(data.artistes.connect)
|
const artiste = await jwennAwtisEpiId(artistesIds)
|
||||||
data.slug = getSlug(artiste, data.titre)
|
data.slug = getSlug(artiste, data.titre)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user