fix: sửa lỗi hiển thị logo trên trang pdf
This commit is contained in:
Vendored
+83
-16
@@ -516,11 +516,14 @@ let PublicTourController = class PublicTourController {
|
||||
expenses: {
|
||||
include: {
|
||||
location: { select: { name: true, plannedStart: true } },
|
||||
paidBy: { select: { name: true } }
|
||||
paidBy: { select: { id: true, name: true } }
|
||||
}
|
||||
},
|
||||
locations: {
|
||||
orderBy: { plannedStart: 'asc' },
|
||||
orderBy: [
|
||||
{ plannedStart: { sort: 'asc', nulls: 'last' } },
|
||||
{ createdAt: 'asc' }
|
||||
],
|
||||
include: { _count: { select: { comments: true } } }
|
||||
},
|
||||
},
|
||||
@@ -839,7 +842,10 @@ let TourController = class TourController {
|
||||
orderBy: { sequence: 'asc' },
|
||||
include: {
|
||||
locations: {
|
||||
orderBy: { plannedStart: 'asc' },
|
||||
orderBy: [
|
||||
{ plannedStart: { sort: 'asc', nulls: 'last' } },
|
||||
{ createdAt: 'asc' }
|
||||
],
|
||||
include: { _count: { select: { comments: true } } }
|
||||
}
|
||||
}
|
||||
@@ -871,11 +877,14 @@ let TourController = class TourController {
|
||||
expenses: {
|
||||
include: {
|
||||
location: { select: { name: true, plannedStart: true } },
|
||||
paidBy: { select: { name: true } }
|
||||
paidBy: { select: { id: true, name: true } }
|
||||
}
|
||||
},
|
||||
locations: {
|
||||
orderBy: { plannedStart: 'asc' },
|
||||
orderBy: [
|
||||
{ plannedStart: { sort: 'asc', nulls: 'last' } },
|
||||
{ createdAt: 'asc' }
|
||||
],
|
||||
include: { _count: { select: { comments: true } } }
|
||||
},
|
||||
},
|
||||
@@ -931,6 +940,44 @@ let TourController = class TourController {
|
||||
include: { user: { select: { id: true, name: true, email: true } } },
|
||||
});
|
||||
}
|
||||
async updateMemberCounts(tourId, userId, body, req) {
|
||||
const isSelf = req.user.id === userId;
|
||||
const requesterParticipation = await this.prisma.tourParticipant.findUnique({
|
||||
where: { tourId_userId: { tourId, userId: req.user.id } },
|
||||
});
|
||||
const canManage = requesterParticipation?.role === 'OWNER' || requesterParticipation?.role === 'MANAGER';
|
||||
if (!canManage && !isSelf) {
|
||||
throw new common_1.ForbiddenException('Bạn không có quyền chỉnh sửa thông tin thành viên này.');
|
||||
}
|
||||
const data = {};
|
||||
if (body.adultCount !== undefined) {
|
||||
if (body.adultCount < 1)
|
||||
throw new common_1.BadRequestException('Số lượng người lớn tối thiểu là 1.');
|
||||
data.adultCount = Number(body.adultCount);
|
||||
}
|
||||
if (body.childCount !== undefined) {
|
||||
if (body.childCount < 0)
|
||||
throw new common_1.BadRequestException('Số lượng trẻ em không được âm.');
|
||||
data.childCount = Number(body.childCount);
|
||||
}
|
||||
if (body.role !== undefined && canManage) {
|
||||
const validRoles = ['OWNER', 'MANAGER', 'MEMBER', 'MEMBER_NO_FINANCE', 'VIEWER_ONLY'];
|
||||
if (validRoles.includes(body.role)) {
|
||||
data.role = body.role;
|
||||
}
|
||||
}
|
||||
await Promise.all([
|
||||
this.cacheManager.del(`user-role:${userId}:${tourId}`),
|
||||
this.cacheManager.del(tourId),
|
||||
this.cacheManager.del(`/api/v1/tours/${tourId}`),
|
||||
this.cacheManager.del(`/api/v1/tours/${tourId}/public`),
|
||||
]);
|
||||
return this.prisma.tourParticipant.update({
|
||||
where: { tourId_userId: { tourId, userId } },
|
||||
data,
|
||||
include: { user: { select: { id: true, name: true, email: true } } },
|
||||
});
|
||||
}
|
||||
async getJoinRequests(tourId, req) {
|
||||
const requests = await this.prisma.joinRequest.findMany({
|
||||
where: { tourId, status: 'PENDING' },
|
||||
@@ -1248,6 +1295,18 @@ __decorate([
|
||||
__metadata("design:paramtypes", [String, Object, Object]),
|
||||
__metadata("design:returntype", Promise)
|
||||
], TourController.prototype, "addMember", null);
|
||||
__decorate([
|
||||
(0, exports.Roles)(client_1.ParticipantRole.OWNER, client_1.ParticipantRole.MANAGER, client_1.ParticipantRole.MEMBER, client_1.ParticipantRole.MEMBER_NO_FINANCE, client_1.ParticipantRole.VIEWER_ONLY),
|
||||
(0, common_1.UseGuards)(jwt_auth_guard_1.JwtAuthGuard, TourRoleGuard),
|
||||
(0, common_1.Patch)(':tourId/members/:userId'),
|
||||
__param(0, (0, common_1.Param)('tourId', common_1.ParseUUIDPipe)),
|
||||
__param(1, (0, common_1.Param)('userId', common_1.ParseUUIDPipe)),
|
||||
__param(2, (0, common_1.Body)()),
|
||||
__param(3, (0, common_1.Req)()),
|
||||
__metadata("design:type", Function),
|
||||
__metadata("design:paramtypes", [String, String, Object, Object]),
|
||||
__metadata("design:returntype", Promise)
|
||||
], TourController.prototype, "updateMemberCounts", null);
|
||||
__decorate([
|
||||
(0, exports.Roles)(client_1.ParticipantRole.OWNER, client_1.ParticipantRole.MANAGER),
|
||||
(0, common_1.UseGuards)(jwt_auth_guard_1.JwtAuthGuard, TourRoleGuard),
|
||||
@@ -1515,7 +1574,10 @@ let RoutingController = class RoutingController {
|
||||
tourId: currentLeg.tourId,
|
||||
sequence: currentLeg.sequence - 1
|
||||
},
|
||||
include: { locations: { orderBy: { plannedStart: 'asc' } } }
|
||||
include: { locations: { orderBy: [
|
||||
{ plannedStart: { sort: 'asc', nulls: 'last' } },
|
||||
{ createdAt: 'asc' }
|
||||
] } }
|
||||
});
|
||||
if (prevLeg?.locations?.length) {
|
||||
startAnchor = prevLeg.locations[prevLeg.locations.length - 1];
|
||||
@@ -1568,7 +1630,10 @@ let RoutingController = class RoutingController {
|
||||
})));
|
||||
const updatedLocations = await this.prisma.location.findMany({
|
||||
where: { legId },
|
||||
orderBy: { plannedStart: 'asc' }
|
||||
orderBy: [
|
||||
{ plannedStart: { sort: 'asc', nulls: 'last' } },
|
||||
{ createdAt: 'asc' }
|
||||
]
|
||||
});
|
||||
if (req.tourId) {
|
||||
await Promise.all([
|
||||
@@ -1820,14 +1885,17 @@ let UserController = class UserController {
|
||||
async getAllUsers(req, q) {
|
||||
const currentUserId = req.user?.id;
|
||||
const users = await this.prisma.user.findMany({
|
||||
where: q
|
||||
? {
|
||||
OR: [
|
||||
{ name: { contains: q, mode: 'insensitive' } },
|
||||
{ email: { contains: q, mode: 'insensitive' } },
|
||||
],
|
||||
}
|
||||
: undefined,
|
||||
where: {
|
||||
isAnonymous: false,
|
||||
...(q
|
||||
? {
|
||||
OR: [
|
||||
{ name: { contains: q, mode: 'insensitive' } },
|
||||
{ email: { contains: q, mode: 'insensitive' } },
|
||||
],
|
||||
}
|
||||
: {}),
|
||||
},
|
||||
select: { id: true, email: true, name: true, isAdmin: true, isBlocked: true, createdAt: true, phone: true, address: true }
|
||||
});
|
||||
return users.filter((u) => u.id !== currentUserId);
|
||||
@@ -1911,7 +1979,6 @@ let UserController = class UserController {
|
||||
};
|
||||
__decorate([
|
||||
(0, common_1.Get)(),
|
||||
(0, common_1.UseGuards)(admin_guard_1.AdminGuard),
|
||||
__param(0, (0, common_1.Req)()),
|
||||
__param(1, (0, common_1.Query)('q')),
|
||||
__metadata("design:type", Function),
|
||||
|
||||
Reference in New Issue
Block a user