diff --git a/frontend/src/component/user/Profile/ProfileTab/ProfileTab.tsx b/frontend/src/component/user/Profile/ProfileTab/ProfileTab.tsx index 7773da1ae1..b114af6dce 100644 --- a/frontend/src/component/user/Profile/ProfileTab/ProfileTab.tsx +++ b/frontend/src/component/user/Profile/ProfileTab/ProfileTab.tsx @@ -1,4 +1,4 @@ -import { useEffect, useState } from 'react'; +import { useEffect, useId, useState } from 'react'; import { Box, FormControl, @@ -15,12 +15,13 @@ 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, useNavigate } from 'react-router-dom'; +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'; const StyledHeader = styled('div')(({ theme }) => ({ display: 'flex', @@ -79,7 +80,6 @@ const StyledDivider = styled('div')(({ theme }) => ({ })); const StyledFormControl = styled(FormControl)(({ theme }) => ({ - marginTop: theme.spacing(1.5), width: theme.spacing(30), })); @@ -99,11 +99,21 @@ const ProjectList = styled('ul')(({ theme }) => ({ gap: theme.spacing(1), })); +const exampleDate = new Date('2014-09-29T14:50:46'); + +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 navigate = useNavigate(); const { locationSettings, setLocationSettings } = useLocationSettings(); const [currentLocale, setCurrentLocale] = useState(); + const exampleDateId = useId(); const [possibleLocales, setPossibleLocales] = useState([ 'en-US', @@ -215,30 +225,36 @@ export const ProfileTab = ({ user }: IProfileTabProps) => { This is the format used across the system for time and date - - - Date/Time formatting - - - + + + + Date/Time formatting + + + + + Example: {formatDateYMDHM(exampleDate, currentLocale)} + + {productivityReportEmailEnabled ? ( <> diff --git a/frontend/src/utils/formatDate.ts b/frontend/src/utils/formatDate.ts index fe07de1643..65fb8f9ed0 100644 --- a/frontend/src/utils/formatDate.ts +++ b/frontend/src/utils/formatDate.ts @@ -14,7 +14,7 @@ export const formatDateYMDHMS = ( export const formatDateYMDHM = ( date: number | string | Date, - locale: string, + locale?: string, timeZone?: string, ): string => { return new Date(date).toLocaleString(locale, {