|
|
|
@ -1,6 +1,6 @@
|
|
|
|
|
import { Tooltip } from "@mui/joy";
|
|
|
|
|
import classNames from "classnames";
|
|
|
|
|
import { getNormalizedDateString } from "@/helpers/datetime";
|
|
|
|
|
import { getNormalizedDateString, getDateWithOffset } from "@/helpers/datetime";
|
|
|
|
|
|
|
|
|
|
interface Props {
|
|
|
|
|
// Format: 2021-1
|
|
|
|
@ -26,8 +26,8 @@ const getCellAdditionalStyles = (count: number, maxCount: number) => {
|
|
|
|
|
|
|
|
|
|
const ActivityCalendar = (props: Props) => {
|
|
|
|
|
const { month: monthStr, data, onClick } = props;
|
|
|
|
|
const year = new Date(monthStr).getFullYear();
|
|
|
|
|
const month = new Date(monthStr).getMonth() + 1;
|
|
|
|
|
const year = new Date(monthStr).getUTCFullYear();
|
|
|
|
|
const month = new Date(monthStr).getUTCMonth() + 1;
|
|
|
|
|
const dayInMonth = new Date(year, month, 0).getDate();
|
|
|
|
|
const firstDay = new Date(year, month - 1, 1).getDay();
|
|
|
|
|
const lastDay = new Date(year, month - 1, dayInMonth).getDay();
|
|
|
|
@ -47,7 +47,9 @@ const ActivityCalendar = (props: Props) => {
|
|
|
|
|
return (
|
|
|
|
|
<div className={classNames("w-36 h-auto p-0.5 shrink-0 grid grid-cols-7 grid-flow-row gap-1")}>
|
|
|
|
|
{days.map((day, index) => {
|
|
|
|
|
const date = getNormalizedDateString(`${year}-${String(month).padStart(2, "0")}-${String(day).padStart(2, "0")}`);
|
|
|
|
|
const date = getNormalizedDateString(
|
|
|
|
|
getDateWithOffset(`${year}-${String(month).padStart(2, "0")}-${String(day).padStart(2, "0")}`),
|
|
|
|
|
);
|
|
|
|
|
const count = data[date] || 0;
|
|
|
|
|
const isToday = new Date().toDateString() === new Date(date).toDateString();
|
|
|
|
|
const tooltipText = count ? `${count} memos in ${date}` : date;
|
|
|
|
|