Adapt components with API response
This commit is contained in:
+8
-8
@@ -4,14 +4,14 @@ export const formatJsonString = stringToFormat =>
|
||||
stringToFormat.split('\n').map((string, index) => <div key={index}>{`${string}`}<br /></div>) // eslint-disable-line react/no-array-index-key
|
||||
|
||||
export const getAlias = (artistes, priorite = null, enhanced = false) => {
|
||||
if (artistes.data.length === 1 && !enhanced) {
|
||||
return artistes.data[0].attributes.alias
|
||||
if (artistes.length === 1 && !enhanced) {
|
||||
return artistes[0].alias
|
||||
}
|
||||
|
||||
if (artistes.data.length === 1 && enhanced) {
|
||||
if (artistes.length === 1 && enhanced) {
|
||||
return [{
|
||||
type: 'element',
|
||||
value: artistes.data[0].attributes.alias
|
||||
value: artistes[0].alias
|
||||
}]
|
||||
}
|
||||
|
||||
@@ -21,12 +21,12 @@ export const getAlias = (artistes, priorite = null, enhanced = false) => {
|
||||
|
||||
if (splittedPriority) {
|
||||
for (const element of splittedPriority) {
|
||||
const foundedArtistes = artistes.data.find(({id}) => id === element)
|
||||
alias.push(foundedArtistes.attributes.alias)
|
||||
const foundedArtistes = artistes.find(({id}) => id === element)
|
||||
alias.push(foundedArtistes.alias)
|
||||
}
|
||||
} else {
|
||||
for (const artiste of artistes.data) {
|
||||
alias.push(artiste.attributes.alias)
|
||||
for (const artiste of artistes) {
|
||||
alias.push(artiste.alias)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user