Fix types
This commit is contained in:
@@ -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<void>;
|
||||
|
||||
@@ -7,5 +7,5 @@ export const ListHandler = <A, R>(
|
||||
itemHandler: ResponseHandler<A, R>
|
||||
): ResponseHandler<A[], R[]> => ({
|
||||
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),
|
||||
});
|
||||
|
||||
@@ -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<typeof SongValidator>;
|
||||
|
||||
Reference in New Issue
Block a user