import React from 'react'; import { Box, Link, Typography, Avatar, Grid, SxProps } from '@mui/material'; import { Card, CardContent, Divider, useTheme, } from '@mui/material'; import DeleteIcon from '@mui/icons-material/Delete'; import { useMediaQuery } from '@mui/material'; import { Candidate, CandidateAI } from 'types/types'; import { CopyBubble } from "components/CopyBubble"; import { rest } from 'lodash'; import { AIBanner } from 'components/ui/AIBanner'; import { useAuth } from 'hooks/AuthContext'; import { DeleteConfirmation } from '../DeleteConfirmation'; interface CandidateInfoProps { candidate: Candidate; sx?: SxProps; action?: string; elevation?: number; variant?: "small" | "normal" | null }; const CandidateInfo: React.FC = (props: CandidateInfoProps) => { const { candidate } = props; const { user, apiClient } = useAuth(); const { sx, action = '', elevation = 1, variant = "normal" } = props; const theme = useTheme(); const isMobile = useMediaQuery(theme.breakpoints.down('md')); const ai: CandidateAI | null = ('isAI' in candidate) ? candidate as CandidateAI : null; const isAdmin = user?.isAdmin; const deleteCandidate = async (candidateId: string | undefined) => { if (candidateId) { await apiClient.deleteCandidate(candidateId); } } if (!candidate) { return No user loaded.; } return ( {ai && } {isAdmin && ai && { deleteCandidate(candidate.id); }} sx={{ minWidth: 'auto', px: 2, maxHeight: "min-content", color: "red" }} action="delete" label="user" title="Delete AI user" icon= message={`Are you sure you want to delete ${candidate.username}? This action cannot be undone.`} />} .MuiTypography-root": { m: 0 } }}> { action !== '' && {action} } {candidate.fullName} {`/u/${candidate.username}`} { event.stopPropagation() }} tooltip="Copy link" content={`${window.location.origin}/u/{candidate.username}`} /> {candidate.description} {variant !== "small" && <> {candidate.location && Location: {candidate.location.city}, {candidate.location.state || candidate.location.country} } {candidate.email && Email: {candidate.email} } {candidate.phone && Phone: {candidate.phone} } } ); }; export { CandidateInfo };