From 409813b2b7b55b2e79f63ebf3c6ff8f7dbb20076 Mon Sep 17 00:00:00 2001 From: DevKoya <138589181+DevKoya06@users.noreply.github.com> Date: Fri, 20 Nov 2026 06:30:38 +0100 Subject: [PATCH] feat: [Feature]: Proposal Comparison & Shortlisting Interface (#239) --- app/dashboard/proposals/[projectId]/page.tsx | 13 ++- components/proposals/index.ts | 5 +- components/proposals/proposal-card.tsx | 26 ++++- .../proposals/proposal-confirm-dialog.tsx | 45 +++++-- components/proposals/proposal-empty-state.tsx | 8 +- components/proposals/proposal-list.tsx | 110 ++++++++++++++---- components/proposals/proposal-skeleton.tsx | 64 ++++++++-- .../proposals/proposal-status-badge.tsx | 9 +- 8 files changed, 228 insertions(+), 52 deletions(-) diff --git a/app/dashboard/proposals/[projectId]/page.tsx b/app/dashboard/proposals/[projectId]/page.tsx index de5c63e..67e1d8d 100644 --- a/app/dashboard/proposals/[projectId]/page.tsx +++ b/app/dashboard/proposals/[projectId]/page.tsx @@ -4,6 +4,7 @@ import { db as sql } from "@/lib/proposals/db"; import { verifyAccessToken } from "@/lib/auth/session"; import { ACCESS_TOKEN_COOKIE } from "@/lib/auth/constants"; import { ProposalList } from "@/components/proposals"; +import { ProposalComparison } from "@/components/proposals/proposal-comparison"; export default async function ProposalsPage({ params, @@ -33,16 +34,20 @@ export default async function ProposalsPage({ if (!isClient && !isFreelancer) notFound(); return ( -
+

Proposals

{isClient - ? "Review, filter, and manage freelancer proposals." + ? "Review, compare, shortlist, and manage freelancer proposals." : "Your submitted proposals and their status."}

- + {isClient ? ( + + ) : ( + + )}
); -} \ No newline at end of file +} diff --git a/components/proposals/index.ts b/components/proposals/index.ts index d56dd20..fe3b470 100644 --- a/components/proposals/index.ts +++ b/components/proposals/index.ts @@ -4,4 +4,7 @@ export * from "./proposal-filters"; export * from "./proposal-status-badge"; export * from "./proposal-confirm-dialog"; export * from "./proposal-skeleton"; -export * from "./proposal-empty-state"; \ No newline at end of file +export * from "./proposal-empty-state"; +export * from "./proposal-comparison"; +export * from "./proposal-comparison-table"; +export * from "./proposal-shortlist-toggle"; diff --git a/components/proposals/proposal-card.tsx b/components/proposals/proposal-card.tsx index 52d8120..ecf72ec 100644 --- a/components/proposals/proposal-card.tsx +++ b/components/proposals/proposal-card.tsx @@ -8,17 +8,21 @@ import type { Proposal } from "@/lib/proposals/types"; interface Props { proposal: Proposal; readOnly?: boolean; + isShortlisted?: boolean; onAccept?: (p: Proposal) => void; onReject?: (p: Proposal) => void; onViewProfile?: (p: Proposal) => void; + onToggleShortlist?: (p: Proposal) => void; } export function ProposalCard({ proposal, readOnly, + isShortlisted, onAccept, onReject, onViewProfile, + onToggleShortlist, }: Props) { const ISO = /^[A-Z]{3}$/; const code = (proposal.currency || "").toUpperCase(); @@ -33,6 +37,10 @@ export function ProposalCard({ .join("") .toUpperCase(); + const canDecide = !readOnly && proposal.status === "pending"; + const canShortlist = + !readOnly && onToggleShortlist && (proposal.status === "pending" || proposal.status === "shortlisted"); + return ( @@ -44,7 +52,7 @@ export function ProposalCard({

{proposal.freelancerName}

{proposal.freelancerRating.toFixed(1)} / 5 - · + · {proposal.freelancerPastContracts} jobs
@@ -64,7 +72,7 @@ export function ProposalCard({

{proposal.coverLetter}

-
+
Budget: {budget} @@ -82,7 +90,17 @@ export function ProposalCard({ > View profile - {!readOnly && proposal.status === "pending" && ( + {canShortlist && ( + + )} + {canDecide && ( <> + )} +
{loading ? ( -
+
+ ) : error ? ( +
+

{error}

+ +
) : proposals.length === 0 ? ( + ) : comparing && actionable ? ( + setPendingAction({ proposal: p, action: "accept" })} + onReject={(p) => setPendingAction({ proposal: p, action: "reject" })} + onClose={() => setComparing(false)} + /> ) : (
{proposals.map((p) => ( - - setPendingAction({ proposal: prop, action: "accept" }) - } - onReject={(prop) => - setPendingAction({ proposal: prop, action: "reject" }) - } - onViewProfile={(prop) => { - window.location.href = `/freelancers/${prop.freelancerId}`; - }} - /> +
+ + setPendingAction({ proposal: prop, action: "accept" }) + } + onReject={(prop) => + setPendingAction({ proposal: prop, action: "reject" }) + } + onViewProfile={(prop) => { + window.location.href = `/freelancers/${prop.freelancerId}`; + }} + /> + {actionable && p.status === "pending" && ( + + )} +
))}
)} @@ -122,4 +190,4 @@ export function ProposalList({ projectId, readOnly }: Props) { />
); -} \ No newline at end of file +} diff --git a/components/proposals/proposal-skeleton.tsx b/components/proposals/proposal-skeleton.tsx index c25fdc5..532947b 100644 --- a/components/proposals/proposal-skeleton.tsx +++ b/components/proposals/proposal-skeleton.tsx @@ -1,17 +1,67 @@ -export function ProposalSkeleton() { +import * as React from "react"; + +type ProposalSkeletonProps = { + className?: string; + "aria-label"?: string; +}; + +export function ProposalSkeleton({ + className, + "aria-label": ariaLabel = "Loading proposal", +}: ProposalSkeletonProps) { return ( -
+
+ {ariaLabel} +
-
-
-
-
+
+
+
+
+
+ +
+
+
+
+
+
+ ); +} + +export function ProposalSkeletonList({ + count = 3, + className, +}: { + count?: number; + className?: string; +}) { + return ( +
+ {Array.from({ length: count }, (_, index) => ( + + ))}
); -} \ No newline at end of file +} diff --git a/components/proposals/proposal-status-badge.tsx b/components/proposals/proposal-status-badge.tsx index 28e4f87..26126c6 100644 --- a/components/proposals/proposal-status-badge.tsx +++ b/components/proposals/proposal-status-badge.tsx @@ -1,17 +1,18 @@ import { Badge } from "@/components/ui/badge"; import type { ProposalStatus } from "@/lib/proposals/types"; -const STYLES: Record = { +const STYLES: Record = { pending: "bg-yellow-100 text-yellow-800 border-yellow-200", + shortlisted: "bg-purple-100 text-purple-800 border-purple-200", accepted: "bg-green-100 text-green-800 border-green-200", rejected: "bg-red-100 text-red-800 border-red-200", updated: "bg-blue-100 text-blue-800 border-blue-200", }; -export function ProposalStatusBadge({ status }: { status: ProposalStatus }) { +export function ProposalStatusBadge({ status }: { status: ProposalStatus | "shortlisted" }) { return ( - + {status.charAt(0).toUpperCase() + status.slice(1)} ); -} \ No newline at end of file +}