fix: khách mời join vào tour thông qua link mời

This commit is contained in:
2026-06-21 07:11:26 +07:00
parent 36157bd53b
commit 55fba75fda
5 changed files with 39 additions and 21 deletions
+14 -1
View File
@@ -51,9 +51,22 @@ export const useTourStore = create<TourState>((set, get) => ({
fetchTour: async (id: string) => {
const token = localStorage.getItem('token');
try {
const response = await fetch(`/api/v1/tours/${id}`, {
let response = await fetch(`/api/v1/tours/${id}`, {
headers: { 'Authorization': `Bearer ${token}` }
});
// Thử lại một lần nếu gặp lỗi 403 hoặc 401 (có thể do cache vai trò cũ chưa được cập nhật)
if (response.status === 403 || response.status === 401) {
await new Promise((resolve) => setTimeout(resolve, 1000));
const retryResponse = await fetch(`/api/v1/tours/${id}`, {
headers: {
'Authorization': `Bearer ${token}`,
'Cache-Control': 'no-cache'
}
});
if (retryResponse.ok) {
response = retryResponse;
}
}
if (!response.ok) throw new Error(`HTTP ${response.status}`);
const data = await response.json();
// ...existing role detection...