diff --git a/ui/dev-dist/sw.js b/ui/dev-dist/sw.js index 9f2efa82..d12408cc 100644 --- a/ui/dev-dist/sw.js +++ b/ui/dev-dist/sw.js @@ -82,7 +82,7 @@ define(['./workbox-54d0af47'], (function (workbox) { 'use strict'; "revision": "3ca0b8505b4bec776b69afdba2768812" }, { "url": "index.html", - "revision": "0.3kkdvt11rc8" + "revision": "0.edm7dfkr7s" }], {}); workbox.cleanupOutdatedCaches(); workbox.registerRoute(new workbox.NavigationRoute(workbox.createHandlerBoundToURL("index.html"), { diff --git a/ui/src/views/forum/Forum.tsx b/ui/src/views/forum/Forum.tsx index 11d5bacb..13b08689 100644 --- a/ui/src/views/forum/Forum.tsx +++ b/ui/src/views/forum/Forum.tsx @@ -5,7 +5,7 @@ import { useForumData } from './useForumData' import { ForumView } from './forum/ForumView' export function Forum() { - const { user, tenantId } = useStoreState((state) => state.auth) + const { user, tenant } = useStoreState((state) => state.auth) const { categories, topics, diff --git a/ui/src/views/forum/Management.tsx b/ui/src/views/forum/Management.tsx index 4c00e1f4..be21e5ae 100644 --- a/ui/src/views/forum/Management.tsx +++ b/ui/src/views/forum/Management.tsx @@ -5,7 +5,6 @@ import { useForumData } from './useForumData' import { AdminView } from './admin/AdminView' export function Management() { - const { user, tenantId } = useStoreState((state) => state.auth) const { categories, topics, @@ -34,12 +33,6 @@ export function Management() { clearError, } = useForumData() - const [selectedCategory, setSelectedCategory] = useState(null) - const [selectedTopic, setSelectedTopic] = useState(null) - const [forumViewState, setForumViewState] = useState<'categories' | 'topics' | 'posts'>( - 'categories', - ) - useEffect(() => { const handleKeyDown = (e: KeyboardEvent) => { if ((e.metaKey || e.ctrlKey) && e.key === 'k') { diff --git a/ui/src/views/forum/admin/CategoryManagement.tsx b/ui/src/views/forum/admin/CategoryManagement.tsx index 03d482e2..0fae864c 100644 --- a/ui/src/views/forum/admin/CategoryManagement.tsx +++ b/ui/src/views/forum/admin/CategoryManagement.tsx @@ -1,36 +1,39 @@ -import React, { useState } from 'react'; -import { Plus, Edit2, Trash2, Lock, Unlock, Eye, EyeOff, Loader2 } from 'lucide-react'; -import { ForumCategory } from '@/proxy/forum/forum'; +import React, { useState } from 'react' +import { Plus, Edit2, Trash2, Lock, Unlock, Eye, EyeOff, Loader2 } from 'lucide-react' +import { ForumCategory } from '@/proxy/forum/forum' +import { useStoreState } from '@/store/store' interface CategoryManagementProps { - categories: ForumCategory[]; - loading: boolean; + categories: ForumCategory[] + loading: boolean onCreateCategory: (category: { - name: string; - slug: string; - description: string; - icon: string; - displayOrder: number; - isActive: boolean; - isLocked: boolean; - }) => Promise; - onUpdateCategory: (id: string, category: Partial) => Promise; - onDeleteCategory: (id: string) => Promise; - onUpdateCategoryLockState: (id: string) => Promise; - onUpdateCategoryActiveState: (id: string) => Promise; + name: string + slug: string + description: string + icon: string + displayOrder: number + isActive: boolean + isLocked: boolean + tenantId?: string + }) => Promise + onUpdateCategory: (id: string, category: Partial) => Promise + onDeleteCategory: (id: string) => Promise + onUpdateCategoryLockState: (id: string) => Promise + onUpdateCategoryActiveState: (id: string) => Promise } -export function CategoryManagement({ - categories, +export function CategoryManagement({ + categories, loading, - onCreateCategory, - onUpdateCategory, + onCreateCategory, + onUpdateCategory, onDeleteCategory, onUpdateCategoryLockState, - onUpdateCategoryActiveState + onUpdateCategoryActiveState, }: CategoryManagementProps) { - const [showCreateForm, setShowCreateForm] = useState(false); - const [editingCategory, setEditingCategory] = useState(null); + const { tenant } = useStoreState((state) => state.auth) + const [showCreateForm, setShowCreateForm] = useState(false) + const [editingCategory, setEditingCategory] = useState(null) const [formData, setFormData] = useState({ name: '', slug: '', @@ -39,8 +42,9 @@ export function CategoryManagement({ displayOrder: 0, isActive: true, isLocked: false, - }); - const [submitting, setSubmitting] = useState(false); + tenantId: '' + }) + const [submitting, setSubmitting] = useState(false) const resetForm = () => { setFormData({ @@ -51,32 +55,33 @@ export function CategoryManagement({ displayOrder: 0, isActive: true, isLocked: false, - }); - setShowCreateForm(false); - setEditingCategory(null); - }; + tenantId: '' + }) + setShowCreateForm(false) + setEditingCategory(null) + } const handleSubmit = async (e: React.FormEvent) => { - e.preventDefault(); - if (submitting) return; + e.preventDefault() + if (submitting) return try { - setSubmitting(true); + setSubmitting(true) if (editingCategory) { - await onUpdateCategory(editingCategory.id, formData); + await onUpdateCategory(editingCategory.id, formData) } else { - await onCreateCategory(formData); + await onCreateCategory(formData) } - resetForm(); + resetForm() } catch (error) { - console.error('Error submitting form:', error); + console.error('Error submitting form:', error) } finally { - setSubmitting(false); + setSubmitting(false) } - }; + } const handleEdit = (category: ForumCategory) => { - setEditingCategory(category); + setEditingCategory(category) setFormData({ name: category.name, slug: category.slug, @@ -85,35 +90,40 @@ export function CategoryManagement({ displayOrder: category.displayOrder, isActive: category.isActive, isLocked: category.isLocked, - }); - setShowCreateForm(true); - }; + tenantId: tenant.tenantId ?? '' + }) + setShowCreateForm(true) + } const handleToggleActive = async (category: ForumCategory) => { try { - await onUpdateCategoryActiveState(category.id); + await onUpdateCategoryActiveState(category.id) } catch (error) { - console.error('Error toggling category status:', error); + console.error('Error toggling category status:', error) } - }; + } const handleToggleLocked = async (category: ForumCategory) => { try { - await onUpdateCategoryLockState(category.id); + await onUpdateCategoryLockState(category.id) } catch (error) { - console.error('Error toggling category lock:', error); + console.error('Error toggling category lock:', error) } - }; + } const handleDelete = async (id: string) => { - if (confirm('Are you sure you want to delete this category? This will also delete all topics and posts in this category.')) { + if ( + confirm( + 'Are you sure you want to delete this category? This will also delete all topics and posts in this category.', + ) + ) { try { - await onDeleteCategory(id); + await onDeleteCategory(id) } catch (error) { - console.error('Error deleting category:', error); + console.error('Error deleting category:', error) } } - }; + } return (
@@ -158,7 +168,7 @@ export function CategoryManagement({ />
- +