Add attachment metadata and overview strategy snapshot
This commit is contained in:
@@ -9,8 +9,13 @@ import {
|
||||
DialogActions,
|
||||
DialogContent,
|
||||
DialogTitle,
|
||||
FormControl,
|
||||
IconButton,
|
||||
InputLabel,
|
||||
LinearProgress,
|
||||
MenuItem,
|
||||
Select,
|
||||
Switch,
|
||||
Table,
|
||||
TableBody,
|
||||
TableCell,
|
||||
@@ -37,6 +42,8 @@ interface AttachmentItem {
|
||||
uploadDate: string;
|
||||
fileType: string;
|
||||
fileSize: number;
|
||||
purpose?: string | null;
|
||||
useForAi: boolean;
|
||||
}
|
||||
|
||||
function fmtSize(n: number) {
|
||||
@@ -56,10 +63,23 @@ function isPdfType(t: string) {
|
||||
|
||||
function guessKind(fileName: string): string {
|
||||
const n = (fileName || "").toLowerCase();
|
||||
if (n.includes("cover")) return "Cover letter";
|
||||
if (n.includes("resume") || n.includes("résumé") || n.includes(" cv") || n.endsWith("cv.pdf")) return "Resume";
|
||||
if (n.includes("portfolio")) return "Portfolio";
|
||||
return "Attachment";
|
||||
if (n.includes("cover")) return "cover-letter";
|
||||
if (n.includes("resume") || n.includes("résumé") || n.includes(" cv") || n.endsWith("cv.pdf")) return "resume";
|
||||
if (n.includes("portfolio")) return "portfolio";
|
||||
if (n.includes("case") || n.includes("sample")) return "case-study";
|
||||
if (n.includes("cert")) return "certificate";
|
||||
return "other";
|
||||
}
|
||||
|
||||
function purposeLabel(purpose: string | null | undefined, t: (key: any) => string) {
|
||||
switch ((purpose || "").trim().toLowerCase()) {
|
||||
case "resume": return t("attachmentsPurposeResume");
|
||||
case "cover-letter": return t("attachmentsPurposeCoverLetter");
|
||||
case "portfolio": return t("attachmentsPurposePortfolio");
|
||||
case "case-study": return t("attachmentsPurposeCaseStudy");
|
||||
case "certificate": return t("attachmentsPurposeCertificate");
|
||||
default: return t("attachmentsPurposeOther");
|
||||
}
|
||||
}
|
||||
|
||||
export default function Attachments({ jobId }: { jobId: number }) {
|
||||
@@ -105,7 +125,7 @@ export default function Attachments({ jobId }: { jobId: number }) {
|
||||
await api.post("/attachments", data, {
|
||||
headers: { "Content-Type": "multipart/form-data" },
|
||||
});
|
||||
toast(files.length === 1 ? "File uploaded." : `${files.length} files uploaded.`, "success");
|
||||
toast(files.length === 1 ? t("attachmentsUploadedSingle") : t("attachmentsUploadedMany", { count: files.length }), "success");
|
||||
await load();
|
||||
} catch (error) {
|
||||
toast(getApiErrorMessage(error, t("attachmentsUploadFailed")), "error");
|
||||
@@ -117,7 +137,7 @@ export default function Attachments({ jobId }: { jobId: number }) {
|
||||
);
|
||||
|
||||
const rename = async (a: AttachmentItem) => {
|
||||
const next = await promptForValue("Rename attachment to:", a.fileName, { title: "Rename attachment", confirmLabel: "Rename" });
|
||||
const next = await promptForValue(t("attachmentsRenamePrompt"), a.fileName, { title: t("attachmentsRenameTitle"), confirmLabel: t("attachmentsRename") });
|
||||
if (!next || next.trim() === a.fileName) return;
|
||||
try {
|
||||
await api.patch(`/attachments/${a.id}`, { fileName: next.trim() });
|
||||
@@ -128,8 +148,18 @@ export default function Attachments({ jobId }: { jobId: number }) {
|
||||
}
|
||||
};
|
||||
|
||||
const updateMetadata = async (a: AttachmentItem, patch: Partial<Pick<AttachmentItem, "purpose" | "useForAi">>) => {
|
||||
try {
|
||||
await api.patch(`/attachments/${a.id}`, { purpose: patch.purpose ?? a.purpose ?? guessKind(a.fileName), useForAi: patch.useForAi ?? a.useForAi });
|
||||
setItems((current) => current.map((item) => item.id === a.id ? { ...item, ...patch } : item));
|
||||
toast(t("attachmentsUpdated"), "success");
|
||||
} catch (error) {
|
||||
toast(getApiErrorMessage(error, t("attachmentsUpdateFailed")), "error");
|
||||
}
|
||||
};
|
||||
|
||||
const remove = async (a: AttachmentItem) => {
|
||||
if (!(await confirmAction(`Delete attachment "${a.fileName}"?`, { title: "Delete attachment", confirmLabel: "Delete", destructive: true }))) return;
|
||||
if (!(await confirmAction(t("attachmentsDeleteConfirm", { name: a.fileName }), { title: t("attachmentsDeleteTitle"), confirmLabel: t("attachmentsDelete"), destructive: true }))) return;
|
||||
try {
|
||||
await api.delete(`/attachments/${a.id}`);
|
||||
toast(t("attachmentsDeleted"), "success");
|
||||
@@ -245,14 +275,15 @@ export default function Attachments({ jobId }: { jobId: number }) {
|
||||
<TableCell sx={{ width: 140 }}>{t("attachmentsKind")}</TableCell>
|
||||
<TableCell sx={{ width: 120 }}>{t("attachmentsType")}</TableCell>
|
||||
<TableCell sx={{ width: 90 }}>{t("attachmentsSize")}</TableCell>
|
||||
<TableCell sx={{ width: 170 }}>{t("attachmentsUploaded")}</TableCell>
|
||||
<TableCell sx={{ width: 160 }}>{t("attachmentsPurpose")}</TableCell>
|
||||
<TableCell sx={{ width: 110 }}>{t("attachmentsAiUse")}</TableCell>
|
||||
<TableCell sx={{ width: 170 }}>{t("attachmentsActions")}</TableCell>
|
||||
</TableRow>
|
||||
</TableHead>
|
||||
<TableBody>
|
||||
{items.map((a) => {
|
||||
const canPreview = isImageType(a.fileType) || isPdfType(a.fileType);
|
||||
const kind = guessKind(a.fileName);
|
||||
const kind = purposeLabel(a.purpose || guessKind(a.fileName), t);
|
||||
return (
|
||||
<TableRow key={a.id} hover>
|
||||
<TableCell>
|
||||
@@ -264,6 +295,25 @@ export default function Attachments({ jobId }: { jobId: number }) {
|
||||
<TableCell sx={{ color: "text.secondary" }}>{a.fileType ? a.fileType.replace("application/", "") : ""}</TableCell>
|
||||
<TableCell sx={{ color: "text.secondary" }}>{a.fileSize ? fmtSize(a.fileSize) : ""}</TableCell>
|
||||
<TableCell sx={{ color: "text.secondary" }}>{a.uploadDate ? new Date(a.uploadDate).toLocaleString() : ""}</TableCell>
|
||||
<TableCell>
|
||||
<FormControl size="small" fullWidth>
|
||||
<InputLabel>{t("attachmentsPurpose")}</InputLabel>
|
||||
<Select value={(a.purpose || guessKind(a.fileName)).toLowerCase()} label={t("attachmentsPurpose")} onChange={(e) => void updateMetadata(a, { purpose: e.target.value })}>
|
||||
<MenuItem value="resume">{t("attachmentsPurposeResume")}</MenuItem>
|
||||
<MenuItem value="cover-letter">{t("attachmentsPurposeCoverLetter")}</MenuItem>
|
||||
<MenuItem value="portfolio">{t("attachmentsPurposePortfolio")}</MenuItem>
|
||||
<MenuItem value="case-study">{t("attachmentsPurposeCaseStudy")}</MenuItem>
|
||||
<MenuItem value="certificate">{t("attachmentsPurposeCertificate")}</MenuItem>
|
||||
<MenuItem value="other">{t("attachmentsPurposeOther")}</MenuItem>
|
||||
</Select>
|
||||
</FormControl>
|
||||
</TableCell>
|
||||
<TableCell>
|
||||
<Box sx={{ display: "flex", alignItems: "center", gap: 0.5 }}>
|
||||
<Switch size="small" checked={Boolean(a.useForAi)} onChange={(_, checked) => void updateMetadata(a, { useForAi: checked })} />
|
||||
<Typography variant="caption" sx={{ color: "text.secondary" }}>{a.useForAi ? t("attachmentsAiEnabled") : t("attachmentsAiDisabled")}</Typography>
|
||||
</Box>
|
||||
</TableCell>
|
||||
<TableCell>
|
||||
<Box sx={{ display: "flex", gap: 0.5, flex: "0 0 auto" }}>
|
||||
{canPreview ? (
|
||||
@@ -288,7 +338,7 @@ export default function Attachments({ jobId }: { jobId: number }) {
|
||||
|
||||
{items.length === 0 ? (
|
||||
<TableRow>
|
||||
<TableCell colSpan={6}>
|
||||
<TableCell colSpan={8}>
|
||||
<Alert severity="info" variant="outlined">
|
||||
{t("attachmentsEmpty")}
|
||||
</Alert>
|
||||
|
||||
@@ -34,6 +34,8 @@ type AttachmentItem = {
|
||||
uploadDate: string;
|
||||
fileType: string;
|
||||
fileSize: number;
|
||||
purpose?: string | null;
|
||||
useForAi: boolean;
|
||||
};
|
||||
|
||||
type FollowUpDraft = {
|
||||
@@ -97,6 +99,7 @@ export default function JobDetailsDialog({ open, jobId, onClose, initialTab = 0,
|
||||
const [focusPlan, setFocusPlan] = useState<FocusPlanResponse | null>(null);
|
||||
const [loadingCandidateFit, setLoadingCandidateFit] = useState(false);
|
||||
const [loadingFocusPlan, setLoadingFocusPlan] = useState(false);
|
||||
const [loadingStrategySnapshot, setLoadingStrategySnapshot] = useState(false);
|
||||
const [interviewPrep, setInterviewPrep] = useState<InterviewPrepResponse | null>(null);
|
||||
const [loadingInterviewPrep, setLoadingInterviewPrep] = useState(false);
|
||||
const [readiness, setReadiness] = useState<ReadinessResponse | null>(null);
|
||||
@@ -137,7 +140,8 @@ export default function JobDetailsDialog({ open, jobId, onClose, initialTab = 0,
|
||||
api.get<AttachmentItem[]>(`/attachments/${jobId}`).then((r) => {
|
||||
const items = Array.isArray(r.data) ? r.data : [];
|
||||
setJobAttachments(items);
|
||||
setSelectedAttachmentIds(items.slice(0, 3).map((item) => item.id));
|
||||
const defaultIds = items.filter((item) => item.useForAi !== false).slice(0, 3).map((item) => item.id);
|
||||
setSelectedAttachmentIds(defaultIds.length > 0 ? defaultIds : items.slice(0, 3).map((item) => item.id));
|
||||
}).catch(() => {
|
||||
setJobAttachments([]);
|
||||
setSelectedAttachmentIds([]);
|
||||
@@ -273,6 +277,40 @@ export default function JobDetailsDialog({ open, jobId, onClose, initialTab = 0,
|
||||
|
||||
{tab === 0 && (
|
||||
<Box sx={{ display: "grid", gridTemplateColumns: "1fr 1fr", gap: 2 }}>
|
||||
<Box sx={{ gridColumn: "1 / -1", display: "flex", justifyContent: "space-between", alignItems: "center", gap: 1, flexWrap: "wrap" }}>
|
||||
<Typography variant="overline">{t("jobDetailsStrategySnapshot")}</Typography>
|
||||
<Button size="small" variant="outlined" disabled={loadingStrategySnapshot} onClick={async () => {
|
||||
if (!jobId) return;
|
||||
setLoadingStrategySnapshot(true);
|
||||
try {
|
||||
const [fitRes, focusRes] = await Promise.all([
|
||||
api.get<CandidateFit>(`/jobapplications/${jobId}/candidate-fit`, { params: { attachmentIds: selectedAttachmentCsv || undefined } }),
|
||||
api.get<FocusPlanResponse>(`/jobapplications/${jobId}/focus-plan`, { params: { attachmentIds: selectedAttachmentCsv || undefined } }),
|
||||
]);
|
||||
setCandidateFit(fitRes.data);
|
||||
setFocusPlan(focusRes.data);
|
||||
} catch {
|
||||
toast(t("jobDetailsStrategySnapshotFailed"), "error");
|
||||
} finally {
|
||||
setLoadingStrategySnapshot(false);
|
||||
}
|
||||
}}>{loadingStrategySnapshot ? t("jobDetailsRefreshing") : t("jobDetailsGenerateStrategySnapshot")}</Button>
|
||||
</Box>
|
||||
{candidateFit || focusPlan ? (
|
||||
<Box sx={{ gridColumn: "1 / -1", p: 1.5, borderRadius: 3, border: "1px solid", borderColor: "divider", backgroundColor: "background.default" }}>
|
||||
<Box sx={{ display: "flex", gap: 1, flexWrap: "wrap", alignItems: "center", mb: 1 }}>
|
||||
{candidateFit ? <Chip size="small" color={candidateFit.matchScore >= 75 ? "success" : candidateFit.matchScore >= 55 ? "warning" : "default"} label={t("jobDetailsMatchPercent", { count: candidateFit.matchScore })} /> : null}
|
||||
{candidateFit?.fitLevel ? <Chip size="small" variant="outlined" label={candidateFit.fitLevel} /> : null}
|
||||
</Box>
|
||||
{focusPlan?.strategicSummary ? <Typography sx={{ whiteSpace: "pre-wrap", mb: 1 }}>{focusPlan.strategicSummary}</Typography> : null}
|
||||
{candidateFit?.matchSummary ? <Typography sx={{ color: "text.secondary", whiteSpace: "pre-wrap", mb: 1.5 }}>{candidateFit.matchSummary}</Typography> : null}
|
||||
{focusPlan?.immediatePriorities?.length ? <ListCard title={t("jobDetailsImmediatePriorities")} items={focusPlan.immediatePriorities.slice(0, 3)} /> : null}
|
||||
</Box>
|
||||
) : (
|
||||
<Box sx={{ gridColumn: "1 / -1" }}>
|
||||
<Typography sx={{ color: "text.secondary" }}>{t("jobDetailsStrategySnapshotEmpty")}</Typography>
|
||||
</Box>
|
||||
)}
|
||||
<Box><Typography variant="overline">{t("jobDetailsDateApplied")}</Typography><Typography>{job ? new Date(job.dateApplied).toLocaleDateString() : ""}</Typography></Box>
|
||||
<Box><Typography variant="overline">{t("jobDetailsDaysSince")}</Typography><Typography>{job?.daysSince ?? ""}</Typography></Box>
|
||||
<Box><Typography variant="overline">{t("jobTableLocation")}</Typography><Typography>{job?.location ?? ""}</Typography></Box>
|
||||
|
||||
@@ -426,15 +426,33 @@ export const translations = {
|
||||
attachmentsType: "Type",
|
||||
attachmentsSize: "Size",
|
||||
attachmentsUploaded: "Uploaded",
|
||||
attachmentsPurpose: "Purpose",
|
||||
attachmentsAiUse: "Use for AI",
|
||||
attachmentsActions: "Actions",
|
||||
attachmentsPreview: "Preview",
|
||||
attachmentsDownload: "Download",
|
||||
attachmentsRename: "Rename",
|
||||
attachmentsDelete: "Delete",
|
||||
attachmentsPurposeResume: "Resume",
|
||||
attachmentsPurposeCoverLetter: "Cover letter",
|
||||
attachmentsPurposePortfolio: "Portfolio",
|
||||
attachmentsPurposeCaseStudy: "Case study",
|
||||
attachmentsPurposeCertificate: "Certificate",
|
||||
attachmentsPurposeOther: "Other",
|
||||
attachmentsRenamePrompt: "Rename attachment to:",
|
||||
attachmentsRenameTitle: "Rename attachment",
|
||||
attachmentsDeleteTitle: "Delete attachment",
|
||||
attachmentsDeleteConfirm: "Delete attachment \"{name}\"?",
|
||||
attachmentsUploadedSingle: "File uploaded.",
|
||||
attachmentsUploadedMany: "{count} files uploaded.",
|
||||
attachmentsAiEnabled: "Included",
|
||||
attachmentsAiDisabled: "Ignored",
|
||||
attachmentsEmpty: "No attachments yet. Upload a resume, cover letter, or portfolio to keep everything tied to this job.",
|
||||
attachmentsPreviewTitle: "Preview: {name}",
|
||||
attachmentsNoInlinePreview: "No inline preview for this file type.",
|
||||
attachmentsUploadFailed: "Upload failed.",
|
||||
attachmentsUpdated: "Attachment updated.",
|
||||
attachmentsUpdateFailed: "Failed to update attachment.",
|
||||
attachmentsRenamed: "Renamed.",
|
||||
attachmentsRenameFailed: "Rename failed.",
|
||||
attachmentsDeleted: "Deleted attachment.",
|
||||
@@ -734,6 +752,10 @@ export const translations = {
|
||||
jobDetailsFollowUpSent: "Follow-up sent and logged.",
|
||||
jobDetailsFollowUpSendFailed: "Failed to send follow-up.",
|
||||
jobDetailsHowYouMatch: "How you match",
|
||||
jobDetailsStrategySnapshot: "Strategy snapshot",
|
||||
jobDetailsGenerateStrategySnapshot: "Generate strategy snapshot",
|
||||
jobDetailsStrategySnapshotEmpty: "Generate a snapshot to see fit, positioning, and immediate priorities in one place.",
|
||||
jobDetailsStrategySnapshotFailed: "Failed to generate strategy snapshot.",
|
||||
jobDetailsMatchPercent: "{count}% match",
|
||||
jobDetailsTailoredPitch: "Tailored pitch",
|
||||
jobDetailsStrongMatches: "Strong matches",
|
||||
@@ -1204,15 +1226,33 @@ export const translations = {
|
||||
attachmentsType: "Filtype",
|
||||
attachmentsSize: "Størrelse",
|
||||
attachmentsUploaded: "Lastet opp",
|
||||
attachmentsPurpose: "Formål",
|
||||
attachmentsAiUse: "Bruk for AI",
|
||||
attachmentsActions: "Handlinger",
|
||||
attachmentsPreview: "Forhåndsvis",
|
||||
attachmentsDownload: "Last ned",
|
||||
attachmentsRename: "Gi nytt navn",
|
||||
attachmentsDelete: "Slett",
|
||||
attachmentsPurposeResume: "CV",
|
||||
attachmentsPurposeCoverLetter: "Søknadsbrev",
|
||||
attachmentsPurposePortfolio: "Portefølje",
|
||||
attachmentsPurposeCaseStudy: "Case-studie",
|
||||
attachmentsPurposeCertificate: "Sertifikat",
|
||||
attachmentsPurposeOther: "Annet",
|
||||
attachmentsRenamePrompt: "Gi vedlegget nytt navn:",
|
||||
attachmentsRenameTitle: "Gi nytt navn til vedlegg",
|
||||
attachmentsDeleteTitle: "Slett vedlegg",
|
||||
attachmentsDeleteConfirm: "Slette vedlegget \"{name}\"?",
|
||||
attachmentsUploadedSingle: "Fil lastet opp.",
|
||||
attachmentsUploadedMany: "{count} filer lastet opp.",
|
||||
attachmentsAiEnabled: "Inkludert",
|
||||
attachmentsAiDisabled: "Ignorert",
|
||||
attachmentsEmpty: "Ingen vedlegg ennå. Last opp en CV, et søknadsbrev eller en portefølje for å knytte alt til denne jobben.",
|
||||
attachmentsPreviewTitle: "Forhåndsvisning: {name}",
|
||||
attachmentsNoInlinePreview: "Ingen innebygd forhåndsvisning for denne filtypen.",
|
||||
attachmentsUploadFailed: "Opplasting mislyktes.",
|
||||
attachmentsUpdated: "Vedlegg oppdatert.",
|
||||
attachmentsUpdateFailed: "Kunne ikke oppdatere vedlegget.",
|
||||
attachmentsRenamed: "Gi nytt navn fullført.",
|
||||
attachmentsRenameFailed: "Kunne ikke gi nytt navn.",
|
||||
attachmentsDeleted: "Vedlegg slettet.",
|
||||
@@ -1512,6 +1552,10 @@ export const translations = {
|
||||
jobDetailsFollowUpSent: "Oppfølging sendt og loggført.",
|
||||
jobDetailsFollowUpSendFailed: "Kunne ikke sende oppfølging.",
|
||||
jobDetailsHowYouMatch: "Slik matcher du",
|
||||
jobDetailsStrategySnapshot: "Strategioversikt",
|
||||
jobDetailsGenerateStrategySnapshot: "Generer strategioversikt",
|
||||
jobDetailsStrategySnapshotEmpty: "Generer en oversikt for å se match, posisjonering og viktigste prioriteringer på ett sted.",
|
||||
jobDetailsStrategySnapshotFailed: "Kunne ikke generere strategioversikt.",
|
||||
jobDetailsMatchPercent: "{count}% match",
|
||||
jobDetailsTailoredPitch: "Tilpasset pitch",
|
||||
jobDetailsStrongMatches: "Sterke matcher",
|
||||
|
||||
Reference in New Issue
Block a user