import type { ILivechatBusinessHour, Serialized } from '@rocket.chat/core-typings'; import { IconButton } from '@rocket.chat/fuselage'; import { GenericTableRow, GenericTableCell } from '@rocket.chat/ui-client'; import type { TranslationKey } from '@rocket.chat/ui-contexts'; import { useRouter } from '@rocket.chat/ui-contexts'; import type { KeyboardEvent } from 'react'; import { memo, useMemo } from 'react'; import { useTranslation } from 'react-i18next'; import { useRemoveBusinessHour } from './useRemoveBusinessHour'; const BusinessHoursRow = ({ _id, name, timezone, workHours, active, type }: Serialized) => { const { t } = useTranslation(); const router = useRouter(); const handleRemove = useRemoveBusinessHour(); const handleClick = () => router.navigate(`/omnichannel/businessHours/edit/${type}/${_id}`); const handleKeyDown = (e: KeyboardEvent) => { if (!['Enter', 'Space'].includes(e.nativeEvent.code)) { return; } handleClick(); }; const openDays = useMemo(() => workHours.filter(({ open }) => !!open).map(({ day }) => day), [workHours]); return ( {name || t('Default')} {t(timezone.name as TranslationKey)} {openDays.join(', ')} {active ? t('Yes') : t('No')} {name && ( { e.stopPropagation(); handleRemove(_id, type); }} /> )} ); }; export default memo(BusinessHoursRow);