feat(role): add 'verwaltung' role with gated access to settings and tools
All checks were successful
Staging Build / build (push) Successful in 3m26s
All checks were successful
Staging Build / build (push) Successful in 3m26s
This commit is contained in:
@@ -30,7 +30,7 @@ import { Plus, Building2 } from 'lucide-react'
|
||||
|
||||
const userSchema = z.object({
|
||||
email: z.string().email('Ungültige E-Mail-Adresse'),
|
||||
role: z.enum(['admin', 'partner']),
|
||||
role: z.enum(['admin', 'partner', 'verwaltung']),
|
||||
company_id: z.string().optional().or(z.literal('')),
|
||||
first_name: z.string().optional().or(z.literal('')),
|
||||
last_name: z.string().optional().or(z.literal('')),
|
||||
@@ -185,6 +185,7 @@ export function UserDialog({ companies }: UserDialogProps) {
|
||||
>
|
||||
<option value="partner" className="bg-white dark:bg-slate-900 text-slate-900 dark:text-slate-100">Partner</option>
|
||||
<option value="admin" className="bg-white dark:bg-slate-900 text-slate-900 dark:text-slate-100">Admin</option>
|
||||
<option value="verwaltung" className="bg-white dark:bg-slate-900 text-slate-900 dark:text-slate-100">Verwaltung</option>
|
||||
</select>
|
||||
</FormControl>
|
||||
<FormMessage />
|
||||
|
||||
@@ -17,17 +17,19 @@ import { deleteUser, resetPassword, updateUserRole, updateUserProfile } from '@/
|
||||
import { assignCompanyToUser } from '@/lib/actions/companies'
|
||||
import { Badge } from '@/components/ui/badge'
|
||||
|
||||
type Role = 'admin' | 'partner' | 'gesperrt'
|
||||
type Role = 'admin' | 'partner' | 'verwaltung' | 'gesperrt'
|
||||
|
||||
const ROLE_LABELS: Record<Role, string> = {
|
||||
admin: 'Admin',
|
||||
partner: 'Partner',
|
||||
verwaltung: 'Verwaltung',
|
||||
gesperrt: 'Gesperrt',
|
||||
}
|
||||
|
||||
const ROLE_BADGE_CLASSES: Record<Role, string> = {
|
||||
admin: 'bg-purple-500/20 text-purple-400 border border-purple-500/30',
|
||||
partner: 'bg-blue-500/20 text-blue-400 border border-blue-500/30',
|
||||
verwaltung: 'bg-emerald-500/20 text-emerald-400 border border-emerald-500/30',
|
||||
gesperrt: 'bg-red-500/20 text-red-400 border border-red-500/30',
|
||||
}
|
||||
|
||||
@@ -205,7 +207,7 @@ export function UserList({ initialUsers, companies }: UserListProps) {
|
||||
</TableHeader>
|
||||
<TableBody>
|
||||
{displayUsers.map((user: any) => {
|
||||
const role: Role = (['admin', 'partner', 'gesperrt'].includes(user.role) ? user.role : 'partner') as Role
|
||||
const role: Role = (['admin', 'partner', 'verwaltung', 'gesperrt'].includes(user.role) ? user.role : 'partner') as Role
|
||||
const isLoadingRole = loadingId === user.id + '-role'
|
||||
const isLoadingCompany = loadingId === user.id + '-company'
|
||||
const isLoadingDelete = loadingId === user.id
|
||||
@@ -288,14 +290,17 @@ export function UserList({ initialUsers, companies }: UserListProps) {
|
||||
onChange={(e) => handleRoleChange(user.id, e.target.value as Role)}
|
||||
className={`text-xs font-semibold rounded px-3 py-1.5 cursor-pointer focus:outline-none focus:ring-2 transition-colors bg-white dark:bg-slate-950/80 ${role === 'admin'
|
||||
? 'text-purple-600 dark:text-purple-300 border border-purple-500/40 focus:ring-purple-500/50'
|
||||
: role === 'gesperrt'
|
||||
? 'text-red-600 dark:text-red-300 border border-red-500/40 focus:ring-red-500/50'
|
||||
: 'text-blue-600 dark:text-blue-300 border border-blue-500/40 focus:ring-blue-500/50'
|
||||
: role === 'verwaltung'
|
||||
? 'text-emerald-600 dark:text-emerald-300 border border-emerald-500/40 focus:ring-emerald-500/50'
|
||||
: role === 'gesperrt'
|
||||
? 'text-red-600 dark:text-red-300 border border-red-500/40 focus:ring-red-500/50'
|
||||
: 'text-blue-600 dark:text-blue-300 border border-blue-500/40 focus:ring-blue-500/50'
|
||||
}`}
|
||||
style={{ appearance: 'auto' }}
|
||||
>
|
||||
<option value="admin" className="bg-white dark:bg-slate-900 text-slate-900 dark:text-slate-100">Admin</option>
|
||||
<option value="partner" className="bg-white dark:bg-slate-900 text-slate-900 dark:text-slate-100">Partner</option>
|
||||
<option value="verwaltung" className="bg-white dark:bg-slate-900 text-slate-900 dark:text-slate-100">Verwaltung</option>
|
||||
<option value="gesperrt" className="bg-white dark:bg-slate-900 text-slate-900 dark:text-slate-100">Gesperrt</option>
|
||||
</select>
|
||||
)}
|
||||
|
||||
Reference in New Issue
Block a user