af1de3d140
Backend: - internal/permissions/permissions.go: permission bitflags (VIEW_CHANNEL through SHARE_SCREEN) - internal/permissions/checker.go: permission checker with role aggregation - internal/middleware/permission.go: RequirePermission middleware - internal/push/handlers.go: push subscription CRUD, VAPID key endpoint, SendPush - internal/auth/webauthn.go: WebAuthn passkey scaffolding (begin/finish endpoints) - internal/db/db.go: is_default on roles, push_subscriptions table, webauthn_credentials table - go.mod: added webpush-go, go-webauthn dependencies Frontend: - stores/role.ts: Zustand store for role management - RoleManager.tsx: role CRUD with permission checkboxes - MemberRoleAssign.tsx: assign roles to members - App.tsx: /servers/:serverId/roles route
110 lines
4.1 KiB
TypeScript
110 lines
4.1 KiB
TypeScript
import { BrowserRouter, Routes, Route, Navigate, Link } from 'react-router-dom';
|
|
import { LoginForm } from './components/LoginForm.tsx';
|
|
import { Layout } from './components/Layout.tsx';
|
|
import { ChatArea } from './components/ChatArea.tsx';
|
|
import { UserSettings } from './components/UserSettings.tsx';
|
|
import { BotManager } from './components/BotManager.tsx';
|
|
import { CommandManager } from './components/CommandManager.tsx';
|
|
import { RoleManager } from './components/RoleManager.tsx';
|
|
import { useAuthStore } from './stores/auth.ts';
|
|
|
|
function ProtectedRoute({ children }: { children: React.ReactNode }) {
|
|
const isAuthenticated = useAuthStore((state) => state.isAuthenticated);
|
|
return isAuthenticated ? <>{children}</> : <Navigate to="/login" replace />;
|
|
}
|
|
|
|
function App() {
|
|
return (
|
|
<BrowserRouter>
|
|
<Routes>
|
|
<Route path="/login" element={<LoginForm />} />
|
|
<Route
|
|
path="/settings"
|
|
element={
|
|
<ProtectedRoute>
|
|
<div className="h-full w-full flex flex-col bg-gb-bg">
|
|
<header className="flex items-center gap-4 px-4 py-2 border-b border-gb-bg-t bg-gb-bg-s">
|
|
<Link to="/" className="text-gb-fg-f hover:text-gb-aqua font-mono text-sm">
|
|
← [BACK]
|
|
</Link>
|
|
<span className="text-gb-orange font-mono text-sm">SETTINGS</span>
|
|
</header>
|
|
<div className="flex-1 overflow-hidden">
|
|
<UserSettings />
|
|
</div>
|
|
</div>
|
|
</ProtectedRoute>
|
|
}
|
|
/>
|
|
<Route
|
|
path="/bots"
|
|
element={
|
|
<ProtectedRoute>
|
|
<div className="h-full w-full flex flex-col bg-gb-bg">
|
|
<header className="flex items-center gap-4 px-4 py-2 border-b border-gb-bg-t bg-gb-bg-s">
|
|
<Link to="/" className="text-gb-fg-f hover:text-gb-aqua font-mono text-sm">
|
|
← [BACK]
|
|
</Link>
|
|
<span className="text-gb-orange font-mono text-sm">BOT MANAGER</span>
|
|
</header>
|
|
<div className="flex-1 overflow-hidden">
|
|
<BotManager />
|
|
</div>
|
|
</div>
|
|
</ProtectedRoute>
|
|
}
|
|
/>
|
|
<Route
|
|
path="/bots/:id/commands"
|
|
element={
|
|
<ProtectedRoute>
|
|
<div className="h-full w-full flex flex-col bg-gb-bg">
|
|
<header className="flex items-center gap-4 px-4 py-2 border-b border-gb-bg-t bg-gb-bg-s">
|
|
<Link to="/bots" className="text-gb-fg-f hover:text-gb-aqua font-mono text-sm">
|
|
← [BACK]
|
|
</Link>
|
|
<span className="text-gb-orange font-mono text-sm">SLASH COMMANDS</span>
|
|
</header>
|
|
<div className="flex-1 overflow-hidden">
|
|
<CommandManager />
|
|
</div>
|
|
</div>
|
|
</ProtectedRoute>
|
|
}
|
|
/>
|
|
<Route
|
|
path="/servers/:serverId/roles"
|
|
element={
|
|
<ProtectedRoute>
|
|
<div className="h-full w-full flex flex-col bg-gb-bg">
|
|
<header className="flex items-center gap-4 px-4 py-2 border-b border-gb-bg-t bg-gb-bg-s">
|
|
<Link to="/" className="text-gb-fg-f hover:text-gb-aqua font-mono text-sm">
|
|
← [BACK]
|
|
</Link>
|
|
<span className="text-gb-orange font-mono text-sm">ROLE MANAGER</span>
|
|
</header>
|
|
<div className="flex-1 overflow-hidden">
|
|
<RoleManager />
|
|
</div>
|
|
</div>
|
|
</ProtectedRoute>
|
|
}
|
|
/>
|
|
<Route
|
|
path="/"
|
|
element={
|
|
<ProtectedRoute>
|
|
<Layout />
|
|
</ProtectedRoute>
|
|
}
|
|
>
|
|
<Route index element={<ChatArea />} />
|
|
<Route path="channels/:channelId" element={<ChatArea />} />
|
|
</Route>
|
|
</Routes>
|
|
</BrowserRouter>
|
|
);
|
|
}
|
|
|
|
export default App;
|