From 3becdcff463380758e61091100caa44b64b1e542 Mon Sep 17 00:00:00 2001 From: Zoe Roux Date: Wed, 29 Nov 2023 21:54:09 +0100 Subject: [PATCH] Fix types --- front/components/SongRow.tsx | 4 ++-- front/models/List.ts | 2 +- front/models/Song.ts | 2 ++ 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/front/components/SongRow.tsx b/front/components/SongRow.tsx index f695ead..4606b12 100644 --- a/front/components/SongRow.tsx +++ b/front/components/SongRow.tsx @@ -1,12 +1,12 @@ import { HStack, IconButton, Image, Text } from 'native-base'; -import Song, { SongWithArtist } from '../models/Song'; +import Song from '../models/Song'; import RowCustom from './RowCustom'; import TextButton from './TextButton'; import { MaterialIcons } from '@expo/vector-icons'; import DurationComponent from './DurationComponent'; type SongRowProps = { - song: Song | SongWithArtist; // TODO: remove Song + song: Song; isLiked: boolean; onPress: () => void; handleLike: (state: boolean, songId: number) => Promise; diff --git a/front/models/List.ts b/front/models/List.ts index 9ac2142..0fd5a75 100644 --- a/front/models/List.ts +++ b/front/models/List.ts @@ -7,5 +7,5 @@ export const ListHandler = ( itemHandler: ResponseHandler ): ResponseHandler => ({ validator: ListValidator(itemHandler.validator), - transformer: (plage) => plage.map((item) => itemHandler.transformer(item)), + transformer: (plage) => plage.map((item) => itemHandler.transformer?.(item) ?? item as unknown as R), }); diff --git a/front/models/Song.ts b/front/models/Song.ts index 67316b6..0e0229e 100644 --- a/front/models/Song.ts +++ b/front/models/Song.ts @@ -18,6 +18,7 @@ export const SongValidator = yup albumId: yup.number().required().nullable(), genreId: yup.number().required().nullable(), difficulties: SongDetailsValidator.required(), + details: SongDetailsValidator.required(), cover: yup.string().required(), artist: yup.lazy(() => ArtistValidator.default(undefined)).optional(), album: yup.lazy(() => AlbumValidator.default(undefined)).optional(), @@ -27,6 +28,7 @@ export const SongValidator = yup .transform((song: Song) => ({ ...song, cover: `${API.baseUrl}/song/${song.id}/illustration`, + details: song.difficulties, })); export type Song = yup.InferType;