Skip to content

Commit

Permalink
Fix today view data
Browse files Browse the repository at this point in the history
  • Loading branch information
arjunkomath committed Jan 15, 2025
1 parent ce8cb52 commit f3d0760
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 10 deletions.
4 changes: 2 additions & 2 deletions app/(dashboard)/[tenant]/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { ReportTimezone } from "@/components/core/report-timezone";
import { project } from "@/drizzle/schema";
import { database, isDatabaseReady } from "@/lib/utils/useDatabase";
import { getOwner } from "@/lib/utils/useOwner";
import { eq, not } from "drizzle-orm";
import { ne } from "drizzle-orm";
import { redirect } from "next/navigation";

export const fetchCache = "force-no-store"; // disable cache for console pages
Expand Down Expand Up @@ -31,7 +31,7 @@ export default async function ConsoleLayout(props: {

const db = await database();
const projects = await db.query.project.findMany({
where: not(eq(project.status, "archived")),
where: ne(project.status, "archived"),
});

return (
Expand Down
13 changes: 10 additions & 3 deletions app/(dashboard)/[tenant]/today/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,14 @@ import PageSection from "@/components/core/section";
import PageTitle from "@/components/layout/page-title";
import { TaskItem } from "@/components/project/tasklist/task/task-item";
import { task } from "@/drizzle/schema";
import { isSameDate, toTimeZone } from "@/lib/utils/date";
import {
guessTimezone,
isSameDate,
toDateStringWithDay,
toDateTimeString,
toEndOfDay,
toTimeZone,
} from "@/lib/utils/date";
import { database } from "@/lib/utils/useDatabase";
import { getTimezone } from "@/lib/utils/useOwner";
import { and, asc, lte, ne } from "drizzle-orm";
Expand All @@ -13,7 +20,7 @@ export default async function Today() {
const db = await database();

const timezone = await getTimezone();
const today = toTimeZone(new Date(), timezone);
const today = toEndOfDay(toTimeZone(new Date(), timezone));

const tasks = await db.query.task.findMany({
where: and(lte(task.dueDate, new Date(today)), ne(task.status, "done")),
Expand Down Expand Up @@ -51,7 +58,7 @@ export default async function Today() {

return (
<>
<PageTitle title="Today" />
<PageTitle title={toDateStringWithDay(today, timezone)} />

<PageSection topInset>
<p className="p-4 text-xl">
Expand Down
2 changes: 1 addition & 1 deletion components/console/navbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export default function NavBar({
strokeWidth="1"
viewBox="0 0 24 24"
width="40"
className="ml-2 text-gray-300 dark:text-gray-700 xl:block"
className="ml-0.5 text-gray-300 dark:text-gray-700 xl:block"
>
<path d="M16.88 3.549L7.12 20.451" />
</svg>
Expand Down
2 changes: 1 addition & 1 deletion components/core/auth.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ export const ProjectSwitcher = ({
strokeWidth="1"
viewBox="0 0 24 24"
width="40"
className="ml-2 text-gray-300 dark:text-gray-700 xl:block"
className="ml-0.5 text-gray-300 dark:text-gray-700 xl:block"
>
<path d="M16.88 3.549L7.12 20.451" />
</svg>
Expand Down
6 changes: 3 additions & 3 deletions components/project/tasklist/task/task-item.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import {
import { Input } from "@/components/ui/input";
import type { Task, TaskList, TaskWithDetails, User } from "@/drizzle/types";
import { cn } from "@/lib/utils";
import { toDateStringWithDay } from "@/lib/utils/date";
import { toDateStringWithDay, toEndOfDay } from "@/lib/utils/date";
import { useSortable } from "@dnd-kit/sortable";
import { CSS } from "@dnd-kit/utilities";
import { AlignJustifyIcon, CalendarClock, FileIcon } from "lucide-react";
Expand Down Expand Up @@ -238,10 +238,10 @@ export const TaskItem = ({
<DateTimePicker
dateOnly
name="dueDate"
onSelect={(date) => {
onSelect={(dueDate) => {
toast.promise(
updateTask(id, projectId, {
dueDate: date,
dueDate: toEndOfDay(dueDate),
}),
updateTaskToastOptions,
);
Expand Down

0 comments on commit f3d0760

Please sign in to comment.