35 lines
1.0 KiB
TypeScript
35 lines
1.0 KiB
TypeScript
import React from "react";
|
|
import spacetime from "spacetime";
|
|
import { api } from "@/server/api/client";
|
|
import TimelineView from "@/components/dashboard/timeline/TimelineView";
|
|
|
|
async function fetchDays(view: string, dateQuery: string) {
|
|
const timezone = await api.users.getTimezone();
|
|
|
|
const today = spacetime(dateQuery ?? "today");
|
|
const firstDay = today.subtract(2, "week").startOf("week");
|
|
|
|
const days = [];
|
|
for (let i = 0; i < 20; i++) {
|
|
const dayDate = firstDay.add(i, "day").format("iso-short");
|
|
// console.log(dayDate);
|
|
const dayRes = await api.days.get({
|
|
dateQuery: dayDate,
|
|
timezone: timezone,
|
|
});
|
|
days.push(dayRes);
|
|
}
|
|
|
|
return days;
|
|
}
|
|
|
|
export default async function TimelinePage({ params }: { params: { view: string, dateQuery: string }; }) {
|
|
const { view = "month", dateQuery } = await params;
|
|
const days = await fetchDays(view, dateQuery);
|
|
|
|
return (
|
|
<>
|
|
<TimelineView days={days} />
|
|
</>
|
|
);
|
|
} |