-
@@ -77,18 +90,20 @@ function ATSScoreBar({ score, label }) {
);
}
-export default function EnhancementViewer({
- resumeFile,
- setEnhancedText,
- setBase64FileContent,
- setFileFormat
+export default function EnhancementViewer({
+ resumeFile,
+ setEnhancedText,
+ setBase64FileContent,
+ setFileFormat,
+ enhanceButtonRef,
+ shortcutLabel,
}) {
const [result, setResult] = useState("");
const [loading, setLoading] = useState(false);
const [error, setError] = useState("");
const [atsScores, setAtsScores] = useState(null);
- const { t, i18n } = useTranslation();
+ const { t, i18n } = useTranslation();
useEffect(() => {
if (!resumeFile) return;
@@ -101,15 +116,21 @@ export default function EnhancementViewer({
try {
const { text: resumeText, format } = await extractText(resumeFile);
-
+
if (!resumeText || resumeText.trim() === "") {
throw new Error(t("errors.noText"));
}
- const uploaderName = resumeFile.name.replace(/\.[^/.]+$/, "") || "Resume";
- const language = i18n.language || 'en';
-
- const enhanced = await enhanceResumeWithGemini(resumeText, format, uploaderName, language);
+ const uploaderName =
+ resumeFile.name.replace(/\.[^/.]+$/, "") || "Resume";
+ const language = i18n.language || "en";
+
+ const enhanced = await enhanceResumeWithGemini(
+ resumeText,
+ format,
+ uploaderName,
+ language
+ );
// Extract ATS scores from full response
const scores = extractATSScores(enhanced.displayText);
@@ -122,7 +143,6 @@ export default function EnhancementViewer({
setEnhancedText(cleanDisplay);
setBase64FileContent(enhanced.base64);
setFileFormat(enhanced.format);
-
} catch (e) {
console.error("Enhancement error:", e);
setError(e.message || t("errors.generic"));
@@ -130,54 +150,104 @@ export default function EnhancementViewer({
setLoading(false);
}
})();
- }, [resumeFile, setEnhancedText, setBase64FileContent, setFileFormat, t, i18n.language]);
+ }, [
+ resumeFile,
+ setEnhancedText,
+ setBase64FileContent,
+ setFileFormat,
+ t,
+ i18n.language,
+ ]);
// Helper to render formatted text with better mobile support
const renderFormattedText = (text) => {
- return text.split('\n').map((line, idx) => {
- const trimmedLine = line.trim();
-
- // Skip ATS score lines (already displayed separately)
- if (trimmedLine.toLowerCase().includes('score:') ||
- trimmedLine.toLowerCase().includes('ats analysis') ||
- trimmedLine.toLowerCase().includes('key improvement')) {
- return null;
- }
+ return text
+ .split("\n")
+ .map((line, idx) => {
+ const trimmedLine = line.trim();
- // Section headers
- if (trimmedLine === trimmedLine.toUpperCase() && trimmedLine.length > 0 && trimmedLine.length < 50) {
- return (
-
- {trimmedLine}
-
- );
- }
+ // Skip ATS score lines (already displayed separately)
+ if (
+ trimmedLine.toLowerCase().includes("score:") ||
+ trimmedLine.toLowerCase().includes("ats analysis") ||
+ trimmedLine.toLowerCase().includes("key improvement")
+ ) {
+ return null;
+ }
- // Explanation text
- if (trimmedLine.startsWith('Explanation:')) {
+ // Section headers
+ if (
+ trimmedLine === trimmedLine.toUpperCase() &&
+ trimmedLine.length > 0 &&
+ trimmedLine.length < 50
+ ) {
+ return (
+
+ {trimmedLine}
+
+ );
+ }
+
+ // Explanation text
+ if (trimmedLine.startsWith("Explanation:")) {
+ return (
+
+ {trimmedLine}
+
+ );
+ }
+
+ // Empty lines
+ if (!trimmedLine) {
+ return
;
+ }
+
+ // Regular text with better mobile wrapping
return (
-
+
{trimmedLine}
);
- }
-
- // Empty lines
- if (!trimmedLine) {
- return
;
- }
-
- // Regular text with better mobile wrapping
- return (
-
- {trimmedLine}
-
- );
- }).filter(Boolean);
+ })
+ .filter(Boolean);
};
+ // Add Enhance Resume button (if not loading, not error, and resumeFile exists)
return (
+ {/* Enhance Resume Button */}
+ {!loading && !error && resumeFile && (
+
+
+ {shortcutLabel && (
+
+ {shortcutLabel}
+
+ )}
+
+ )}
+
{loading && (
@@ -192,7 +262,9 @@ export default function EnhancementViewer({
{error && (
-
{t("errors.title")}
+
+ {t("errors.title")}
+
{error}
)}
@@ -204,42 +276,58 @@ export default function EnhancementViewer({
{/* ATS Score Display */}
- {atsScores && (atsScores.original !== null || atsScores.enhanced !== null) && (
-
-
ATS Score Analysis
-
-
- {atsScores.original !== null && (
-
+ {atsScores &&
+ (atsScores.original !== null || atsScores.enhanced !== null) && (
+
+
+ ATS Score Analysis
+
+
+
+ {atsScores.original !== null && (
+
+ )}
+
+ {atsScores.enhanced !== null && (
+
+ )}
+
+
+ {/* Score improvement badge */}
+ {atsScores.original !== null && atsScores.enhanced !== null && (
+
+
+ ✨ Improvement: +{atsScores.enhanced - atsScores.original}{" "}
+ points
+
+
)}
-
- {atsScores.enhanced !== null && (
-
+
+ {/* Key improvements */}
+ {atsScores.improvements.length > 0 && (
+
+
+ Key Improvements:
+
+
+ {atsScores.improvements
+ .slice(0, 5)
+ .map((improvement, idx) => (
+ -
+ {improvement}
+
+ ))}
+
+
)}
-
- {/* Score improvement badge */}
- {atsScores.original !== null && atsScores.enhanced !== null && (
-
-
- ✨ Improvement: +{atsScores.enhanced - atsScores.original} points
-
-
- )}
-
- {/* Key improvements */}
- {atsScores.improvements.length > 0 && (
-
-
Key Improvements:
-
- {atsScores.improvements.slice(0, 5).map((improvement, idx) => (
- - {improvement}
- ))}
-
-
- )}
-
- )}
+ )}
{/* Enhanced Resume Content */}
@@ -249,4 +337,4 @@ export default function EnhancementViewer({
)}
);
-}
\ No newline at end of file
+}
diff --git a/src/Components/FileUpload.jsx b/src/Components/FileUpload.jsx
index 27d6996..81ea10e 100644
--- a/src/Components/FileUpload.jsx
+++ b/src/Components/FileUpload.jsx
@@ -1,7 +1,11 @@
-import { useRef, useState } from "react";
+import { useRef, useState, forwardRef } from "react";
import { useTranslation } from "react-i18next";
-export default function FileUpload({ setResumeFile }) {
+export default function FileUpload({
+ setResumeFile,
+ uploadButtonRef,
+ shortcutLabel,
+}) {
const inputRef = useRef();
const [dragActive, setDragActive] = useState(false);
const { t } = useTranslation();
@@ -42,18 +46,24 @@ export default function FileUpload({ setResumeFile }) {
>
📄
- {t("upload.title")}{" "}
- PDF,{" "}
+ {t("upload.title")} PDF,{" "}
DOCX {t("upload.or")}{" "}
- TXT{" "}
- {t("upload.here")}
+ TXT {t("upload.here")}
-
+
+
+ {shortcutLabel && (
+
+ {shortcutLabel}
+
+ )}
+