-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[UICAL-278] Fix rendering error for closed calendars (#499)
* Improve user fetching for metadata view * Separate InfoPaneHours intl a separate component * Additional cleanup * Revert "Additional cleanup" This reverts commit 1fec395. * Fix render issue on end time column * Update changelog * Fix history version to be consistent with react-router-dom * Fix tests * Sonar nits
- Loading branch information
1 parent
4148e54
commit 7bdc60f
Showing
15 changed files
with
526 additions
and
694 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
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,89 @@ | ||
import { MultiColumnList } from '@folio/stripes/components'; | ||
import classNames from 'classnames'; | ||
import React, { useMemo } from 'react'; | ||
import { FormattedMessage, useIntl } from 'react-intl'; | ||
import { Calendar } from '../types/types'; | ||
import { | ||
containsFullOvernightSpans, | ||
containsNextDayOvernight, | ||
generateDisplayRows, | ||
get247Rows, | ||
splitOpeningsIntoDays, | ||
} from '../utils/InfoPaneUtils'; | ||
import { isOpen247 } from '../utils/CalendarUtils'; | ||
import { useLocaleWeekdays } from '../utils/WeekdayUtils'; | ||
import css from '../views/panes/InfoPane.css'; | ||
|
||
export default function InfoPaneHours({ | ||
calendar, | ||
}: { | ||
readonly calendar: Calendar; | ||
}) { | ||
const intl = useIntl(); | ||
const localeWeekdays = useLocaleWeekdays(intl); | ||
|
||
const hours = useMemo( | ||
() => splitOpeningsIntoDays(calendar.normalHours), | ||
[calendar], | ||
); | ||
|
||
const dataRows = useMemo(() => { | ||
if (isOpen247(calendar.normalHours)) { | ||
return get247Rows(intl, localeWeekdays); | ||
} else { | ||
return generateDisplayRows(intl, localeWeekdays, hours); | ||
} | ||
}, [hours, calendar, intl, localeWeekdays]); | ||
|
||
return ( | ||
<> | ||
<MultiColumnList | ||
interactive={false} | ||
getCellClass={(defaultClass, _rowData, column) => { | ||
return classNames(defaultClass, { | ||
[css.hoursCell]: column !== 'day', | ||
[css.dayCell]: column === 'day', | ||
}); | ||
}} | ||
columnMapping={{ | ||
day: ( | ||
<FormattedMessage id="ui-calendar.infoPane.accordion.hours.day" /> | ||
), | ||
startTime: ( | ||
<FormattedMessage id="ui-calendar.infoPane.accordion.hours.open" /> | ||
), | ||
endTime: ( | ||
<FormattedMessage id="ui-calendar.infoPane.accordion.hours.close" /> | ||
), | ||
}} | ||
columnWidths={{ | ||
day: 200, | ||
startTime: { min: 100, max: 100 }, | ||
endTime: { min: 100, max: 100 }, | ||
}} | ||
contentData={dataRows} | ||
/> | ||
<p | ||
className={ | ||
!isOpen247(calendar.normalHours) && containsNextDayOvernight(hours) | ||
? '' | ||
: css.hidden | ||
} | ||
> | ||
<FormattedMessage id="ui-calendar.infoPane.nextDayHelpText" /> | ||
</p> | ||
<p | ||
className={ | ||
!isOpen247(calendar.normalHours) && containsFullOvernightSpans(hours) | ||
? '' | ||
: css.hidden | ||
} | ||
> | ||
<FormattedMessage id="ui-calendar.infoPane.overnightHelpText" /> | ||
</p> | ||
<p className={isOpen247(calendar.normalHours) ? '' : css.hidden}> | ||
<FormattedMessage id="ui-calendar.infoPane.247HelpText" /> | ||
</p> | ||
</> | ||
); | ||
} |
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.