feat: Implement admin user management features

- Added adminCreateUser endpoint and corresponding DTO for creating users.
- Implemented deleteUser and resetPassword functionalities for admin users.
- Introduced updateEmail functionality for admin users.
- Updated UsersService to handle user creation, deletion, password reset, and email updates.
- Modified UsersController to include new admin routes with appropriate role checks.
- Refactored frontend navigation to link to user management under profile.
- Created new profile tabs for user management and database management.
- Developed AnvandareClient component for user management, including user creation, deletion, role changes, and password resets.
- Added DatabsTab for managing product listings and merging duplicates.
- Enhanced MinProfilTab for user profile management with form handling.
This commit is contained in:
Nils-Johan Gynther
2026-04-18 14:49:02 +02:00
parent 00dc0d6c69
commit 537a4f8ab6
16 changed files with 1141 additions and 66 deletions
+28 -4
View File
@@ -1,16 +1,40 @@
import { auth } from '../../auth';
import Navigation from '../Navigation';
import ProfileClient from './ProfileClient';
import ProfileTabs from './ProfileTabs';
import MinProfilTab from './tabs/MinProfilTab';
export const metadata = { title: 'Min profil' };
export default function ProfilPage() {
type Props = {
searchParams: Promise<{ tab?: string }>;
};
export default async function ProfilPage({ searchParams }: Props) {
const { tab = 'profil' } = await searchParams;
const session = await auth();
const isAdmin = (session?.user as any)?.role === 'admin';
// DatabsTab och AnvandareTab laddas dynamiskt för att hålla page.tsx tunn
let TabContent: React.ComponentType;
if (tab === 'databas' && isAdmin) {
const { default: DatabsTab } = await import('./tabs/DatabsTab');
TabContent = DatabsTab;
} else if (tab === 'anvandare' && isAdmin) {
const { default: AnvandareTab } = await import('./tabs/AnvandareTab');
TabContent = AnvandareTab;
} else {
TabContent = MinProfilTab;
}
return (
<>
<Navigation />
<main style={{ padding: '1rem', maxWidth: '800px', margin: '0 auto' }}>
<main style={{ padding: '1rem', maxWidth: '1200px', margin: '0 auto' }}>
<h1 style={{ marginBottom: '1.5rem' }}>Min profil</h1>
<ProfileClient />
<ProfileTabs activeTab={tab === 'databas' || tab === 'anvandare' ? tab : 'profil'} isAdmin={isAdmin} />
<TabContent />
</main>
</>
);
}