-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
16 changed files
with
926 additions
and
82 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
...ront/src/modules/settings/accounts/components/SettingsAccountsCalendarDisplaySettings.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import { useState } from 'react'; | ||
import styled from '@emotion/styled'; | ||
import { formatInTimeZone } from 'date-fns-tz'; | ||
|
||
import { SettingsAccountsCalendarTimeZoneSelect } from '@/settings/accounts/components/SettingsAccountsCalendarTimeZoneSelect'; | ||
import { detectTimeZone } from '@/settings/accounts/utils/detectTimeZone'; | ||
import { Select } from '@/ui/input/components/Select'; | ||
|
||
const StyledContainer = styled.div` | ||
display: flex; | ||
flex-direction: column; | ||
gap: ${({ theme }) => theme.spacing(4)}; | ||
`; | ||
|
||
export const SettingsAccountsCalendarDisplaySettings = () => { | ||
// TODO: use the user's saved time zone. If undefined, default it with the user's detected time zone. | ||
const [timeZone, setTimeZone] = useState(detectTimeZone()); | ||
|
||
// TODO: use the user's saved time format. | ||
const [timeFormat, setTimeFormat] = useState<12 | 24>(24); | ||
|
||
return ( | ||
<StyledContainer> | ||
<SettingsAccountsCalendarTimeZoneSelect | ||
value={timeZone} | ||
onChange={setTimeZone} | ||
/> | ||
<Select | ||
dropdownId="settings-accounts-calendar-time-format" | ||
label="Format" | ||
fullWidth | ||
value={timeFormat} | ||
options={[ | ||
{ | ||
label: formatInTimeZone(Date.now(), timeZone, 'HH:mm'), | ||
value: 24, | ||
}, | ||
{ | ||
label: formatInTimeZone(Date.now(), timeZone, 'h:mm aa'), | ||
value: 12, | ||
}, | ||
]} | ||
onChange={setTimeFormat} | ||
/> | ||
</StyledContainer> | ||
); | ||
}; |
25 changes: 25 additions & 0 deletions
25
...front/src/modules/settings/accounts/components/SettingsAccountsCalendarTimezoneSelect.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { availableTimeZoneOptions } from '@/settings/accounts/constants/timeZoneSelectOptions'; | ||
import { detectTimeZone } from '@/settings/accounts/utils/detectTimeZone'; | ||
import { findAvailableTimeZoneOption } from '@/settings/accounts/utils/findAvailableTimeZoneOption'; | ||
import { Select } from '@/ui/input/components/Select'; | ||
|
||
type SettingsAccountsCalendarTimeZoneSelectProps = { | ||
value?: string; | ||
onChange: (nextValue: string) => void; | ||
}; | ||
|
||
export const SettingsAccountsCalendarTimeZoneSelect = ({ | ||
value = detectTimeZone(), | ||
onChange, | ||
}: SettingsAccountsCalendarTimeZoneSelectProps) => ( | ||
<Select | ||
dropdownId="settings-accounts-calendar-time-zone" | ||
dropdownWidth={416} | ||
label="Time zone" | ||
fullWidth | ||
value={findAvailableTimeZoneOption(value)?.value} | ||
options={availableTimeZoneOptions} | ||
onChange={onChange} | ||
withSearchInput | ||
/> | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.