From 43cf55a8ef588f83b925400b902a5cf2e44b4782 Mon Sep 17 00:00:00 2001 From: parsa aghaei Date: Sat, 8 Aug 2026 18:26:05 +0330 Subject: [PATCH] fix(admin): resolve GET/PUT /admin/settings 404, videos.map crash, and remove legacy CMS sidebar link --- backend/src/admin/admin.controller.ts | 14 ++++++++++++++ frontend/admin-panel/src/components/Sidebar.tsx | 1 - frontend/admin-panel/src/pages/Videos.tsx | 15 ++++++++++++++- 3 files changed, 28 insertions(+), 2 deletions(-) diff --git a/backend/src/admin/admin.controller.ts b/backend/src/admin/admin.controller.ts index 1f63ff8..c1a19c9 100644 --- a/backend/src/admin/admin.controller.ts +++ b/backend/src/admin/admin.controller.ts @@ -228,4 +228,18 @@ export class AdminController { await this.adminService.deleteDoctor(id); return { success: true }; } + + @Get('settings') + @ApiOperation({ summary: 'دریافت تنظیمات کلی سیستم' }) + async getSettings() { + const data = await this.adminService.getSettings(); + return { success: true, data }; + } + + @Put('settings') + @ApiOperation({ summary: 'بروزرسانی تنظیمات کلی سیستم' }) + async updateSettings(@Body() body: Record) { + const data = await this.adminService.updateSettings(body); + return { success: true, data }; + } } diff --git a/frontend/admin-panel/src/components/Sidebar.tsx b/frontend/admin-panel/src/components/Sidebar.tsx index df1e801..ea501b8 100644 --- a/frontend/admin-panel/src/components/Sidebar.tsx +++ b/frontend/admin-panel/src/components/Sidebar.tsx @@ -41,7 +41,6 @@ const menuGroups = [ { icon: FileText, label: 'وبلاگ', path: '/blogs' }, { icon: BookOpen, label: 'دانشنامه عمومی', path: '/wiki' }, { icon: Video, label: 'مدیریت ویدئوها', path: '/videos' }, - { icon: Image, label: 'مدیریت CMS قدیم', path: '/cms' }, ] }, { diff --git a/frontend/admin-panel/src/pages/Videos.tsx b/frontend/admin-panel/src/pages/Videos.tsx index 94c94ee..379629e 100644 --- a/frontend/admin-panel/src/pages/Videos.tsx +++ b/frontend/admin-panel/src/pages/Videos.tsx @@ -45,9 +45,22 @@ export default function Videos() { api.get('/videos', { params: { search: searchTerm, limit: 100 }, }).then(res => { - if (isSubscribed) setVideos(res.data.data || res.data || []); + if (isSubscribed) { + const raw = res.data; + const videoList = Array.isArray(raw?.videos) + ? raw.videos + : Array.isArray(raw?.data?.videos) + ? raw.data.videos + : Array.isArray(raw?.data) + ? raw.data + : Array.isArray(raw) + ? raw + : []; + setVideos(videoList); + } }).catch(err => { console.error('Failed to fetch videos:', err); + if (isSubscribed) setVideos([]); }).finally(() => { if (isSubscribed) setIsLoading(false); });