generated from pricelees/issue-pr-template
fix: 프론트엔드 배포시 빌드 과정에서 발생하는 문제 수정
This commit is contained in:
parent
8a6cb277b5
commit
336d41c589
@ -1,28 +0,0 @@
|
|||||||
import React from 'react';
|
|
||||||
import {Navigate, useLocation} from 'react-router-dom';
|
|
||||||
import {useAuth} from '../context/AuthContext';
|
|
||||||
|
|
||||||
const AdminRoute: React.FC<{ children: JSX.Element }> = ({ children }) => {
|
|
||||||
const { loggedIn, role, loading } = useAuth();
|
|
||||||
const location = useLocation();
|
|
||||||
|
|
||||||
if (loading) {
|
|
||||||
return <div>Loading...</div>; // Or a proper spinner component
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!loggedIn) {
|
|
||||||
// Not logged in, redirect to login page. No alert needed here
|
|
||||||
// as the user is simply redirected.
|
|
||||||
return <Navigate to="/login" state={{ from: location }} replace />;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (role !== 'ADMIN') {
|
|
||||||
// Logged in but not an admin, show alert and redirect.
|
|
||||||
alert('접근 권한이 없어요. 관리자에게 문의해주세요.');
|
|
||||||
return <Navigate to="/" replace />;
|
|
||||||
}
|
|
||||||
|
|
||||||
return children;
|
|
||||||
};
|
|
||||||
|
|
||||||
export default AdminRoute;
|
|
||||||
@ -1,5 +1,5 @@
|
|||||||
import {isLoginRequiredError} from '@_api/apiClient';
|
import { isLoginRequiredError } from '@_api/apiClient';
|
||||||
import type {AuditInfo} from '@_api/common/commonTypes';
|
import type { AuditInfo } from '@_api/common/commonTypes';
|
||||||
import {
|
import {
|
||||||
createSchedule,
|
createSchedule,
|
||||||
deleteSchedule,
|
deleteSchedule,
|
||||||
@ -7,15 +7,15 @@ import {
|
|||||||
fetchScheduleAudit,
|
fetchScheduleAudit,
|
||||||
updateSchedule
|
updateSchedule
|
||||||
} from '@_api/schedule/scheduleAPI';
|
} from '@_api/schedule/scheduleAPI';
|
||||||
import {type AdminScheduleSummaryResponse, ScheduleStatus,} from '@_api/schedule/scheduleTypes';
|
import { type AdminScheduleSummaryResponse, ScheduleStatus, } from '@_api/schedule/scheduleTypes';
|
||||||
import {getStores} from '@_api/store/storeAPI';
|
import { getStores } from '@_api/store/storeAPI';
|
||||||
import {type SimpleStoreResponse} from '@_api/store/storeTypes';
|
import { type SimpleStoreResponse } from '@_api/store/storeTypes';
|
||||||
import {fetchActiveThemes, fetchThemeById} from '@_api/theme/themeAPI';
|
import { fetchActiveThemes } from '@_api/theme/themeAPI';
|
||||||
import {DifficultyKoreanMap, type SimpleActiveThemeResponse, type ThemeInfoResponse} from '@_api/theme/themeTypes';
|
import { DifficultyKoreanMap, type SimpleActiveThemeResponse, type ThemeInfoResponse } from '@_api/theme/themeTypes';
|
||||||
import {useAdminAuth} from '@_context/AdminAuthContext';
|
import { useAdminAuth } from '@_context/AdminAuthContext';
|
||||||
import '@_css/admin-schedule-page.css';
|
import '@_css/admin-schedule-page.css';
|
||||||
import React, {Fragment, useEffect, useState} from 'react';
|
import React, { Fragment, useEffect, useState } from 'react';
|
||||||
import {useLocation, useNavigate} from 'react-router-dom';
|
import { useLocation, useNavigate } from 'react-router-dom';
|
||||||
|
|
||||||
const getScheduleStatusText = (status: ScheduleStatus): string => {
|
const getScheduleStatusText = (status: ScheduleStatus): string => {
|
||||||
switch (status) {
|
switch (status) {
|
||||||
@ -53,8 +53,8 @@ const AdminSchedulePage: React.FC = () => {
|
|||||||
const [editingSchedule, setEditingSchedule] = useState<EditingSchedule | null>(null);
|
const [editingSchedule, setEditingSchedule] = useState<EditingSchedule | null>(null);
|
||||||
|
|
||||||
const [isModalOpen, setIsModalOpen] = useState(false);
|
const [isModalOpen, setIsModalOpen] = useState(false);
|
||||||
const [selectedThemeDetails, setSelectedThemeDetails] = useState<ThemeInfoResponse | null>(null);
|
const [selectedThemeDetails] = useState<ThemeInfoResponse | null>(null);
|
||||||
const [isLoadingThemeDetails, setIsLoadingThemeDetails] = useState<boolean>(false);
|
const [isLoadingThemeDetails] = useState<boolean>(false);
|
||||||
|
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
const location = useLocation();
|
const location = useLocation();
|
||||||
|
|||||||
@ -19,7 +19,6 @@
|
|||||||
"strict": true,
|
"strict": true,
|
||||||
"noUnusedLocals": true,
|
"noUnusedLocals": true,
|
||||||
"noUnusedParameters": true,
|
"noUnusedParameters": true,
|
||||||
"erasableSyntaxOnly": true,
|
|
||||||
"noFallthroughCasesInSwitch": true,
|
"noFallthroughCasesInSwitch": true,
|
||||||
"noUncheckedSideEffectImports": true,
|
"noUncheckedSideEffectImports": true,
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user