Skip to content

Commit 5f67dfc

Browse files
committed
error states
1 parent 0289334 commit 5f67dfc

File tree

4 files changed

+38
-16
lines changed

4 files changed

+38
-16
lines changed

src/components/interactive/CoverLetterCard.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ export default function CoverLetterCard({ report, candidateName, roleName, compa
5555
tempDiv.innerHTML = `
5656
<div style="text-align: center; margin-bottom: 40px; border-bottom: 2px solid #000; padding-bottom: 20px;">
5757
<h1 style="margin: 0; font-size: 24px; font-weight: bold;">Cover Letter</h1>
58-
<p style="margin: 10px 0 0 0; font-size: 14px; color: #666;">${candidateName} - ${roleName} @ ${companyName}</p>
5958
</div>
6059
<div style="white-space: pre-wrap; text-align: justify;">${report.cover_letter}</div>
6160
`;

src/components/interactive/JobDescriptionCard.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ function fmtMinutes(iso: string) {
3434
function prettifyStatus(raw: string) {
3535
if (!raw) return "Unknown";
3636
if (raw === "success") return "Successfully Processed";
37-
if (raw === "failed_parse_jd") return "Failed to Parse";
37+
if (raw === "failed_parsing_jd") return "Failed to Parse";
3838
return raw.replace(/_/g, " ");
3939
}
4040

src/components/interactive/ReportCard.tsx

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { useReactToPrint } from "react-to-print";
55
import { Card, CardHeader, CardTitle, CardContent } from "@/components/ui/card";
66
import { Progress } from "@/components/ui/progress";
77
import { Button } from "@/components/ui/button";
8+
import { Badge } from "@/components/ui/badge";
89
import { Check, X, Download, Shield, LogIn } from "lucide-react";
910
import { EXTERNAL } from '@/constant';
1011
import { getUserProfile, getLoginUrl, type UserProfile } from '@/lib/utils';
@@ -59,10 +60,23 @@ function fmtMinutes(iso: string) {
5960

6061
function prettifyStatus(raw: string) {
6162
if (!raw) return "—";
62-
if (raw === "failed_parse_jd") return "Job description parsing failed";
63+
if (raw === "failed_parsing_jd") return "Job description parsing failed";
64+
if (raw === "failed_generating_report") return "Report generation failed";
6365
return raw.replace(/_/g, " ");
6466
}
6567

68+
function getStatusIcon(status: string) {
69+
if (status === "success") return <Check className="h-4 w-4 text-green-600" />;
70+
if (status?.startsWith("failed")) return <X className="h-4 w-4 text-red-600" />;
71+
return null;
72+
}
73+
74+
function getStatusColor(status: string) {
75+
if (status === "success") return "bg-green-100 text-green-800";
76+
if (status?.startsWith("failed")) return "bg-red-100 text-red-800";
77+
return "bg-yellow-100 text-yellow-800";
78+
}
79+
6680
function getExpressionLevel(score: number): { level: string; color: string; imagePath: string } {
6781
if (score >= 80) {
6882
return { level: "High", color: "text-green-600", imagePath: "/expression_high.png" };
@@ -97,9 +111,8 @@ export default function ReportCard() {
97111

98112
const roleName = report?.submission?.job_description?.role_name ?? "—";
99113
const companyName = report?.submission?.job_description?.company_name ?? "—";
100-
const backfillStatus = prettifyStatus(
101-
report?.submission?.job_description?.backfill_status ?? ""
102-
);
114+
const rawBackfillStatus = report?.submission?.job_description?.backfill_status ?? "";
115+
const backfillStatus = prettifyStatus(rawBackfillStatus);
103116

104117
// Create a nicely formatted filename for the PDF download
105118
const createFileName = () => {
@@ -410,12 +423,13 @@ export default function ReportCard() {
410423
)}
411424
</p>
412425
</div>
413-
{backfillStatus &&
414-
backfillStatus.toLowerCase() !== "success" && (
426+
{rawBackfillStatus &&
427+
rawBackfillStatus.toLowerCase() !== "success" && (
415428
<p>
416-
<span className="inline-flex items-center gap-1 rounded-full bg-red-100 text-red-700 px-2 py-1 text-xs font-medium">
429+
<Badge className={`flex items-center gap-1 ${getStatusColor(rawBackfillStatus)}`}>
430+
{getStatusIcon(rawBackfillStatus)}
417431
{backfillStatus}
418-
</span>
432+
</Badge>
419433
</p>
420434
)}
421435
<p className="text-sm text-gray-500">

src/components/interactive/RoleFitIndexForm.tsx

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ const STATE_CONFIG = {
6262
submitted: {
6363
step: 2,
6464
buttonText: "Analyzing…",
65-
progressStep: 0,
65+
progressStep: 1,
6666
isProcessing: true,
6767
canSubmit: false,
6868
helperText: "Analyzing your CV & JD — this usually takes ~30 seconds. You'll be redirected when the report is ready.",
@@ -71,7 +71,7 @@ const STATE_CONFIG = {
7171
parsed_jd: {
7272
step: 2,
7373
buttonText: "Analyzing…",
74-
progressStep: 1,
74+
progressStep: 2,
7575
isProcessing: true,
7676
canSubmit: false,
7777
helperText: "Analyzing your CV & JD — this usually takes ~30 seconds. You'll be redirected when the report is ready.",
@@ -80,7 +80,7 @@ const STATE_CONFIG = {
8080
generated_report: {
8181
step: 2,
8282
buttonText: "Analyzing…",
83-
progressStep: 2,
83+
progressStep: 3,
8484
isProcessing: true,
8585
canSubmit: false,
8686
helperText: "Analyzing your CV & JD — this usually takes ~30 seconds. You'll be redirected when the report is ready.",
@@ -103,6 +103,15 @@ const STATE_CONFIG = {
103103
canSubmit: true,
104104
helperText: "Failed to parse the job description. Please check the format and try again.",
105105
isError: true
106+
},
107+
failed_generating_report: {
108+
step: 2,
109+
buttonText: "Analyze Role Fit Now",
110+
progressStep: 2,
111+
isProcessing: false,
112+
canSubmit: true,
113+
helperText: "Failed to generate the report. Please try again.",
114+
isError: true
106115
}
107116
} as const;
108117

@@ -369,10 +378,10 @@ export default function RoleFitForm() {
369378

370379
if ((rec.status || "").startsWith("failed_")) {
371380
if (rec.status === "failed_parsing_jd") {
372-
// Don't set a generic error - let the UI show the failure at the parsing step
381+
// Show failure at the parsing step and allow retry
373382
setCurrentState("failed_parsing_jd");
374383
clearTimeout(timeout);
375-
reject(new Error("Failed to parse job description"));
384+
resolve(false); // Resolve instead of reject to allow retry
376385
} else {
377386
setGenericError("Submission failed: " + rec.status);
378387
clearTimeout(timeout);
@@ -583,7 +592,7 @@ export default function RoleFitForm() {
583592
{stateConfig.helperText ||
584593
(genericError
585594
? "Something went wrong. Please try again."
586-
: "Analyzing your CV & JD — this usually takes ~30 seconds. You'll be redirected when the report is ready.")}
595+
: "Analyzing your CV & JD — this usually takes ~20 seconds. You'll be redirected when the report is ready.")}
587596
</p>
588597
</div>
589598
)}

0 commit comments

Comments
 (0)