Sửa lỗi frontend không load dược danh sách thêm thành viên
This commit is contained in:
Vendored
+4
-4
@@ -765,7 +765,7 @@ __decorate([
|
|||||||
__metadata("design:returntype", Promise)
|
__metadata("design:returntype", Promise)
|
||||||
], LocationController.prototype, "deleteLocation", null);
|
], LocationController.prototype, "deleteLocation", null);
|
||||||
LocationController = __decorate([
|
LocationController = __decorate([
|
||||||
(0, common_1.Controller)('v1/locations'),
|
(0, common_1.Controller)('locations'),
|
||||||
(0, common_1.UseGuards)(jwt_auth_guard_1.JwtAuthGuard),
|
(0, common_1.UseGuards)(jwt_auth_guard_1.JwtAuthGuard),
|
||||||
__metadata("design:paramtypes", [prisma_service_1.PrismaService])
|
__metadata("design:paramtypes", [prisma_service_1.PrismaService])
|
||||||
], LocationController);
|
], LocationController);
|
||||||
@@ -810,7 +810,7 @@ __decorate([
|
|||||||
__metadata("design:returntype", Promise)
|
__metadata("design:returntype", Promise)
|
||||||
], LegController.prototype, "deleteLeg", null);
|
], LegController.prototype, "deleteLeg", null);
|
||||||
LegController = __decorate([
|
LegController = __decorate([
|
||||||
(0, common_1.Controller)('v1/legs'),
|
(0, common_1.Controller)('legs'),
|
||||||
(0, common_1.UseGuards)(jwt_auth_guard_1.JwtAuthGuard),
|
(0, common_1.UseGuards)(jwt_auth_guard_1.JwtAuthGuard),
|
||||||
__metadata("design:paramtypes", [prisma_service_1.PrismaService])
|
__metadata("design:paramtypes", [prisma_service_1.PrismaService])
|
||||||
], LegController);
|
], LegController);
|
||||||
@@ -912,7 +912,7 @@ __decorate([
|
|||||||
__metadata("design:returntype", Promise)
|
__metadata("design:returntype", Promise)
|
||||||
], RoutingController.prototype, "optimize", null);
|
], RoutingController.prototype, "optimize", null);
|
||||||
RoutingController = __decorate([
|
RoutingController = __decorate([
|
||||||
(0, common_1.Controller)('v1/routing'),
|
(0, common_1.Controller)('routing'),
|
||||||
__metadata("design:paramtypes", [prisma_service_1.PrismaService])
|
__metadata("design:paramtypes", [prisma_service_1.PrismaService])
|
||||||
], RoutingController);
|
], RoutingController);
|
||||||
let UserController = class UserController {
|
let UserController = class UserController {
|
||||||
@@ -1001,7 +1001,7 @@ __decorate([
|
|||||||
__metadata("design:returntype", Promise)
|
__metadata("design:returntype", Promise)
|
||||||
], UserController.prototype, "toggleBlock", null);
|
], UserController.prototype, "toggleBlock", null);
|
||||||
UserController = __decorate([
|
UserController = __decorate([
|
||||||
(0, common_1.Controller)('v1/users'),
|
(0, common_1.Controller)('users'),
|
||||||
__metadata("design:paramtypes", [prisma_service_1.PrismaService])
|
__metadata("design:paramtypes", [prisma_service_1.PrismaService])
|
||||||
], UserController);
|
], UserController);
|
||||||
let AppModule = class AppModule {
|
let AppModule = class AppModule {
|
||||||
|
|||||||
Vendored
+1
-1
File diff suppressed because one or more lines are too long
+4
-4
@@ -587,7 +587,7 @@ class TourController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Controller('v1/locations')
|
@Controller('locations')
|
||||||
@UseGuards(JwtAuthGuard)
|
@UseGuards(JwtAuthGuard)
|
||||||
class LocationController {
|
class LocationController {
|
||||||
constructor(private prisma: PrismaService) {}
|
constructor(private prisma: PrismaService) {}
|
||||||
@@ -644,7 +644,7 @@ class LocationController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Controller('v1/legs')
|
@Controller('legs')
|
||||||
@UseGuards(JwtAuthGuard)
|
@UseGuards(JwtAuthGuard)
|
||||||
class LegController {
|
class LegController {
|
||||||
constructor(private prisma: PrismaService) {}
|
constructor(private prisma: PrismaService) {}
|
||||||
@@ -688,7 +688,7 @@ function calculateDistance(lat1: number, lon1: number, lat2: number, lon2: numbe
|
|||||||
return 12742 * Math.asin(Math.sqrt(a)); // 2 * R; R = 6371 km
|
return 12742 * Math.asin(Math.sqrt(a)); // 2 * R; R = 6371 km
|
||||||
}
|
}
|
||||||
|
|
||||||
@Controller('v1/routing')
|
@Controller('routing')
|
||||||
class RoutingController {
|
class RoutingController {
|
||||||
constructor(private prisma: PrismaService) {}
|
constructor(private prisma: PrismaService) {}
|
||||||
|
|
||||||
@@ -801,7 +801,7 @@ class RoutingController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Controller('v1/users')
|
@Controller('users')
|
||||||
class UserController {
|
class UserController {
|
||||||
constructor(private prisma: PrismaService) {}
|
constructor(private prisma: PrismaService) {}
|
||||||
|
|
||||||
|
|||||||
@@ -35,8 +35,7 @@ export const AddMemberModal: React.FC<AddMemberModalProps> = ({ isOpen, onClose,
|
|||||||
setLoading(true);
|
setLoading(true);
|
||||||
setFetchError('');
|
setFetchError('');
|
||||||
try {
|
try {
|
||||||
const API_BASE = `http://${window.location.hostname}:3001`;
|
const res = await fetch(`/api/v1/users?q=${encodeURIComponent(query)}`, {
|
||||||
const res = await fetch(`${API_BASE}/api/v1/users?q=${encodeURIComponent(query)}`, {
|
|
||||||
headers: { 'Authorization': `Bearer ${localStorage.getItem('token')}` }
|
headers: { 'Authorization': `Bearer ${localStorage.getItem('token')}` }
|
||||||
});
|
});
|
||||||
if (!res.ok) throw new Error('Không thể tải danh sách người dùng');
|
if (!res.ok) throw new Error('Không thể tải danh sách người dùng');
|
||||||
@@ -86,10 +85,9 @@ export const AddMemberModal: React.FC<AddMemberModalProps> = ({ isOpen, onClose,
|
|||||||
if (!onMemberAdded) return;
|
if (!onMemberAdded) return;
|
||||||
setActionLoading(reqId);
|
setActionLoading(reqId);
|
||||||
try {
|
try {
|
||||||
const API_BASE = `http://${window.location.hostname}:3001`;
|
|
||||||
const endpoint = action === 'accept'
|
const endpoint = action === 'accept'
|
||||||
? `${API_BASE}/api/v1/tours/${tourId}/join-requests/${reqId}/accept`
|
? `/api/v1/tours/${tourId}/join-requests/${reqId}/accept`
|
||||||
: `${API_BASE}/api/v1/tours/${tourId}/join-requests/${reqId}/reject`;
|
: `/api/v1/tours/${tourId}/join-requests/${reqId}/reject`;
|
||||||
const res = await fetch(endpoint, {
|
const res = await fetch(endpoint, {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: { 'Authorization': `Bearer ${localStorage.getItem('token')}` },
|
headers: { 'Authorization': `Bearer ${localStorage.getItem('token')}` },
|
||||||
@@ -111,12 +109,11 @@ export const AddMemberModal: React.FC<AddMemberModalProps> = ({ isOpen, onClose,
|
|||||||
setSubmitting(true);
|
setSubmitting(true);
|
||||||
setSubmitError('');
|
setSubmitError('');
|
||||||
try {
|
try {
|
||||||
const API_BASE = `http://${window.location.hostname}:3001`;
|
|
||||||
const endpoint = canCreateDirectly ? `/api/v1/tours/${tourId}/members` : `/api/v1/tours/${tourId}/join-requests`;
|
const endpoint = canCreateDirectly ? `/api/v1/tours/${tourId}/members` : `/api/v1/tours/${tourId}/join-requests`;
|
||||||
const body = canCreateDirectly
|
const body = canCreateDirectly
|
||||||
? { userId: selectedUser, role }
|
? { userId: selectedUser, role }
|
||||||
: { userId: selectedUser };
|
: { userId: selectedUser };
|
||||||
const res = await fetch(`${API_BASE}${endpoint}`, {
|
const res = await fetch(`${endpoint}`, {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: {
|
headers: {
|
||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
|
|||||||
@@ -14,8 +14,7 @@ export const UserManagementModal: React.FC<UserManagementModalProps> = ({ isOpen
|
|||||||
const fetchUsers = async () => {
|
const fetchUsers = async () => {
|
||||||
setLoading(true);
|
setLoading(true);
|
||||||
try {
|
try {
|
||||||
const API_BASE = `http://${window.location.hostname}:3001`;
|
const response = await fetch(`/api/v1/users`, {
|
||||||
const response = await fetch(`${API_BASE}/api/v1/users`, {
|
|
||||||
headers: { 'Authorization': `Bearer ${localStorage.getItem('token')}` }
|
headers: { 'Authorization': `Bearer ${localStorage.getItem('token')}` }
|
||||||
});
|
});
|
||||||
if (!response.ok) throw new Error('Không thể tải danh sách người dùng');
|
if (!response.ok) throw new Error('Không thể tải danh sách người dùng');
|
||||||
@@ -34,8 +33,7 @@ export const UserManagementModal: React.FC<UserManagementModalProps> = ({ isOpen
|
|||||||
|
|
||||||
const handleToggleBlock = async (id: string) => {
|
const handleToggleBlock = async (id: string) => {
|
||||||
try {
|
try {
|
||||||
const API_BASE = `http://${window.location.hostname}:3001`;
|
await fetch(`/api/v1/users/block/${id}`, {
|
||||||
await fetch(`${API_BASE}/api/v1/users/block/${id}`, {
|
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: { 'Authorization': `Bearer ${localStorage.getItem('token')}` }
|
headers: { 'Authorization': `Bearer ${localStorage.getItem('token')}` }
|
||||||
});
|
});
|
||||||
@@ -48,8 +46,7 @@ export const UserManagementModal: React.FC<UserManagementModalProps> = ({ isOpen
|
|||||||
const handleDelete = async (id: string) => {
|
const handleDelete = async (id: string) => {
|
||||||
if (!confirm('Bạn có chắc chắn muốn xóa người dùng này?')) return;
|
if (!confirm('Bạn có chắc chắn muốn xóa người dùng này?')) return;
|
||||||
try {
|
try {
|
||||||
const API_BASE = `http://${window.location.hostname}:3001`;
|
const res = await fetch(`/api/v1/users/${id}`, {
|
||||||
const res = await fetch(`${API_BASE}/api/v1/users/${id}`, {
|
|
||||||
method: 'DELETE',
|
method: 'DELETE',
|
||||||
headers: { 'Authorization': `Bearer ${localStorage.getItem('token')}` }
|
headers: { 'Authorization': `Bearer ${localStorage.getItem('token')}` }
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user