import React, { useState } from 'react'; import { Box, Typography, Paper, Tabs, Tab, Table, TableBody, TableCell, TableContainer, TableHead, TableRow, Chip, Button, Dialog, DialogTitle, DialogContent, DialogActions, TextField, MenuItem, Select, FormControl, InputLabel, Grid } from '@mui/material'; import { Person, Business, AssignmentInd } from '@mui/icons-material'; // Interfaces from the data model interface BaseUser { id: string; email: string; createdAt: Date; lastLogin: Date; profileImage?: string; isActive: boolean; } interface Candidate extends BaseUser { type: 'candidate'; firstName: string; lastName: string; skills: { id: string; name: string; level: string }[]; location: { city: string; country: string; remote?: boolean }; } interface Employer extends BaseUser { type: 'employer'; companyName: string; industry: string; companySize: string; location: { city: string; country: string }; companyLogo?: string; } type User = Candidate | Employer; // Mock data const mockUsers: User[] = [ { id: '1', email: 'john.doe@example.com', createdAt: new Date('2023-08-15'), lastLogin: new Date('2023-10-22'), isActive: true, type: 'candidate', firstName: 'John', lastName: 'Doe', skills: [ { id: 's1', name: 'React', level: 'advanced' }, { id: 's2', name: 'TypeScript', level: 'intermediate' } ], location: { city: 'Austin', country: 'USA' } }, { id: '2', email: 'sarah.smith@example.com', createdAt: new Date('2023-09-10'), lastLogin: new Date('2023-10-24'), isActive: true, type: 'candidate', firstName: 'Sarah', lastName: 'Smith', skills: [ { id: 's3', name: 'Python', level: 'expert' }, { id: 's4', name: 'Data Science', level: 'advanced' } ], location: { city: 'Seattle', country: 'USA', remote: true } }, { id: '3', email: 'tech@acme.com', createdAt: new Date('2023-07-05'), lastLogin: new Date('2023-10-23'), isActive: true, type: 'employer', companyName: 'Acme Tech', industry: 'Software', companySize: '50-200', location: { city: 'San Francisco', country: 'USA' } }, { id: '4', email: 'careers@globex.com', createdAt: new Date('2023-08-20'), lastLogin: new Date('2023-10-20'), isActive: false, type: 'employer', companyName: 'Globex Corporation', industry: 'Manufacturing', companySize: '1000+', location: { city: 'Chicago', country: 'USA' } } ]; // Component for User Management const UserManagement: React.FC = () => { const [tabValue, setTabValue] = useState(0); const [users, setUsers] = useState(mockUsers); const [openDialog, setOpenDialog] = useState(false); const [selectedUser, setSelectedUser] = useState(null); const [aiConfigOpen, setAiConfigOpen] = useState(false); // Handle tab change const handleTabChange = (event: React.SyntheticEvent, newValue: number) => { setTabValue(newValue); }; // Filter users based on tab value const filteredUsers = users.filter(user => { if (tabValue === 0) return true; if (tabValue === 1) return user.type === 'candidate'; if (tabValue === 2) return user.type === 'employer'; return false; }); // Handle open user detail dialog const handleOpenUserDetails = (user: User) => { setSelectedUser(user); setOpenDialog(true); }; // Handle close user detail dialog const handleCloseDialog = () => { setOpenDialog(false); setSelectedUser(null); }; // Handle open AI configuration dialog const handleOpenAiConfig = (user: User) => { setSelectedUser(user); setAiConfigOpen(true); }; // Handle close AI configuration dialog const handleCloseAiConfig = () => { setAiConfigOpen(false); }; // Helper function to get user's name for display const getUserDisplayName = (user: User) => { if (user.type === 'candidate') { return `${user.firstName} ${user.lastName}`; } else { return user.companyName; } }; // Helper function to format date const formatDate = (date: Date) => { return new Date(date).toLocaleDateString(); }; return ( } label="All Users" /> } label="Candidates" /> } label="Employers" /> User Type {/* Location */} {/* Created */} Last Login Status Actions {filteredUsers.map((user) => ( td": { whiteSpace: "nowrap"}}}> {getUserDisplayName(user)} {/* {user.location.city}, {user.location.country} {user.type === 'candidate' && user.location.remote && } */} {/* {formatDate(user.createdAt)} */} {formatDate(user.lastLogin)} ))}
{/* User Details Dialog */} {selectedUser && ( <> {selectedUser.type === 'candidate' ? 'Candidate Details' : 'Employer Details'} {selectedUser.type === 'candidate' ? ( Personal Information Skills {selectedUser.skills.map((skill) => ( ))} ) : ( Company Information Contact Information )} )} {/* AI Config Dialog */} {selectedUser && ( <> AI Configuration for {getUserDisplayName(selectedUser)} RAG Database Configuration Embedding Model Vector Store AI Model Parameters AI Model Data Sources Source Name Type Status Last Refreshed Profile Data Internal Auto Company Documents Document 10/20/2024 Industry News Web Crawler Daily
)}
); }; export { UserManagement };