import { useEffect, useId, useState } from 'react'; import { Box, FormControl, InputLabel, Select, type SelectChangeEvent, styled, Tooltip, Typography, } from '@mui/material'; import { Badge } from 'component/common/Badge/Badge'; import { UserAvatar } from 'component/common/UserAvatar/UserAvatar'; import { useProfile } from 'hooks/api/getters/useProfile/useProfile'; import { useLocationSettings } from 'hooks/useLocationSettings'; import type { IUser } from 'interfaces/user'; import TopicOutlinedIcon from '@mui/icons-material/TopicOutlined'; import { Link } from 'react-router-dom'; import { PageContent } from 'component/common/PageContent/PageContent'; import { ConditionallyRender } from 'component/common/ConditionallyRender/ConditionallyRender'; import { RoleBadge } from 'component/common/RoleBadge/RoleBadge'; import { useUiFlag } from 'hooks/useUiFlag'; import { ProductivityEmailSubscription } from './ProductivityEmailSubscription.tsx'; import { formatDateYMDHM } from 'utils/formatDate.ts'; import { defaultLocales } from '../../../../constants/defaultLocales.ts'; const StyledHeader = styled('div')(({ theme }) => ({ display: 'flex', flexDirection: 'row', alignItems: 'center', padding: theme.spacing(6), borderRadius: theme.shape.borderRadiusLarge, backgroundColor: theme.palette.background.alternative, color: theme.palette.primary.contrastText, marginBottom: theme.spacing(3), boxShadow: theme.boxShadows.primaryHeader, })); const StyledInfo = styled('div')(() => ({ flexGrow: 1, })); const StyledInfoName = styled(Typography)(({ theme }) => ({ fontSize: theme.spacing(3.75), })); const StyledAvatar = styled(UserAvatar)(({ theme }) => ({ width: theme.spacing(9.5), height: theme.spacing(9.5), marginRight: theme.spacing(3), })); const StyledSectionLabel = styled(Typography)(({ theme }) => ({ fontSize: theme.fontSizes.mainHeader, marginBottom: theme.spacing(3), })); const StyledAccess = styled('div')(({ theme }) => ({ display: 'flex', flexDirection: 'row', gap: theme.spacing(2), '& > div > p': { marginBottom: theme.spacing(1.5), }, })); const StyledBadgeLink = styled(Link)(({ theme }) => ({ ':hover,:focus-visible': { outline: 'none', '> *': { outline: `2px solid ${theme.palette.primary.main}`, }, }, })); const StyledDivider = styled('div')(({ theme }) => ({ width: '100%', height: '1px', backgroundColor: theme.palette.divider, margin: theme.spacing(3, 0), })); const StyledFormControl = styled(FormControl)(({ theme }) => ({ width: theme.spacing(30), })); const StyledInputLabel = styled(InputLabel)(({ theme }) => ({ backgroundColor: theme.palette.background.paper, })); interface IProfileTabProps { user: IUser; } const ProjectList = styled('ul')(({ theme }) => ({ listStyle: 'none', padding: 0, display: 'flex', flexFlow: 'row wrap', gap: theme.spacing(1), })); const exampleDateString = '2014-09-29T14:50:46'; const exampleDate = new Date(exampleDateString); const LocaleSelector = styled('div')(({ theme }) => ({ marginTop: theme.spacing(1.5), display: 'flex', flexFlow: 'row wrap', gap: theme.spacing(1), alignItems: 'center', })); export const ProfileTab = ({ user }: IProfileTabProps) => { const { profile, refetchProfile } = useProfile(); const { locationSettings, setLocationSettings } = useLocationSettings(); const [currentLocale, setCurrentLocale] = useState(); const exampleDateId = useId(); const [possibleLocales, setPossibleLocales] = useState([ ...defaultLocales, ]); useEffect(() => { const found = possibleLocales.find((locale) => locale .toLowerCase() .includes(locationSettings.locale.toLowerCase()), ); setCurrentLocale(found); if (!found) { setPossibleLocales((prev) => [...prev, locationSettings.locale]); } }, [locationSettings]); const changeLocale = (e: SelectChangeEvent) => { const locale = e.target.value; setCurrentLocale(locale); setLocationSettings({ locale }); }; const productivityReportEmailEnabled = useUiFlag('productivityReportEmail'); return ( <> {user.name || user.email || user.username} {user.email} Access ( <> Your root role {profile?.rootRole.name} )} /> Projects {profile?.projects.map((project) => (
  • } > {project}
  • ))} } elseShow={ No projects } />
    Date/Time Settings This is the format used across the system for time and date Date/Time formatting Example:{' '} {productivityReportEmailEnabled ? ( <> Email Settings {profile?.subscriptions && ( )} ) : null}
    ); };