Add isLiked bool on the front

This commit is contained in:
2024-01-12 18:28:56 +01:00
committed by Clément Le Bihan
parent ec17aa741f
commit 17f64cd849

View File

@@ -35,6 +35,7 @@ export const SongValidator = yup
yup.array(yup.object({ userId: yup.number().required() })).default(undefined) yup.array(yup.object({ userId: yup.number().required() })).default(undefined)
) )
.optional(), .optional(),
isLiked: yup.bool().optional(),
}) })
.concat(ModelValidator) .concat(ModelValidator)
.transform((song: Song) => ({ .transform((song: Song) => ({
@@ -53,6 +54,7 @@ export const SongValidator = yup
yup.date().cast(b.playDate)!.getTime() yup.date().cast(b.playDate)!.getTime()
) )
.at(0)?.info.score ?? null, .at(0)?.info.score ?? null,
isLiked: song.likedByUsers?.some(() => true),
})); }));
export type Song = yup.InferType<typeof SongValidator>; export type Song = yup.InferType<typeof SongValidator>;