This commit is contained in:
danis
2023-12-21 17:40:23 +01:00
parent dac9849ef5
commit b3853646cb
3 changed files with 23 additions and 9 deletions

View File

@@ -1,4 +1,4 @@
import { Controller, Get } from "@nestjs/common";
import { Controller, Get, Put } from "@nestjs/common";
import { ApiOkResponse, ApiTags } from "@nestjs/swagger";
import { ScoresService } from "./scores.service";
import { User } from "@prisma/client";
@@ -13,4 +13,10 @@ export class ScoresController {
getTopTwenty(): Promise<User[]> {
return this.scoresService.topTwenty();
}
// @ApiOkResponse{{description: "Successfully updated the user's total score"}}
// @Put("/add")
// addScore(): Promise<void> {
// return this.ScoresService.add()
// }
}

View File

@@ -55,7 +55,6 @@ const SearchBarComponent = (props: { onValidate: (searchData: searchProps) => vo
artist: artistsQuery.data?.find((a) => a.name === artist)?.id ?? undefined,
genre: genresQuery.data?.find((g) => g.name === genre)?.id ?? undefined,
};
props.onValidate(searchData);
};

View File

@@ -6,6 +6,7 @@ import MusicList from '../../components/UI/MusicList';
import { useQuery } from '../../Queries';
import API from '../../API';
import { MusicItemType } from '../../components/UI/MusicItem';
import { View } from 'react-native';
export type searchProps = {
artist: number | undefined;
@@ -17,13 +18,13 @@ export type searchProps = {
const SearchView = (props: RouteProps<{}>) => {
const navigation = useNavigation();
// const [searchResult, setSearchResult] = React.useState([] as MusicItemType[]);
const [searchQuery, setSearchQuery] = React.useState({artist: undefined, genre: undefined, query: ''} as searchProps)
const rawResult = useQuery(API.searchSongs(searchQuery), { enabled: !!searchQuery });
const [searchQuery, setSearchQuery] = React.useState({} as searchProps);
const rawResult = useQuery(API.searchSongs(searchQuery), {enabled: !!searchQuery.query});
const result =
rawResult.data?.map((song) => ({
artist: song.artist!.name,
song: song.name,
image: song.cover,
artist: song?.artist?.name ?? 'duh',
song: song?.name,
image: song?.cover,
level: 42,
lastScore: 42,
bestScore: 42,
@@ -34,10 +35,18 @@ const SearchView = (props: RouteProps<{}>) => {
onPlay: () => navigation.navigate('Play', { songId: song.id }),
})) ?? [];
const handleLog = (query: searchProps) => {
console.log("got query: ", query.query);
setSearchQuery(query);
// rawResult.refetch();
}
return (
<ScaffoldCC routeName={props.route.name}>
<SearchBarComponent onValidate={setSearchQuery} />
<MusicList initialMusics={result} />
<View style={{display: 'flex', gap: 20}} >
<SearchBarComponent onValidate={(data) => handleLog(data)} />
{/* {result ? <MusicList initialMusics={result} /> : null} */}
</View>
</ScaffoldCC>
);
};