결제, 구독 기능

This commit is contained in:
2025-05-11 17:27:39 +09:00
parent 2924a61a9d
commit 1db3a03ffd
18 changed files with 3276 additions and 180 deletions
+35 -2
View File
@@ -37,9 +37,42 @@ apiClient.interceptors.response.use(
if (error.response && error.response.status === 401) {
// 로컬 스토리지에서 토큰 제거
localStorage.removeItem('token');
// 로그인 페이지로 리디렉션
window.location.href = '/login';
localStorage.removeItem('user');
// 현재 페이지가 이미 로그인 페이지가 아닌 경우에만 리디렉션
const currentPath = window.location.pathname;
if (currentPath !== '/login') {
// 로그인 페이지로 리디렉션
window.location.href = '/login';
}
}
// 403 에러 (권한 없음) 처리
if (error.response && error.response.status === 403) {
// 구독 관련 오류 메시지인지 확인
const errorMessage = error.response.data?.error || '';
if (errorMessage.includes('기능을 사용할 수 없습니다') ||
errorMessage.includes('권한이 없습니다')) {
// 사용자에게 구독 안내 표시
import('primevue/usetoast').then(({ useToast }) => {
const toast = useToast();
toast.add({
severity: 'warn',
summary: '권한 없음',
detail: '해당 기능을 사용하려면 구독이 필요합니다. 구독 페이지로 이동합니다.',
life: 5000
});
});
// 3초 후 구독 페이지로 이동
setTimeout(() => {
const clubId = localStorage.getItem('clubId');
window.location.href = `/club/subscription`;
}, 3000);
}
}
return Promise.reject(error);
}
);
+7 -2
View File
@@ -19,8 +19,13 @@ export default {
const response = await apiClient.post('/api/club/events', { clubId });
return response.data;
} catch (error) {
if (error.response && error.response.data && error.response.data.message) {
throw new Error(error.response.data.message);
// 원래 오류 객체 그대로 전달하여 HTTP 상태 코드 확인 가능하게 함
if (error.response) {
console.error('이벤트 목록 오류:', {
status: error.response.status,
data: error.response.data
});
throw error;
}
throw error;
}