Fix single track artist fields
This commit is contained in:
1 parent
661b9341d7
commit
5e3f3ef6a2
1 file changed
+9
-3
@@ -100,6 +100,12 @@ const serializeLyrics = (lyrics: Track["lyrics"] | undefined) => {
|
|||||||
return JSON.stringify(lyrics)
|
return JSON.stringify(lyrics)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const getArtistIds = (artists: Array<string | Option> = []) =>
|
||||||
|
artists.map((artist) => (typeof artist === "string" ? artist : artist.value))
|
||||||
|
|
||||||
|
const getOptionId = (option: string | Option) =>
|
||||||
|
typeof option === "string" ? option : option.value
|
||||||
|
|
||||||
const showModal = ref<boolean>(false)
|
const showModal = ref<boolean>(false)
|
||||||
const item = ref<Track | undefined>(undefined)
|
const item = ref<Track | undefined>(undefined)
|
||||||
|
|
||||||
@@ -145,8 +151,8 @@ const save = async (value: any) => {
|
|||||||
method: "POST",
|
method: "POST",
|
||||||
data: {
|
data: {
|
||||||
name: `${value.name} - Single`,
|
name: `${value.name} - Single`,
|
||||||
artists: value.artists.map((artist: Option) => artist.value),
|
artists: getArtistIds(value.artists),
|
||||||
genres: value.genre.value,
|
genre: getOptionId(value.genre),
|
||||||
file: value.cover,
|
file: value.cover,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
@@ -164,7 +170,7 @@ const save = async (value: any) => {
|
|||||||
data: {
|
data: {
|
||||||
...value,
|
...value,
|
||||||
album: value.album?.value ?? value.album,
|
album: value.album?.value ?? value.album,
|
||||||
artists: value.artists.map((artist: Option) => artist.value),
|
artists: getArtistIds(value.artists),
|
||||||
lyrics: serializeLyrics(value.lyrics),
|
lyrics: serializeLyrics(value.lyrics),
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in new issue
Block a user