Sửa lỗi thành viên có thể gửi lời mời các users khác

This commit is contained in:
2026-06-15 19:38:07 +07:00
parent c9ef98b2ff
commit 7812d1395b
4 changed files with 13 additions and 11 deletions
+1 -1
View File
@@ -517,7 +517,7 @@ let TourController = class TourController {
});
role = participation?.role;
}
if (!role || !(role === 'OWNER' || role === 'MANAGER')) {
if (!role || role !== 'OWNER') {
throw new common_1.ForbiddenException('Bạn không có quyền từ chối yêu cầu tham gia.');
}
const joinRequest = await this.prisma.joinRequest.findUnique({
+1 -1
View File
File diff suppressed because one or more lines are too long
+1 -1
View File
@@ -549,7 +549,7 @@ class TourController {
});
role = participation?.role;
}
if (!role || !(role === 'OWNER' || role === 'MANAGER')) {
if (!role || role !== 'OWNER') {
throw new ForbiddenException('Bạn không có quyền từ chối yêu cầu tham gia.');
}
+9 -7
View File
@@ -5,7 +5,7 @@ import { useTourStore } from '@/store/useTourStore';
import { AddLocationModal } from '@/components/AddLocationModal';
import { AddMemberModal } from '../components/AddMemberModal';
import { ConfirmModal } from '../components/ConfirmModal';
import { NotificationModal, useNotificationModal } from '../components/NotificationModal';
import { NotificationModal, useNotificationModal } from '@/components/NotificationModal';
import { MapContainer, TileLayer, Marker, Popup, useMapEvents, Polyline, useMap } from 'react-leaflet';
import _MarkerClusterGroup from 'react-leaflet-cluster';
const MarkerClusterGroup = (_MarkerClusterGroup as any).default || _MarkerClusterGroup;
@@ -207,6 +207,8 @@ export const TourDetailPage = ({ onBack }: { onBack: () => void }) => {
// SỬA LỖI: Sử dụng các selectors riêng lẻ để tránh re-render trang khi mapCenter trong store thay đổi
const canEdit = ['OWNER', 'MANAGER'].includes(userRole || '');
const canInvite = ['OWNER', 'MANAGER', 'MEMBER'].includes(userRole || '');
const isOwner = userRole === 'OWNER';
useEffect(() => {
if (currentTour && ['OWNER', 'MANAGER'].includes(userRole || '')) {
@@ -435,7 +437,7 @@ export const TourDetailPage = ({ onBack }: { onBack: () => void }) => {
<img src={`https://i.pravatar.cc/100?u=${p.userId}`} alt="Avatar" />
</button>
))}
{joinRequests.slice(0, 3).map((req: any) => (
{isOwner && joinRequests.slice(0, 3).map((req: any) => (
<div key={req.id} className="relative group">
<div className="w-10 h-10 rounded-full border-2 border-amber-400 bg-amber-50 flex items-center justify-center text-amber-700 font-bold overflow-hidden shadow-lg">
{req.user?.name?.charAt(0) || '?'}
@@ -511,11 +513,11 @@ export const TourDetailPage = ({ onBack }: { onBack: () => void }) => {
<button
onClick={() => {
if (!currentTour) return;
if (canEdit) setIsAddMemberOpen(true);
if (canInvite) setIsAddMemberOpen(true);
}}
disabled={!canEdit}
disabled={!canInvite}
className={`p-2 rounded-full border backdrop-blur-sm transition-all ml-2 ${
canEdit ? 'bg-white/10 hover:bg-white/20 border-white/20' : 'bg-white/5 border-white/10 opacity-50'
canInvite ? 'bg-white/10 hover:bg-white/20 border-white/20' : 'bg-white/5 border-white/10 opacity-50'
}`}
>
<Plus className="w-4 h-4" />
@@ -720,7 +722,7 @@ export const TourDetailPage = ({ onBack }: { onBack: () => void }) => {
</div>
</div>
</div>
<div className="flex gap-2">
{isOwner && <div className="flex gap-2">
<button
disabled={joinRequestActionId === req.id}
onClick={async () => {
@@ -775,7 +777,7 @@ export const TourDetailPage = ({ onBack }: { onBack: () => void }) => {
>
<X className="w-4 h-4" />
</button>
</div>
</div>}
</div>
))}
{joinRequests.length === 0 && (