Skip to content

Commit c7c1749

Browse files
committed
Kanban comment section update
1 parent 4aacc4a commit c7c1749

2 files changed

Lines changed: 642 additions & 2 deletions

File tree

‎apps/codebility/app/home/kanban/[projectId]/[id]/_components/tasks/TaskViewModal.tsx‎

Lines changed: 61 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"use client";
22

3-
import { useEffect, useState } from "react";
3+
import { useCallback, useEffect, useState } from "react";
44
import Image from "next/image";
55
import DefaultAvatar from "@/components/DefaultAvatar";
66
import { Button } from "@/components/ui/button";
@@ -42,6 +42,8 @@ import { completeTask, updateTaskPRLink } from "../../actions";
4242
import DifficultyPointsTooltip, {
4343
DIFFICULTY_LEVELS,
4444
} from "../DifficultyPointsTooltip";
45+
import TaskCommentsSection from "./_components/TaskComments";
46+
import { MessageCircle, ChevronDown, ChevronUp } from "lucide-react";
4547

4648
// Fetch available members function - unchanged from original
4749
const fetchAvailableMembers = async (
@@ -183,7 +185,7 @@ function AssigneeSelector({
183185
onAssigneeChange([user.id]);
184186
}
185187
};
186-
188+
187189
return (
188190
<div className="flex flex-col gap-1">
189191
<div className="flex flex-wrap gap-2">
@@ -341,6 +343,34 @@ const TaskViewModal = ({
341343
user?.role_id === 10;
342344
const canMarkAsDone = user?.role_id === 1 || user?.role_id === 5;
343345

346+
347+
const [showComments, setShowComments] = useState(false);
348+
const [commentCount, setCommentCount] = useState(0);
349+
350+
useEffect(() => {
351+
const fetchCommentCount = async () => {
352+
if (!task?.id) return;
353+
354+
const { count, error } = await supabase
355+
.from("tasks_comments")
356+
.select("*", { count: "exact", head: true })
357+
.eq("task_id", task.id);
358+
359+
if (!error && count !== null) {
360+
setCommentCount(count);
361+
}
362+
};
363+
364+
fetchCommentCount();
365+
}, [task?.id]);
366+
367+
368+
369+
const toggleComments = useCallback(() => {
370+
setShowComments(prev => !prev);
371+
}, []);
372+
373+
344374
useEffect(() => {
345375
const supabaseClient = createClientClientComponent();
346376
setSupabase(supabaseClient);
@@ -925,6 +955,35 @@ const TaskViewModal = ({
925955
</div>
926956
</div>
927957

958+
{/* Comments Section */}
959+
<div className="space-y-3 border-t border-gray-200 pt-4 dark:border-gray-700">
960+
<Button
961+
variant="ghost"
962+
onClick={toggleComments}
963+
className="w-full justify-between rounded-lg bg-gray-50 px-4 py-3 text-sm font-medium text-gray-700 transition-colors hover:bg-gray-100 dark:bg-gray-800 dark:text-gray-300 dark:hover:bg-gray-700"
964+
>
965+
<div className="flex items-center gap-2">
966+
<MessageCircle className="h-4 w-4" />
967+
<span>Comments ({commentCount})</span>
968+
</div>
969+
{showComments ? (
970+
<ChevronUp className="h-4 w-4" />
971+
) : (
972+
<ChevronDown className="h-4 w-4" />
973+
)}
974+
</Button>
975+
976+
{showComments && (
977+
<div className="rounded-lg border border-gray-200 bg-gray-50 p-3 sm:p-4 dark:border-gray-700 dark:bg-gray-800/50">
978+
<TaskCommentsSection
979+
taskId={task?.id || ""}
980+
currentUserId={user?.id || ""}
981+
onCommentCountChange={setCommentCount}
982+
/>
983+
</div>
984+
)}
985+
</div>
986+
928987
<DialogFooter className="mt-4 flex justify-end">
929988
<Button
930989
onClick={() => {

0 commit comments

Comments
 (0)