Skip to content

Commit

Permalink
Update today view
Browse files Browse the repository at this point in the history
  • Loading branch information
arjunkomath committed Jan 11, 2025
1 parent e3f187b commit 6b1b05d
Show file tree
Hide file tree
Showing 3 changed files with 70 additions and 5 deletions.
3 changes: 2 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ RUN apk add --no-cache \
libstdc++ \
gcc \
musl-dev \
cmake
cmake \
curl

# Stage 1: Install dependencies
FROM base AS deps
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import { buttonVariants } from "@/components/ui/button";
import { task, taskList } from "@/drizzle/schema";
import { database } from "@/lib/utils/useDatabase";
import { getOwner } from "@/lib/utils/useOwner";
import { allUsers } from "@/lib/utils/useUser";
import { and, asc, eq, or } from "drizzle-orm";
import Link from "next/link";
import { createTask, partialUpdateTaskList } from "./actions";
Expand Down
71 changes: 68 additions & 3 deletions app/(dashboard)/[tenant]/today/page.tsx
Original file line number Diff line number Diff line change
@@ -1,20 +1,49 @@
import { Greeting } from "@/components/core/greeting";
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 { database } from "@/lib/utils/useDatabase";
import { and, lte, ne } from "drizzle-orm";
import dayjs from "dayjs";
import { and, asc, lte, ne } from "drizzle-orm";
import { AlertTriangleIcon, InfoIcon } from "lucide-react";

export default async function Today() {
const db = await database();

const tasks = await db.query.task.findMany({
where: and(lte(task.dueDate, new Date()), ne(task.status, "done")),
orderBy: [asc(task.position)],
with: {
taskList: {
columns: {
projectId: true,
},
},
creator: {
columns: {
firstName: true,
imageUrl: true,
},
},
assignee: {
columns: {
firstName: true,
imageUrl: true,
},
},
},
});

console.log({ tasks });
const dueToday = tasks
.filter((t) => Boolean(t.dueDate))
.filter((t) => dayjs(new Date(t.dueDate!)).isSame(new Date(), "day"));

const summary = `You've got ${tasks.length} tasks due today.`;
const overDue = tasks
.filter((t) => Boolean(t.dueDate))
.filter((t) => dayjs(new Date(t.dueDate!)).isBefore(new Date(), "day"));

const summary = `You've got ${dueToday.length > 0 ? dueToday.length : "no"} tasks due today & ${overDue.length > 0 ? overDue.length : "no"} overdue tasks.`;

return (
<>
Expand All @@ -25,6 +54,42 @@ export default async function Today() {
<Greeting />, {summary}
</p>
</PageSection>

<PageSection>
{overDue.length ? (
<>
<p className="flex items-center p-4 text-xl font-medium text-red-600">
<AlertTriangleIcon className="w-6 h-6 inline-block mr-1" />
Overdue
</p>
{overDue.map((task) => (
<TaskItem
key={task.id}
task={task}
projectId={+task.taskList.projectId}
compact
/>
))}
</>
) : null}

{dueToday.length ? (
<>
<p className="flex items-center p-4 text-xl font-medium text-orange-600">
<InfoIcon className="w-6 h-6 inline-block mr-1" />
Due Today
</p>
{dueToday.map((task) => (
<TaskItem
key={task.id}
task={task}
projectId={+task.taskList.projectId}
compact
/>
))}
</>
) : null}
</PageSection>
</>
);
}

0 comments on commit 6b1b05d

Please sign in to comment.