-
-
Notifications
You must be signed in to change notification settings - Fork 150
feat(ui): Collaboration Hub #98
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 5 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
0124657
feat(collaboration-hub): implement AI matches and general collaborati…
Saahi30 f1f63d3
feat(active-collabs): add UI for active collaborations with progress …
Saahi30 9efa3ec
feat: added the ui of the view details view of the active collabs car…
Saahi30 ad8a1b3
feat: added the UI of the requests tab in the collaboration hub (Fron…
Saahi30 0511c50
feat(ui): add comprehensive accessibility features to Dialog componen…
Saahi30 f87cc52
a11y: Add accessibility labels and ARIA attributes to collaboration-h…
Saahi30 559ba8c
ally: improved accessibility
Saahi30 876749f
ally: improved accessibility
Saahi30 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
146 changes: 146 additions & 0 deletions
146
Frontend/src/components/collaboration-hub/ActiveCollabCard.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,146 @@ | ||
| import React from "react"; | ||
| import { useNavigate } from "react-router-dom"; | ||
| import { Button } from "../ui/button"; | ||
| import { Avatar, AvatarFallback, AvatarImage } from "../ui/avatar"; | ||
|
|
||
| export interface ActiveCollabCardProps { | ||
| id: number; | ||
| collaborator: { | ||
| name: string; | ||
| avatar: string; | ||
| contentType: string; | ||
| }; | ||
| collabTitle: string; | ||
| status: string; | ||
| startDate: string; | ||
| dueDate: string; | ||
| messages: number; | ||
| deliverables: { completed: number; total: number }; | ||
| lastActivity: string; | ||
| latestUpdate: string; | ||
| } | ||
|
|
||
| const statusColors: Record<string, string> = { | ||
| "In Progress": "bg-blue-100 text-blue-700", | ||
| "Awaiting Response": "bg-yellow-100 text-yellow-700", | ||
| "Completed": "bg-green-100 text-green-700" | ||
| }; | ||
|
|
||
| function getDaysBetween(start: string, end: string) { | ||
| const s = new Date(start); | ||
| const e = new Date(end); | ||
| if (isNaN(s.getTime()) || isNaN(e.getTime())) return 0; | ||
| const diff = e.getTime() - s.getTime(); | ||
| if (diff < 0) return 0; | ||
| return Math.ceil(diff / (1000 * 60 * 60 * 24)); | ||
| } | ||
|
|
||
| function getDaysLeft(due: string) { | ||
| const now = new Date(); | ||
| const d = new Date(due); | ||
| if (isNaN(d.getTime())) return 0; | ||
| const diff = d.getTime() - now.getTime(); | ||
| // Allow negative for overdue, but if invalid, return 0 | ||
| return Math.ceil(diff / (1000 * 60 * 60 * 24)); | ||
| } | ||
|
|
||
| function getTimelineProgress(start: string, due: string) { | ||
| const total = getDaysBetween(start, due); | ||
| if (total === 0) return 0; | ||
| const elapsed = getDaysBetween(start, new Date().toISOString().slice(0, 10)); | ||
| return Math.min(100, Math.max(0, Math.round((elapsed / total) * 100))); | ||
| } | ||
|
|
||
| const ActiveCollabCard: React.FC<ActiveCollabCardProps> = ({ | ||
| id, | ||
| collaborator, | ||
| collabTitle, | ||
| status, | ||
| startDate, | ||
| dueDate, | ||
| messages, | ||
| deliverables, | ||
| lastActivity, | ||
| latestUpdate | ||
| }) => { | ||
| const navigate = useNavigate(); | ||
| const deliverableProgress = Math.round((deliverables.completed / deliverables.total) * 100); | ||
| const timelineProgress = getTimelineProgress(startDate, dueDate); | ||
| const daysLeft = getDaysLeft(dueDate); | ||
| const overdue = daysLeft < 0 && status !== "Completed"; | ||
|
|
||
| return ( | ||
| <div className="bg-white rounded-xl shadow p-5 flex flex-col gap-3 border border-gray-100 w-full max-w-xl mx-auto"> | ||
| <div className="flex items-center gap-4"> | ||
| <Avatar className="h-12 w-12"> | ||
| <AvatarImage src={collaborator.avatar} alt={collaborator.name} /> | ||
| <AvatarFallback className="bg-gray-200">{collaborator.name.slice(0,2).toUpperCase()}</AvatarFallback> | ||
| </Avatar> | ||
| <div className="flex-1"> | ||
| <div className="font-semibold text-lg text-gray-900">{collaborator.name}</div> | ||
| <div className="text-xs text-gray-500">{collaborator.contentType}</div> | ||
| </div> | ||
| <span className={`px-3 py-1 rounded-full text-xs font-semibold ${statusColors[status] || "bg-gray-100 text-gray-700"}`}>{status}</span> | ||
| </div> | ||
| <div className="flex flex-wrap items-center gap-2 text-sm text-gray-700"> | ||
| <span className="font-semibold">Collab:</span> {collabTitle} | ||
| <span className="ml-4 font-semibold">Start:</span> {startDate} | ||
| <span className="ml-4 font-semibold">Due:</span> <span className={overdue ? "text-red-600 font-bold" : ""}>{dueDate}</span> | ||
| <span className="ml-4 font-semibold">{overdue ? `Overdue by ${Math.abs(daysLeft)} days` : daysLeft === 0 ? "Due today" : `${daysLeft} days left`}</span> | ||
| </div> | ||
| {/* Timeline Progress Bar */} | ||
| <div className="w-full flex flex-col gap-1"> | ||
| <div className="flex justify-between text-xs text-gray-500"> | ||
| <span>Timeline</span> | ||
| <span>{timelineProgress}%</span> | ||
| </div> | ||
| <div className="w-full h-2 bg-gray-200 rounded-full overflow-hidden"> | ||
| <div className="h-2 rounded-full bg-blue-400" style={{ width: `${timelineProgress}%` }} /> | ||
| </div> | ||
| </div> | ||
| {/* Deliverables Progress Bar */} | ||
| <div className="w-full flex flex-col gap-1"> | ||
| <div className="flex justify-between text-xs text-gray-500"> | ||
| <span>Deliverables</span> | ||
| <span>{deliverables.completed}/{deliverables.total} ({deliverableProgress}%)</span> | ||
| </div> | ||
| <div className="w-full h-2 bg-gray-200 rounded-full overflow-hidden"> | ||
| <div className="h-2 rounded-full bg-green-400" style={{ width: `${deliverableProgress}%` }} /> | ||
| </div> | ||
| </div> | ||
| <div className="flex flex-wrap items-center gap-4 text-xs text-gray-600"> | ||
| <span>Messages: <span className="font-semibold text-gray-900">{messages}</span></span> | ||
| <span>Last activity: <span className="font-semibold text-gray-900">{lastActivity}</span></span> | ||
| </div> | ||
| <div className="text-xs text-gray-700 italic bg-gray-50 rounded px-3 py-2 border border-gray-100"> | ||
| <span className="font-semibold text-gray-800">Latest update:</span> {latestUpdate} | ||
| </div> | ||
| <div className="flex gap-2 mt-2"> | ||
| <Button | ||
| className="bg-gray-100 text-gray-900 hover:bg-gray-200 font-semibold rounded-full py-2" | ||
| variant="secondary" | ||
| onClick={() => navigate(`/dashboard/collaborations/${id}`)} | ||
| aria-label="View collaboration details" | ||
| > | ||
| View Details | ||
| </Button> | ||
| <Button | ||
| className="bg-blue-100 text-blue-700 hover:bg-blue-200 font-semibold rounded-full py-2" | ||
| aria-label="Send message to collaborator" | ||
| > | ||
| Message | ||
| </Button> | ||
| {status !== "Completed" && ( | ||
| <Button | ||
| className="bg-green-100 text-green-700 hover:bg-green-200 font-semibold rounded-full py-2" | ||
| aria-label="Mark collaboration as complete" | ||
| > | ||
| Mark Complete | ||
| </Button> | ||
| )} | ||
| </div> | ||
|
Saahi30 marked this conversation as resolved.
|
||
| </div> | ||
| ); | ||
| }; | ||
|
|
||
| export default ActiveCollabCard; | ||
69 changes: 69 additions & 0 deletions
69
Frontend/src/components/collaboration-hub/ActiveCollabsGrid.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,69 @@ | ||
| import React, { useState } from "react"; | ||
| import { activeCollabsMock } from "./activeCollabsMockData"; | ||
| import ActiveCollabCard from "./ActiveCollabCard"; | ||
|
|
||
| const statusOptions = ["All", "In Progress", "Completed"]; | ||
| const sortOptions = ["Start Date", "Due Date", "Name"]; | ||
|
|
||
| const ActiveCollabsGrid: React.FC = () => { | ||
| const [statusFilter, setStatusFilter] = useState("All"); | ||
| const [sortBy, setSortBy] = useState("Start Date"); | ||
|
|
||
| // Only show In Progress and Completed | ||
| let filtered = activeCollabsMock.filter(c => c.status !== "Awaiting Response"); | ||
| if (statusFilter !== "All") { | ||
| filtered = filtered.filter(c => c.status === statusFilter); | ||
| } | ||
| if (sortBy === "Start Date") { | ||
| filtered = [...filtered].sort((a, b) => a.startDate.localeCompare(b.startDate)); | ||
| } else if (sortBy === "Due Date") { | ||
| filtered = [...filtered].sort((a, b) => a.dueDate.localeCompare(b.dueDate)); | ||
| } else if (sortBy === "Name") { | ||
| filtered = [...filtered].sort((a, b) => a.collaborator.name.localeCompare(b.collaborator.name)); | ||
| } | ||
|
|
||
| return ( | ||
| <div className="w-full max-w-4xl mx-auto"> | ||
| <div className="flex flex-wrap items-center justify-between gap-4 mb-6"> | ||
| <div className="flex gap-2 items-center"> | ||
| <span className="font-semibold text-gray-700">Status:</span> | ||
| <select | ||
| className="border rounded px-2 py-1 text-sm" | ||
| value={statusFilter} | ||
| onChange={e => setStatusFilter(e.target.value)} | ||
| > | ||
| {statusOptions.map(opt => ( | ||
| <option key={opt} value={opt}>{opt}</option> | ||
| ))} | ||
| </select> | ||
| </div> | ||
| <div className="flex gap-2 items-center"> | ||
| <span className="font-semibold text-gray-700">Sort by:</span> | ||
| <select | ||
| className="border rounded px-2 py-1 text-sm" | ||
| value={sortBy} | ||
| onChange={e => setSortBy(e.target.value)} | ||
| > | ||
| {sortOptions.map(opt => ( | ||
| <option key={opt} value={opt}>{opt}</option> | ||
| ))} | ||
| </select> | ||
| </div> | ||
|
coderabbitai[bot] marked this conversation as resolved.
|
||
| </div> | ||
| {filtered.length === 0 ? ( | ||
| <div className="text-center text-gray-400 py-16"> | ||
| <div className="text-2xl mb-2">No active collaborations</div> | ||
| <div className="text-sm">Start a new collaboration to see it here!</div> | ||
| </div> | ||
| ) : ( | ||
| <div className="flex flex-col gap-6"> | ||
| {filtered.map(collab => ( | ||
| <ActiveCollabCard key={collab.id} {...collab} /> | ||
| ))} | ||
| </div> | ||
| )} | ||
| </div> | ||
| ); | ||
| }; | ||
|
|
||
| export default ActiveCollabsGrid; | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.