front and back fix
This commit is contained in:
10209
back/package-lock.json
generated
10209
back/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -2,19 +2,19 @@ import {
|
||||
Controller,
|
||||
Get,
|
||||
} from '@nestjs/common';
|
||||
import { ApiTags } from '@nestjs/swagger';
|
||||
import { ApiOkResponse, ApiTags } from '@nestjs/swagger';
|
||||
import { ScoresService } from './scores.service';
|
||||
import { User } from '@prisma/client';
|
||||
|
||||
@ApiTags('scores')
|
||||
@Controller('scores')
|
||||
export class ScoresController {
|
||||
constructor(private readonly scoresService: ScoresService) {}
|
||||
|
||||
|
||||
// @ApiOkResponse({ description: 'Successfully sent the Top 3 players'})
|
||||
// @Get('scores/top/3')
|
||||
// getTopThree(): Promise<any> {
|
||||
// // return await this.scoresService.topThree();
|
||||
// return [] as any[];
|
||||
// }
|
||||
|
||||
@ApiOkResponse({ description: 'Successfully sent the Top 20 players'})
|
||||
@Get('scores/top/20')
|
||||
getTopTwenty(): Promise<User[]> {
|
||||
return this.scoresService.topTwenty();
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import { User } from '@prisma/client';
|
||||
import { PrismaService } from 'src/prisma/prisma.service';
|
||||
|
||||
@Injectable()
|
||||
@@ -7,9 +8,12 @@ export class ScoresService {
|
||||
private prisma: PrismaService,
|
||||
) {}
|
||||
|
||||
// // async topThree(): Promise<any> {
|
||||
// // return this.prisma.user.findMany(
|
||||
// // // {orderBy: }
|
||||
// // )
|
||||
// }
|
||||
async topTwenty(): Promise<User[]> {
|
||||
return this.prisma.user.findMany({
|
||||
orderBy: {
|
||||
partyPlayed: 'desc',
|
||||
},
|
||||
take: 20,
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -134,13 +134,13 @@ export class UsersService {
|
||||
}
|
||||
|
||||
async addScore(
|
||||
where: Prisma.UserWhereUniqueInput,
|
||||
where: number,
|
||||
score: number,
|
||||
) {
|
||||
return this.prisma.user.update({
|
||||
where,
|
||||
where: { id: where },
|
||||
data: {
|
||||
score: {
|
||||
partyPlayed: {
|
||||
increment: score,
|
||||
},
|
||||
},
|
||||
|
||||
14
front/API.ts
14
front/API.ts
@@ -704,4 +704,18 @@ export default class API {
|
||||
method: 'PATCH',
|
||||
});
|
||||
}
|
||||
|
||||
public static getTopTwentyPlayers(): Query<User[]> {
|
||||
return {
|
||||
key: ['score'],
|
||||
exec: () =>
|
||||
API.fetch(
|
||||
{
|
||||
route: '/scores/top/20',
|
||||
method: 'GET',
|
||||
},
|
||||
{ handler: ListHandler(UserHandler) }
|
||||
),
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,27 +1,86 @@
|
||||
import { Box, Heading, useBreakpointValue, ScrollView } from 'native-base';
|
||||
import { Box, Heading, useBreakpointValue, ScrollView, Text } from 'native-base';
|
||||
import { View, Image } from 'react-native';
|
||||
import { useQuery } from 'react-query';
|
||||
import User from '../models/User';
|
||||
import { border } from 'native-base/lib/typescript/theme/styled-system';
|
||||
import API from '../API';
|
||||
|
||||
const PodiumUserCardComponent = () => {
|
||||
return (
|
||||
<View
|
||||
style={{
|
||||
display: 'flex',
|
||||
paddingTop: '60px',
|
||||
flexDirection: 'column',
|
||||
justifyContent: 'center',
|
||||
alignItems: 'center',
|
||||
}}
|
||||
>
|
||||
|
||||
<View
|
||||
style={{
|
||||
width: '140px',
|
||||
height: '140px',
|
||||
flexShrink: 0,
|
||||
borderRadius: 12,
|
||||
}}
|
||||
>
|
||||
<Image
|
||||
source={{
|
||||
uri: 'https://picsum.photos/140/140',
|
||||
}}
|
||||
style={{
|
||||
aspectRatio: 1,
|
||||
width: '100%',
|
||||
height: '100%',
|
||||
flexShrink: 1,
|
||||
}}
|
||||
/>
|
||||
<Text
|
||||
style={{
|
||||
color: '#FFF',
|
||||
fontFamily: 'Lexend',
|
||||
fontSize: 16,
|
||||
fontStyle: 'normal',
|
||||
fontWeight: '500',
|
||||
}}
|
||||
>
|
||||
|
||||
</Text>
|
||||
</View>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
|
||||
const boardRowComponent = () => {
|
||||
return (
|
||||
<View>
|
||||
|
||||
</View>
|
||||
);
|
||||
}
|
||||
|
||||
const Leaderboardiew = () => {
|
||||
// const userQuery = useQuery(API.get)
|
||||
const TopTwentyQuery = [] as any[];
|
||||
const TopThreeQuery = [] as any[];
|
||||
return(
|
||||
<ScrollView>
|
||||
{TopThreeQuery.map((data) => (
|
||||
<Box rounded={'full'} borderWidth={1}>
|
||||
data.name;
|
||||
</Box>
|
||||
))}
|
||||
|
||||
{TopTwentyQuery.map((data) => (
|
||||
<Box>
|
||||
data.name;
|
||||
</Box>
|
||||
))}
|
||||
</ScrollView>
|
||||
);
|
||||
return (
|
||||
<View
|
||||
style={{
|
||||
width: '100%',
|
||||
height: '100%',
|
||||
display: 'flex',
|
||||
flexDirection: 'column',
|
||||
}}
|
||||
>
|
||||
<View
|
||||
style={{
|
||||
display: 'flex',
|
||||
paddingBottom: '0px',
|
||||
justifyContent: 'center',
|
||||
alignItems: 'center',
|
||||
alignSelf: 'stretch',
|
||||
}}
|
||||
>
|
||||
</View>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
|
||||
export default Leaderboardiew;
|
||||
Reference in New Issue
Block a user