fix: fixed quantity display on cryptos

This commit is contained in:
Kevsl 2024-06-12 21:26:29 +02:00
parent cf8fbe4fe5
commit 49faaf4fa0
3 changed files with 23 additions and 18 deletions

View File

@ -1,12 +1,12 @@
import { import {
Body, Body,
Controller, Controller,
Delete, // Delete,
Get, Get,
HttpCode, HttpCode,
HttpStatus, HttpStatus,
Param, Param,
Patch, // Patch,
Post, Post,
UseGuards, UseGuards,
} from '@nestjs/common'; } from '@nestjs/common';
@ -55,19 +55,19 @@ export class CryptoController {
) { ) {
return this.cryptoService.buyCrypto(user.id, dto); return this.cryptoService.buyCrypto(user.id, dto);
} }
@HttpCode(HttpStatus.OK) // @HttpCode(HttpStatus.OK)
@Patch('/update/:id') // @Patch('/update/:id')
editCryptoById( // editCryptoById(
@Param('id') cryptoId: string, // @Param('id') cryptoId: string,
@Body() dto: CryptoDto, // @Body() dto: CryptoDto,
@GetUser() user: User, // @GetUser() user: User,
) { // ) {
return this.cryptoService.editCryptoById(user.id, cryptoId, dto); // return this.cryptoService.editCryptoById(user.id, cryptoId, dto);
} // }
@HttpCode(HttpStatus.NO_CONTENT) // @HttpCode(HttpStatus.NO_CONTENT)
@Delete('/delete/:id') // @Delete('/delete/:id')
deleteOfferById(@Param('id') roleId: string, @GetUser() user: User) { // deleteOfferById(@Param('id') roleId: string, @GetUser() user: User) {
return this.cryptoService.deleteCryptoById(user.id, roleId); // return this.cryptoService.deleteCryptoById(user.id, roleId);
} // }
} }

View File

@ -36,9 +36,9 @@ export class CryptoService {
await checkUserHasAccount(userId); await checkUserHasAccount(userId);
if (cryptoId) { if (cryptoId) {
return this.prisma.crypto.findMany({ return this.prisma.cryptoHistory.findMany({
where: { where: {
id: cryptoId, id_crypto: cryptoId,
}, },
orderBy: { orderBy: {

View File

@ -21,6 +21,7 @@ export class UserService {
UserHasCrypto: { UserHasCrypto: {
select: { select: {
Crypto: true, Crypto: true,
amount: true,
}, },
}, },
}, },
@ -40,10 +41,14 @@ export class UserService {
UserHasCrypto: { UserHasCrypto: {
select: { select: {
Crypto: true, Crypto: true,
amount: true,
}, },
}, },
}, },
take: 50, take: 50,
orderBy: {
dollarAvailables: 'desc',
},
}); });
return user; return user;
} }