diff --git a/app/(dashboard)/[tenant]/projects/[projectId]/events/page.tsx b/app/(dashboard)/[tenant]/projects/[projectId]/events/page.tsx
index 945d098..f07d4d8 100644
--- a/app/(dashboard)/[tenant]/projects/[projectId]/events/page.tsx
+++ b/app/(dashboard)/[tenant]/projects/[projectId]/events/page.tsx
@@ -10,137 +10,136 @@ import dayjs from "dayjs";
import timezone from "dayjs/plugin/timezone";
import utc from "dayjs/plugin/utc";
import {
- and,
- asc,
- between,
- desc,
- eq,
- gt,
- isNotNull,
- lt,
- or,
+ and,
+ asc,
+ between,
+ desc,
+ eq,
+ gt,
+ isNotNull,
+ lt,
+ or,
} from "drizzle-orm";
import { RssIcon } from "lucide-react";
import Link from "next/link";
type Props = {
- params: Promise<{
- projectId: string;
- }>;
- searchParams: Promise<{
- on: string;
- }>;
+ params: Promise<{
+ projectId: string;
+ }>;
+ searchParams: Promise<{
+ on: string;
+ }>;
};
dayjs.extend(utc);
dayjs.extend(timezone);
export default async function EventDetails(props: Props) {
- const searchParams = await props.searchParams;
- const params = await props.params;
- const { projectId } = params;
- const { on } = searchParams;
- const { userId, ownerId, orgSlug } = await getOwner();
+ const searchParams = await props.searchParams;
+ const params = await props.params;
+ const { projectId } = params;
+ const { on } = searchParams;
+ const { userId, ownerId, orgSlug } = await getOwner();
- const timezone = await getTimezone();
+ const timezone = await getTimezone();
- // Convert the selected date to the user's timezone and then to UTC for the database
- const selectedDate = dayjs(new Date(on));
- const dayCommentId = `${projectId}${selectedDate.year()}${selectedDate.month()}${selectedDate.date()}`;
+ const selectedDate = on ? dayjs(new Date(on)) : dayjs().tz(timezone);
+ const dayCommentId = `${projectId}${selectedDate.year()}${selectedDate.month()}${selectedDate.date()}`;
- const startOfDay = selectedDate.startOf("day").toDate();
- const endOfDay = selectedDate.endOf("day").toDate();
+ const startOfDay = selectedDate.startOf("day").toDate();
+ const endOfDay = selectedDate.endOf("day").toDate();
- const db = await database();
- const events = await db.query.calendarEvent
- .findMany({
- where: and(
- eq(calendarEvent.projectId, +projectId),
- or(
- between(calendarEvent.start, startOfDay, endOfDay),
- between(calendarEvent.end, startOfDay, endOfDay),
- and(
- lt(calendarEvent.start, startOfDay),
- gt(calendarEvent.end, endOfDay),
- ),
- isNotNull(calendarEvent.repeatRule),
- ),
- ),
- orderBy: [desc(calendarEvent.start), asc(calendarEvent.allDay)],
- with: {
- creator: {
- columns: {
- id: true,
- firstName: true,
- imageUrl: true,
- },
- },
- invites: {
- with: {
- user: {
- columns: {
- firstName: true,
- imageUrl: true,
- },
- },
- },
- },
- },
- })
- .execute();
+ const db = await database();
+ const events = await db.query.calendarEvent
+ .findMany({
+ where: and(
+ eq(calendarEvent.projectId, +projectId),
+ or(
+ between(calendarEvent.start, startOfDay, endOfDay),
+ between(calendarEvent.end, startOfDay, endOfDay),
+ and(
+ lt(calendarEvent.start, startOfDay),
+ gt(calendarEvent.end, endOfDay),
+ ),
+ isNotNull(calendarEvent.repeatRule),
+ ),
+ ),
+ orderBy: [desc(calendarEvent.start), asc(calendarEvent.allDay)],
+ with: {
+ creator: {
+ columns: {
+ id: true,
+ firstName: true,
+ imageUrl: true,
+ },
+ },
+ invites: {
+ with: {
+ user: {
+ columns: {
+ firstName: true,
+ imageUrl: true,
+ },
+ },
+ },
+ },
+ },
+ })
+ .execute();
- const calendarSubscriptionUrl = `/api/calendar/${ownerId}/${projectId}/calendar.ics?userId=${userId}`;
+ const calendarSubscriptionUrl = `/api/calendar/${ownerId}/${projectId}/calendar.ics?userId=${userId}`;
- return (
- <>
-