일정 관리 상태 복원 로직 - fromScheduleForm 플래그 방식으로 변경

- 일정 추가/수정 버튼 클릭 시 플래그 설정
- 돌아올 때 플래그가 있으면 상태 복원 후 플래그 제거
- 플래그가 없으면 상태 초기화 (새로고침/직접 진입)
This commit is contained in:
caadiq 2026-01-06 12:10:58 +09:00
parent 31f15fe20b
commit 2c766e8da6

View file

@ -21,16 +21,17 @@ function AdminSchedule() {
};
// sessionStorage
// ,
// (fromScheduleForm )
const getStoredState = () => {
try {
const navType = performance.getEntriesByType('navigation')[0]?.type;
// /
if (navType === 'back_forward') {
const fromForm = sessionStorage.getItem('fromScheduleForm');
if (fromForm) {
//
sessionStorage.removeItem('fromScheduleForm');
const stored = sessionStorage.getItem('adminScheduleState');
return stored ? JSON.parse(stored) : null;
}
// (reload, navigate)
//
sessionStorage.removeItem('adminScheduleState');
return null;
} catch { return null; }
@ -523,7 +524,10 @@ function AdminSchedule() {
관리
</button>
<button
onClick={() => navigate('/admin/schedule/new')}
onClick={() => {
sessionStorage.setItem('fromScheduleForm', 'true');
navigate('/admin/schedule/new');
}}
className="flex items-center gap-2 px-5 py-3 bg-primary text-white rounded-xl hover:bg-primary-dark transition-colors font-medium shadow-sm"
>
<Plus size={20} />
@ -1070,7 +1074,10 @@ function AdminSchedule() {
</a>
)}
<button
onClick={() => navigate(`/admin/schedule/${schedule.id}/edit`)}
onClick={() => {
sessionStorage.setItem('fromScheduleForm', 'true');
navigate(`/admin/schedule/${schedule.id}/edit`);
}}
className="p-2 hover:bg-gray-200 rounded-lg transition-colors text-gray-500"
>
<Edit2 size={18} />