Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Box, States, StatesIcon, StatesTitle, StatesSubtitle, ButtonGroup, Button, Throbber } from '@rocket.chat/fuselage';
import { Box, States, StatesIcon, StatesTitle, StatesSubtitle, ButtonGroup, Button, IconButton, Throbber } from '@rocket.chat/fuselage';
import { useResizeObserver } from '@rocket.chat/fuselage-hooks';
import {
VirtualizedScrollbars,
Expand All @@ -12,12 +12,13 @@ import {
} from '@rocket.chat/ui-client';
import { useTranslation, useUser } from '@rocket.chat/ui-contexts';
import type { ReactElement } from 'react';
import { useState, useCallback } from 'react';
import { Virtuoso } from 'react-virtuoso';

import OutlookEventItem from './OutlookEventItem';
import { getErrorMessage } from '../../../lib/errorHandling';
import { useOutlookAuthentication } from '../hooks/useOutlookAuthentication';
import { useMutationOutlookCalendarSync, useOutlookCalendarListForToday } from '../hooks/useOutlookCalendarList';
import { useMutationOutlookCalendarSync, useOutlookCalendarList } from '../hooks/useOutlookCalendarList';
import { NotOnDesktopError } from '../lib/NotOnDesktopError';

type OutlookEventsListProps = {
Expand All @@ -34,7 +35,17 @@ const OutlookEventsList = ({ onClose, changeRoute }: OutlookEventsListProps): Re

const syncOutlookCalendar = useMutationOutlookCalendarSync();

const calendarListResult = useOutlookCalendarListForToday();
const [currentDate, setCurrentDate] = useState(() => new Date());

const handlePrevDay = useCallback(() => {
setCurrentDate((prev) => new Date(prev.getFullYear(), prev.getMonth(), prev.getDate() - 1));
}, []);

const handleNextDay = useCallback(() => {
setCurrentDate((prev) => new Date(prev.getFullYear(), prev.getMonth(), prev.getDate() + 1));
}, []);

const calendarListResult = useOutlookCalendarList(currentDate);
Comment thread
VedantGupta-DTU marked this conversation as resolved.

const { ref, contentBoxSize: { inlineSize = 378, blockSize = 1 } = {} } = useResizeObserver<HTMLElement>({
debounceDelay: 200,
Expand All @@ -53,6 +64,13 @@ const OutlookEventsList = ({ onClose, changeRoute }: OutlookEventsListProps): Re
<ContextualbarClose onClick={onClose} />
</ContextualbarHeader>
<ContextualbarContent paddingInline={0} color='default'>
<Box display='flex' justifyContent='space-between' alignItems='center' pi={24} pb={16}>
<IconButton icon='chevron-left' title={t('Previous')} onClick={handlePrevDay} />
<Box fontScale='p2' fontWeight={600}>
{new Intl.DateTimeFormat('en-US', { month: 'short', day: 'numeric', year: 'numeric' }).format(currentDate)}
Comment thread
VedantGupta-DTU marked this conversation as resolved.
</Box>
Comment thread
VedantGupta-DTU marked this conversation as resolved.
<IconButton icon='chevron-right' title={t('Next')} onClick={handleNextDay} />
</Box>
<Box flexGrow={1} flexShrink={1} overflow='hidden' display='flex' justifyContent='center' ref={ref}>
{calendarListResult.isPending && <Throbber size='x12' />}
{calendarListResult.isError && (
Expand Down