Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions app/dashboard/proposals/[projectId]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -33,16 +34,20 @@ export default async function ProposalsPage({
if (!isClient && !isFreelancer) notFound();

return (
<div className="container mx-auto max-w-5xl py-8">
<div className="container mx-auto max-w-5xl py-8 px-4">
<header className="mb-6">
<h1 className="text-2xl font-semibold">Proposals</h1>
<p className="text-sm text-muted-foreground">
{isClient
? "Review, filter, and manage freelancer proposals."
? "Review, compare, shortlist, and manage freelancer proposals."
: "Your submitted proposals and their status."}
</p>
</header>
<ProposalList projectId={projectId} readOnly={!isClient} />
{isClient ? (
<ProposalComparison projectId={projectId} />
) : (
<ProposalList projectId={projectId} readOnly />
)}
</div>
);
}
}
5 changes: 4 additions & 1 deletion components/proposals/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";
export * from "./proposal-empty-state";
export * from "./proposal-comparison";
export * from "./proposal-comparison-table";
export * from "./proposal-shortlist-toggle";
26 changes: 22 additions & 4 deletions components/proposals/proposal-card.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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 (
<Card>
<CardHeader className="flex flex-row items-start justify-between gap-4">
Expand All @@ -44,7 +52,7 @@ export function ProposalCard({
<p className="font-medium">{proposal.freelancerName}</p>
<div className="flex items-center gap-2 text-xs text-muted-foreground">
<span>{proposal.freelancerRating.toFixed(1)} / 5</span>
<span>·</span>
<span>·</span>
<span>{proposal.freelancerPastContracts} jobs</span>
</div>
</div>
Expand All @@ -64,7 +72,7 @@ export function ProposalCard({
<p className="line-clamp-2 text-sm text-muted-foreground">
{proposal.coverLetter}
</p>
<div className="grid grid-cols-2 gap-2 text-sm">
<div className="grid grid-cols-1 gap-2 text-sm sm:grid-cols-2">
<div>
<span className="text-muted-foreground">Budget: </span>
<span className="font-medium">{budget}</span>
Expand All @@ -82,7 +90,17 @@ export function ProposalCard({
>
View profile
</Button>
{!readOnly && proposal.status === "pending" && (
{canShortlist && (
<Button
variant="outline"
size="sm"
aria-pressed={!!isShortlisted}
onClick={() => onToggleShortlist?.(proposal)}
>
{isShortlisted ? "Remove from shortlist" : "Shortlist"}
</Button>
)}
{canDecide && (
<>
<Button size="sm" onClick={() => onAccept?.(proposal)}>
Accept
Expand All @@ -100,4 +118,4 @@ export function ProposalCard({
</CardContent>
</Card>
);
}
}
45 changes: 38 additions & 7 deletions components/proposals/proposal-confirm-dialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ interface Props {
open: boolean;
action: "accept" | "reject" | null;
freelancerName?: string;
isSubmitting?: boolean;
error?: string | null;
onCancel: () => void;
onConfirm: () => void;
}
Expand All @@ -23,30 +25,59 @@ export function ProposalConfirmDialog({
open,
action,
freelancerName,
isSubmitting = false,
error = null,
onCancel,
onConfirm,
}: Props) {
const isAccept = action === "accept";
const name = freelancerName ?? "this freelancer";

return (
<AlertDialog open={open} onOpenChange={(o) => !o && onCancel()}>
<AlertDialog
open={open}
onOpenChange={(o) => {
if (!o && !isSubmitting) onCancel();
}}
>
<AlertDialogContent>
<AlertDialogHeader>
<AlertDialogTitle>
{isAccept ? "Accept proposal?" : "Reject proposal?"}
</AlertDialogTitle>
<AlertDialogDescription>
{isAccept
? `Accepting ${freelancerName ?? "this freelancer"}'s proposal will notify them and start the project.`
: `Rejecting ${freelancerName ?? "this freelancer"}'s proposal will notify them.`}
? `Accepting ${name}'s proposal will notify them and start the project.`
: `Rejecting ${name}'s proposal will notify them.`}
</AlertDialogDescription>
</AlertDialogHeader>
{error && (
<p role="alert" className="text-sm text-destructive">
{error}
</p>
)}
<AlertDialogFooter>
<AlertDialogCancel onClick={onCancel}>Cancel</AlertDialogCancel>
<AlertDialogAction onClick={onConfirm}>
{isAccept ? "Accept" : "Reject"}
<AlertDialogCancel onClick={onCancel} disabled={isSubmitting}>
Cancel
</AlertDialogCancel>
<AlertDialogAction
onClick={(e) => {
e.preventDefault();
onConfirm();
}}
disabled={isSubmitting}
aria-busy={isSubmitting}
>
{isSubmitting
? isAccept
? "Accepting..."
: "Rejecting..."
: isAccept
? "Accept"
: "Reject"}
</AlertDialogAction>
</AlertDialogFooter>
</AlertDialogContent>
</AlertDialog>
);
}
}
8 changes: 4 additions & 4 deletions components/proposals/proposal-empty-state.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@ import { Card, CardContent } from "@/components/ui/card";

export function ProposalEmptyState({ filtered }: { filtered?: boolean }) {
return (
<Card>
<CardContent className="flex flex-col items-center justify-center gap-2 py-16 text-center">
<Card role="status" aria-live="polite">
<CardContent className="flex flex-col items-center justify-center gap-2 px-4 py-12 text-center sm:py-16">
<p className="font-medium">
{filtered ? "No proposals match your filters" : "No proposals yet"}
</p>
<p className="text-sm text-muted-foreground">
<p className="max-w-sm text-sm text-muted-foreground">
{filtered
? "Try changing the status filter or search term."
: "Proposals will appear here once freelancers apply to your project."}
</p>
</CardContent>
</Card>
);
}
}
Loading
Loading