Skip to content
Merged
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
11 changes: 11 additions & 0 deletions core/onboarding-review.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ function resume(): ExtractedResume {
startDate: "2021-05-01",
endDate: "2021-08-01",
description: "",
site: null,
},
];
return data;
Expand Down Expand Up @@ -164,6 +165,9 @@ describe("keptOnboardingHistory", () => {
org: "State",
title: "AS",
field: "Math",
place: "Philadelphia, PA",
lat: 39.95,
lng: -75.16,
};
expect(isBlankOnboardingCheckItem(blankOnboardingCheckItem("Job", -1))).toBe(true);
expect(isBlankOnboardingCheckItem(job)).toBe(false);
Expand All @@ -186,6 +190,13 @@ describe("keptOnboardingHistory", () => {
institution: "State",
degree: "AS",
field: "Math",
location: "Philadelphia, PA",
});
expect(kept.education[0]?.site).toEqual({
label: "Philadelphia, PA",
address: "Philadelphia, PA",
latitude: 39.95,
longitude: -75.16,
});
expect(kept.skills).toEqual(["PLC"]);
});
Expand Down
12 changes: 9 additions & 3 deletions core/onboarding-review.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,14 +67,14 @@ export function onboardingCheckItems(data: ExtractedResume): OnboardingCheckItem
org: school.institution || "Untitled school",
title: school.degree,
field: school.field,
place: school.location || ONBOARDING_NO_PLACE,
place: school.site?.label || school.location || ONBOARDING_NO_PLACE,
startDate: school.startDate,
endDate: school.endDate,
isCurrent: false,
description: school.description,
achievements: [],
lat: null,
lng: null,
lat: school.site?.latitude ?? null,
lng: school.site?.longitude ?? null,
}),
);
return [...jobs, ...schools];
Expand Down Expand Up @@ -223,6 +223,10 @@ function keptSchool(
const base = item.sourceIndex >= 0 ? extracted.education[item.sourceIndex] : undefined;
if (item.sourceIndex >= 0 && !base) return null;
const place = item.place === ONBOARDING_NO_PLACE ? (base?.location ?? "") : item.place;
const site =
item.lat != null && item.lng != null
? { label: place, address: place, latitude: item.lat, longitude: item.lng }
: (base?.site ?? null);
return {
institution: "",
degree: "",
Expand All @@ -231,6 +235,7 @@ function keptSchool(
startDate: "",
endDate: "",
description: "",
site: null,
...base,
institution: item.org.trim() || "Untitled school",
degree: item.title.trim(),
Expand All @@ -239,6 +244,7 @@ function keptSchool(
startDate: item.startDate,
endDate: item.endDate,
description: item.description.trim(),
site,
};
}

Expand Down
2 changes: 2 additions & 0 deletions core/resume-extract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ export type ExtractedSchool = {
startDate: string;
endDate: string;
description: string;
site: ExtractedSite | null;
};

export type ExtractedResume = {
Expand Down Expand Up @@ -378,5 +379,6 @@ function asSchool(value: unknown): ExtractedSchool | null {
startDate: asText(row.startDate),
endDate: asText(row.endDate),
description: asText(row.description),
site: parseSite(row.site),
};
}
41 changes: 41 additions & 0 deletions server/history.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,47 @@ describe("GET /api/history", () => {
}
});

it("pins a validated school site onto the Work Map", async () => {
const ctx = setup();
try {
await ctx.app.request("/api/history", {
method: "POST",
headers: { "content-type": "application/json" },
body: JSON.stringify({
experience: [],
education: [
{
institution: "City College",
degree: "AAS",
location: "Philadelphia, PA",
site: {
label: "City College",
address: "Philadelphia, Pennsylvania, United States",
latitude: 39.9526,
longitude: -75.1652,
},
},
],
skills: [],
}),
});
const map = await ctx.app.request("/api/work-map");
const body = (await map.json()) as {
roles: Array<{
kind: string;
locations: Array<{ label: string; latitude: number }>;
}>;
};
expect(body.roles[0]).toMatchObject({ kind: "school" });
expect(body.roles[0]?.locations[0]).toMatchObject({
label: "City College",
latitude: 39.9526,
});
} finally {
ctx.close();
}
});

it("pins a validated job site onto the Work Map", async () => {
const ctx = setup();
try {
Expand Down
3 changes: 3 additions & 0 deletions server/history.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,9 @@ export async function saveExtractedResume(
school.field,
now,
);
if (school.site) {
persistExtractedSite(db, occupantId, schoolId, school.site);
}
roles.push({
id: schoolId,
kind: "school",
Expand Down
41 changes: 38 additions & 3 deletions web/src/Onboarding.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ export function Onboarding({
const abortRef = useRef<AbortController | null>(null);
const scanAbort = useRef<AbortController | null>(null);
const fileInputRef = useRef<HTMLInputElement | null>(null);
const previewDialogRef = useRef<HTMLDialogElement>(null);

useEffect(() => {
if (!photo) return;
Expand All @@ -97,6 +98,16 @@ export function Onboarding({
return () => URL.revokeObjectURL(url);
}, [photo]);

useEffect(() => {
const node = previewDialogRef.current;
if (!node) return;
if (previewOpen) {
if (!node.open) node.showModal();
return;
}
if (node.open) node.close();
}, [previewOpen, file]);

useEffect(() => {
let cancel = false;
void (async () => {
Expand Down Expand Up @@ -644,9 +655,9 @@ export function Onboarding({
<button
type="button"
className="onboarding-btn onboarding-btn-ghost onboarding-file-preview"
onClick={() => setPreviewOpen((open) => !open)}
onClick={() => setPreviewOpen(true)}
>
{previewOpen ? "Hide preview" : "Preview"}
Preview
</button>
</span>
</div>
Expand All @@ -664,7 +675,31 @@ export function Onboarding({
/>
</label>
)}
{file && previewOpen ? <ResumePreview file={file} /> : null}
{file ? (
<dialog
ref={previewDialogRef}
className="onboarding-review onboarding-file-dialog"
aria-labelledby="onboarding-file-preview-title"
onClose={() => setPreviewOpen(false)}
>
<div className="onboarding-review-head">
<p className="onboarding-kicker">Resume</p>
<button
type="button"
className="onboarding-btn onboarding-btn-ghost"
onClick={() => setPreviewOpen(false)}
>
Close
</button>
</div>
<h2 id="onboarding-file-preview-title">
<em>{file.name}</em>
</h2>
<div className="onboarding-file-dialog-body">
{previewOpen ? <ResumePreview file={file} /> : null}
</div>
</dialog>
) : null}
{file ? (
<input
ref={fileInputRef}
Expand Down
Loading
Loading