-
Notifications
You must be signed in to change notification settings - Fork 225
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
(fix) O3-3879: Localize the monthly calendar header text (#1293)
* (chore): Update month text based on locale * Fixup * Misc fixes --------- Co-authored-by: Dennis Kigen <[email protected]>
- Loading branch information
1 parent
d8a815a
commit ab41846
Showing
10 changed files
with
79 additions
and
50 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
10 changes: 6 additions & 4 deletions
10
packages/esm-appointments-app/src/calendar/monthly/days-of-week.component.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
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
49 changes: 49 additions & 0 deletions
49
packages/esm-appointments-app/src/calendar/monthly/monthly-header.component.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,49 @@ | ||
import React, { useCallback, useContext } from 'react'; | ||
import dayjs from 'dayjs'; | ||
import { useTranslation } from 'react-i18next'; | ||
import { Button } from '@carbon/react'; | ||
import { formatDate } from '@openmrs/esm-framework'; | ||
import { omrsDateFormat } from '../../constants'; | ||
import DaysOfWeekCard from './days-of-week.component'; | ||
import SelectedDateContext from '../../hooks/selectedDateContext'; | ||
import styles from './monthly-header.scss'; | ||
|
||
const DAYS_IN_WEEK = ['SUN', 'MON', 'TUE', 'WED', 'THUR', 'FRI', 'SAT']; | ||
|
||
const MonthlyHeader: React.FC = () => { | ||
const { t } = useTranslation(); | ||
const { selectedDate, setSelectedDate } = useContext(SelectedDateContext); | ||
|
||
const handleSelectPrevMonth = useCallback(() => { | ||
setSelectedDate(dayjs(selectedDate).subtract(1, 'month').format(omrsDateFormat)); | ||
}, [selectedDate, setSelectedDate]); | ||
|
||
const handleSelectNextMonth = useCallback(() => { | ||
setSelectedDate(dayjs(selectedDate).add(1, 'month').format(omrsDateFormat)); | ||
}, [selectedDate, setSelectedDate]); | ||
|
||
return ( | ||
<> | ||
<div className={styles.container}> | ||
<Button | ||
aria-label={t('previousMonth', 'Previous month')} | ||
kind="tertiary" | ||
onClick={handleSelectPrevMonth} | ||
size="sm"> | ||
{t('prev', 'Prev')} | ||
</Button> | ||
<span>{formatDate(new Date(selectedDate), { day: false, time: false, noToday: true })}</span> | ||
<Button aria-label={t('nextMonth', 'Next month')} kind="tertiary" onClick={handleSelectNextMonth} size="sm"> | ||
{t('next', 'Next')} | ||
</Button> | ||
</div> | ||
<div className={styles.workLoadCard}> | ||
{DAYS_IN_WEEK.map((day) => ( | ||
<DaysOfWeekCard key={day} dayOfWeek={day} /> | ||
))} | ||
</div> | ||
</> | ||
); | ||
}; | ||
|
||
export default MonthlyHeader; |
40 changes: 0 additions & 40 deletions
40
packages/esm-appointments-app/src/calendar/monthly/monthly-header.module.tsx
This file was deleted.
Oops, something went wrong.
File renamed without changes.
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