import moment from 'moment'; import { useTranslation } from 'react-i18next'; import { SettlementDays, SettlementStatus } from '../model/types'; import { useEffect, useState } from 'react'; export interface CalendarGridProps { yearMonth: string; scheduledDateList: Array; completedDateList: Array; }; export const CalendarGrid = ({ yearMonth, scheduledDateList, completedDateList }: CalendarGridProps) => { const { t } = useTranslation(); const makeCalendarDate = () => { let startDay = moment(yearMonth).startOf('month').day(); let lastDate = moment(yearMonth).endOf('month').date(); let lastYearMonth = moment(yearMonth).subtract(1, 'month').format('YYYY-MM'); let lastYearMonthLastDate = moment(lastYearMonth).endOf('month').date(); let lastOthersCnt = (7 - ((startDay + lastDate) % 7)); let rs = []; for(let i=0;i{ (lastYearMonthLastDate - startDay + i + 1) } ); } for(let i=1;i<=lastDate;i++){ if(scheduledDateList?.includes(i)){ rs.push(
{ i }
); } else if(completedDateList?.includes(i)){ rs.push(
{ i }
); } else{ rs.push(
{ i }
); } } for(let i=0;i{ (i + 1) } ); } return rs; } return ( <>
{t('common.weekdays.sun')}
{t('common.weekdays.mon')}
{t('common.weekdays.tue')}
{t('common.weekdays.wed')}
{t('common.weekdays.thu')}
{t('common.weekdays.fri')}
{t('common.weekdays.sat')}
{ makeCalendarDate() }
) };