diff --git a/app/Services/MenuService.php b/app/Services/MenuService.php index 3868399c..3746bb44 100644 --- a/app/Services/MenuService.php +++ b/app/Services/MenuService.php @@ -322,10 +322,10 @@ public function forceDeleteMenu(int $id): array ->toArray(); // 아카이브 레코드 생성 - $batchId = 'menu_delete_'.Str::uuid(); + $batchId = (string) Str::uuid(); $archivedRecord = ArchivedRecord::create([ 'batch_id' => $batchId, - 'batch_description' => "메뉴 삭제: {$menu->name} (ID: {$menu->id})", + 'batch_description' => "메뉴 영구 삭제: {$menu->name} (ID: {$menu->id})", 'record_type' => 'menu', 'tenant_id' => $menu->tenant_id, 'original_id' => $menu->id, @@ -720,10 +720,10 @@ public function forceDeleteGlobalMenu(int $id): array ->toArray(); // 아카이브 레코드 생성 - $batchId = 'global_menu_delete_'.Str::uuid(); + $batchId = (string) Str::uuid(); $archivedRecord = ArchivedRecord::create([ 'batch_id' => $batchId, - 'batch_description' => "글로벌 메뉴 삭제: {$menu->name} (ID: {$menu->id})", + 'batch_description' => "글로벌 메뉴 영구 삭제: {$menu->name} (ID: {$menu->id})", 'record_type' => 'global_menu', 'tenant_id' => null, 'original_id' => $menu->id, diff --git a/resources/views/menus/global-index.blade.php b/resources/views/menus/global-index.blade.php index fec76682..570ec817 100644 --- a/resources/views/menus/global-index.blade.php +++ b/resources/views/menus/global-index.blade.php @@ -210,14 +210,26 @@ function saveGlobalMenuOrder(items) { // 영구삭제 확인 window.confirmForceDelete = function(id, name) { showPermanentDeleteConfirm(name, () => { - htmx.ajax('DELETE', `/api/admin/global-menus/${id}/force`, { - target: '#menu-table', - swap: 'none', + fetch(`/api/admin/global-menus/${id}/force`, { + method: 'DELETE', headers: { - 'X-CSRF-TOKEN': '{{ csrf_token() }}' + 'X-CSRF-TOKEN': '{{ csrf_token() }}', + 'Accept': 'application/json', + 'Content-Type': 'application/json' } - }).then(() => { - htmx.trigger('#menu-table', 'filterSubmit'); + }) + .then(response => response.json().then(data => ({ ok: response.ok, data }))) + .then(({ ok, data }) => { + if (ok && data.success) { + showToast(data.message || '글로벌 메뉴가 영구 삭제되었습니다.', 'success'); + htmx.trigger('#menu-table', 'filterSubmit'); + } else { + showToast(data.message || '삭제에 실패했습니다.', 'error'); + } + }) + .catch(error => { + showToast('삭제 중 오류가 발생했습니다.', 'error'); + console.error('Force delete error:', error); }); }); }; diff --git a/resources/views/menus/index.blade.php b/resources/views/menus/index.blade.php index 260f2e62..93afb9c3 100644 --- a/resources/views/menus/index.blade.php +++ b/resources/views/menus/index.blade.php @@ -593,14 +593,26 @@ function saveMenuOrder(items) { // 영구삭제 확인 window.confirmForceDelete = function(id, name) { showPermanentDeleteConfirm(name, () => { - htmx.ajax('DELETE', `/api/admin/menus/${id}/force`, { - target: '#menu-table', - swap: 'none', + fetch(`/api/admin/menus/${id}/force`, { + method: 'DELETE', headers: { - 'X-CSRF-TOKEN': '{{ csrf_token() }}' + 'X-CSRF-TOKEN': '{{ csrf_token() }}', + 'Accept': 'application/json', + 'Content-Type': 'application/json' } - }).then(() => { - htmx.trigger('#menu-table', 'filterSubmit'); + }) + .then(response => response.json().then(data => ({ ok: response.ok, data }))) + .then(({ ok, data }) => { + if (ok && data.success) { + showToast(data.message || '메뉴가 영구 삭제되었습니다.', 'success'); + htmx.trigger('#menu-table', 'filterSubmit'); + } else { + showToast(data.message || '삭제에 실패했습니다.', 'error'); + } + }) + .catch(error => { + showToast('삭제 중 오류가 발생했습니다.', 'error'); + console.error('Force delete error:', error); }); }); };