chore(workspace): eradicate all tsc errors and eslint warnings across frontend, admin, and backend
Deploy Canina / deploy (push) Failing after 29s

This commit is contained in:
parsa committed 2026-08-07 07:39:26 +03:30
1 parent 4659a7b1de
commit 9f11d8fb2d
98 files changed
+1272 -1009

No files matched your search

+22 -7
View File
@@ -65,7 +65,7 @@ export class UsersController {
},
},
})
getProfile(@Req() req: any) {
getProfile(@Req() req: { user: { id: string } }) {
return this.usersService.findById(req.user.id);
}
@@ -100,7 +100,10 @@ export class UsersController {
},
},
})
updateProfile(@Req() req: any, @Body() updateProfileDto: UpdateProfileDto) {
updateProfile(
@Req() req: { user: { id: string } },
@Body() updateProfileDto: UpdateProfileDto,
) {
return this.usersService.update(req.user.id, updateProfileDto);
}
@@ -125,7 +128,10 @@ export class UsersController {
},
},
})
addAddress(@Req() req: any, @Body() addressDto: AddressDto) {
addAddress(
@Req() req: { user: { id: string } },
@Body() addressDto: AddressDto,
) {
return this.usersService.addAddress(req.user.id, addressDto);
}
@@ -151,7 +157,7 @@ export class UsersController {
},
})
updateAddress(
@Req() req: any,
@Req() req: { user: { id: string } },
@Param('addressId') addressId: string,
@Body() addressDto: AddressDto,
) {
@@ -170,7 +176,10 @@ export class UsersController {
},
},
})
deleteAddress(@Req() req: any, @Param('addressId') addressId: string) {
deleteAddress(
@Req() req: { user: { id: string } },
@Param('addressId') addressId: string,
) {
return this.usersService.deleteAddress(req.user.id, addressId);
}
@@ -186,7 +195,10 @@ export class UsersController {
},
},
})
setDefaultAddress(@Req() req: any, @Param('addressId') addressId: string) {
setDefaultAddress(
@Req() req: { user: { id: string } },
@Param('addressId') addressId: string,
) {
return this.usersService.setDefaultAddress(req.user.id, addressId);
}
@@ -208,7 +220,10 @@ export class UsersController {
},
})
@ApiBadRequestResponse({ description: 'مبلغ نامعتبر است' })
async topUpWallet(@Req() req: any, @Body() body: { amount: number }) {
async topUpWallet(
@Req() req: { user: { id: string } },
@Body() body: { amount: number },
) {
const amount = Number(body.amount);
if (!amount || amount <= 0) {
throw new BadRequestException('مبلغ شارژ باید بزرگتر از صفر باشد');
+20 -2
View File
@@ -56,7 +56,16 @@ describe('UsersService', () => {
});
it('should addAddress', async () => {
const addressData = { title: 'Home', isDefault: true };
const addressData = {
title: 'Home',
receptorName: 'Ali',
phone: '09123456789',
province: 'Tehran',
city: 'Tehran',
detail: 'Street 1',
zipCode: '1234567890',
isDefault: true,
};
mockPrisma.userAddress.create.mockResolvedValue({
id: 'addr-id',
...addressData,
@@ -72,7 +81,16 @@ describe('UsersService', () => {
});
it('should updateAddress', async () => {
const addressData = { title: 'Work', isDefault: true };
const addressData = {
title: 'Work',
receptorName: 'Ali',
phone: '09123456789',
province: 'Tehran',
city: 'Tehran',
detail: 'Street 2',
zipCode: '1234567890',
isDefault: true,
};
mockPrisma.userAddress.update.mockResolvedValue({
id: 'addr-id',
...addressData,
+19 -3
View File
@@ -1,6 +1,18 @@
import { Injectable } from '@nestjs/common';
import { Prisma } from '@prisma/client';
import { PrismaService } from '../prisma/prisma.service';
export interface UserAddressInput {
title: string;
receptorName: string;
phone: string;
province: string;
city: string;
detail: string;
zipCode: string;
isDefault?: boolean;
}
@Injectable()
export class UsersService {
constructor(private prisma: PrismaService) {}
@@ -37,7 +49,7 @@ export class UsersService {
});
}
async update(id: string, data: any) {
async update(id: string, data: Prisma.UserUpdateInput) {
return this.prisma.user.update({
where: { id },
data,
@@ -56,7 +68,7 @@ export class UsersService {
});
}
async addAddress(userId: string, data: any) {
async addAddress(userId: string, data: UserAddressInput) {
if (data.isDefault) {
await this.prisma.userAddress.updateMany({
where: { userId },
@@ -78,7 +90,11 @@ export class UsersService {
});
}
async updateAddress(userId: string, addressId: string, data: any) {
async updateAddress(
userId: string,
addressId: string,
data: UserAddressInput,
) {
if (data.isDefault) {
await this.prisma.userAddress.updateMany({
where: { userId, NOT: { id: addressId } },