Skip to content

Commit

Permalink
feat(schedule): update schedule mobile view with user timezone offset (
Browse files Browse the repository at this point in the history
…#2313)

* feat(schedule): update schedule mobile view with user timezone offset

* fix: formatting
  • Loading branch information
ThorsAngerVaNeT authored Oct 18, 2023
1 parent b061f61 commit f60f15f
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,19 @@ import { SwapRightOutlined } from '@ant-design/icons';
import { coloredDateRenderer } from 'components/Table';
import { renderTagWithStyle, statusRenderer } from '../TableView/renderers';
import Link from 'next/link';
import { ScheduleSettings } from 'modules/Schedule/hooks/useScheduleSettings';
import dayjs from 'dayjs';

const { Title } = Typography;

export const MobileItemCard = ({ item }: { item: CourseScheduleItemDto }) => {
export const MobileItemCard = ({
item,
timezone,
}: {
item: CourseScheduleItemDto;
timezone: ScheduleSettings['timezone'];
}) => {
const timezoneOffset = `(UTC ${dayjs().tz(timezone).format('Z')})`;
return (
<div style={{ padding: '12px 0px', backgroundColor: 'white', borderBottom: '1px groove' }}>
<Row gutter={12} wrap={false}>
Expand All @@ -21,17 +30,20 @@ export const MobileItemCard = ({ item }: { item: CourseScheduleItemDto }) => {
<Row gutter={12} wrap={false}>
<Col flex="1">{statusRenderer(item.status)}</Col>
<Col flex="0 0 auto">
{coloredDateRenderer('UTC', 'MMM D HH:mm', 'start', 'Recommended date for studying')(item.startDate, item)}
{coloredDateRenderer(timezone, 'MMM D HH:mm', 'start', 'Recommended date for studying')(item.startDate, item)}
{item.endDate && (
<>
{' '}
<SwapRightOutlined />{' '}
</>
)}
{item.endDate &&
coloredDateRenderer('UTC', 'MMM D HH:mm', 'end', 'Recommended date for studying')(item.endDate, item)}
coloredDateRenderer(timezone, 'MMM D HH:mm', 'end', 'Recommended date for studying')(item.endDate, item)}
</Col>
</Row>
<Row justify={'end'} color="secondary">
{timezoneOffset}
</Row>
</div>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ export function TableView({ data, settings, statusFilter = ALL_TAB_KEY, mobileVi
) : (
<>
{filteredData.map(item => (
<MobileItemCard item={item} key={generateUniqueRowKey(item)} />
<MobileItemCard item={item} key={generateUniqueRowKey(item)} timezone={settings.timezone} />
))}
</>
);
Expand Down

0 comments on commit f60f15f

Please sign in to comment.