Add application workflow and lead analytics
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
// ==UserScript==
|
||||
// @name Job tracker capture
|
||||
// @namespace https://www.adam-french.co.uk/
|
||||
// @version 2.0.0
|
||||
// @version 2.1.0
|
||||
// @description Add the job posting you are looking at to the tracker at /jobs/.
|
||||
// @match *://*/*
|
||||
// @noframes
|
||||
@@ -279,6 +279,12 @@
|
||||
h("option", { value: "saved", textContent: "Saved for later" }),
|
||||
),
|
||||
notes: h("textarea", {}),
|
||||
salaryRange: h("input", { type: "text" }),
|
||||
workArrangement: h("input", { type: "text" }),
|
||||
applicationSource: h("input", { type: "text" }),
|
||||
requisitionId: h("input", { type: "text" }),
|
||||
resumeVersion: h("input", { type: "text" }),
|
||||
contactRole: h("input", { type: "text" }),
|
||||
description: h("textarea", { class: "description" }),
|
||||
};
|
||||
const message = h("div", { class: "message" });
|
||||
@@ -295,6 +301,12 @@
|
||||
field("Company", f.company),
|
||||
field("Location", f.location),
|
||||
field("Status", f.status),
|
||||
field("Salary / range", f.salaryRange),
|
||||
field("Work arrangement", f.workArrangement),
|
||||
field("Application source", f.applicationSource),
|
||||
field("Requisition ID", f.requisitionId),
|
||||
field("Resume version", f.resumeVersion),
|
||||
field("Contact / referral role", f.contactRole),
|
||||
field("Notes", f.notes),
|
||||
field("URL", f.url),
|
||||
h(
|
||||
@@ -367,8 +379,9 @@
|
||||
const seq = ++openSeq;
|
||||
const { f, panel, save } = ui;
|
||||
|
||||
for (const key of ["jobTitle", "company", "location", "notes"])
|
||||
for (const key of ["jobTitle", "company", "location", "notes", "salaryRange", "workArrangement", "applicationSource", "requisitionId"])
|
||||
f[key].value = "";
|
||||
for (const key of ["resumeVersion", "contactRole"]) f[key].value = "";
|
||||
f.url.value = location.href;
|
||||
f.description.value = pageText();
|
||||
f.status.value = "applied";
|
||||
@@ -386,7 +399,7 @@
|
||||
if (seq !== openSeq) return;
|
||||
// Only empty fields are filled: the popup is usable while Claude is
|
||||
// thinking, and anything typed in the meantime wins.
|
||||
for (const key of ["jobTitle", "company", "location", "notes"])
|
||||
for (const key of ["jobTitle", "company", "location", "notes", "salaryRange", "workArrangement", "applicationSource", "requisitionId"])
|
||||
if (!f[key].value.trim()) f[key].value = posting?.[key] ?? "";
|
||||
say(
|
||||
posting?.jobTitle && posting?.company
|
||||
@@ -415,6 +428,12 @@
|
||||
url: f.url.value,
|
||||
status: f.status.value,
|
||||
notes: f.notes.value,
|
||||
salaryRange: f.salaryRange.value,
|
||||
workArrangement: f.workArrangement.value,
|
||||
applicationSource: f.applicationSource.value,
|
||||
requisitionId: f.requisitionId.value,
|
||||
resumeVersion: f.resumeVersion.value,
|
||||
contactRole: f.contactRole.value,
|
||||
description: f.description.value,
|
||||
});
|
||||
showTracked(result.application);
|
||||
|
||||
@@ -11,6 +11,7 @@ import Icon from "@/components/Icon.vue";
|
||||
const userscriptUrl = `${import.meta.env.BASE_URL}job-capture.user.js`;
|
||||
|
||||
const NAV = [
|
||||
{ to: "/dashboard", label: "Dashboard", icon: "chart" },
|
||||
{ to: "/", label: "Applications", icon: "briefcase" },
|
||||
{ to: "/leads", label: "Leads", icon: "inbox" },
|
||||
{ to: "/settings", label: "Settings", icon: "sliders" },
|
||||
|
||||
@@ -539,6 +539,9 @@ textarea.input-sm {
|
||||
background: var(--warn);
|
||||
box-shadow: 0 0 0 3px color-mix(in srgb, var(--warn) 20%, transparent);
|
||||
}
|
||||
.dot[class*="status-"] {
|
||||
background: var(--st, var(--text-3));
|
||||
}
|
||||
|
||||
.status-saved { --st: var(--st-saved); }
|
||||
.status-applied { --st: var(--st-applied); }
|
||||
|
||||
@@ -51,6 +51,7 @@ const PATHS = {
|
||||
play: '<polygon points="6 3 20 12 6 21 6 3"/>',
|
||||
globe:
|
||||
'<circle cx="12" cy="12" r="10"/><path d="M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20"/><path d="M2 12h20"/>',
|
||||
chart: '<path d="M3 3v18h18"/><path d="m7 16 4-5 3 3 5-7"/>',
|
||||
};
|
||||
|
||||
const svg = computed(() => PATHS[props.name] ?? "");
|
||||
|
||||
@@ -11,6 +11,7 @@ import { createRouter, createWebHistory } from "vue-router";
|
||||
export default createRouter({
|
||||
history: createWebHistory(import.meta.env.BASE_URL),
|
||||
routes: [
|
||||
{ path: "/dashboard", name: "dashboard", component: () => import("@/views/Dashboard.vue") },
|
||||
{ path: "/", name: "tracker", component: () => import("@/views/JobApplications.vue") },
|
||||
{ path: "/leads", name: "leads", component: () => import("@/views/JobLeads.vue") },
|
||||
{ path: "/settings", name: "settings", component: () => import("@/views/Settings.vue") },
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
import { defineStore } from "pinia";
|
||||
import { gql } from "@/graphql";
|
||||
|
||||
export const useAnalyticsStore = defineStore("analytics", {
|
||||
state: () => ({ data: null, loading: false, error: null }),
|
||||
actions: {
|
||||
async fetch() {
|
||||
this.loading = true;
|
||||
this.error = null;
|
||||
try {
|
||||
const result = await gql(`query DashboardAnalytics {
|
||||
analytics {
|
||||
totalApplications statusCounts { status count }
|
||||
transitions { from to count }
|
||||
responseCount interviewCount offerCount
|
||||
responseRate interviewRate offerRate
|
||||
averageDaysToResponse averageDaysToInterview averageDaysToOffer
|
||||
}
|
||||
}`);
|
||||
this.data = result.analytics;
|
||||
} catch (error) {
|
||||
this.error = error;
|
||||
} finally {
|
||||
this.loading = false;
|
||||
}
|
||||
},
|
||||
},
|
||||
});
|
||||
@@ -11,7 +11,7 @@ import { gql } from "@/graphql";
|
||||
|
||||
// `description` is deliberately not here: it is the full text of the posting,
|
||||
// tens of kilobytes a row, and is fetched per row when asked for.
|
||||
const APP_FIELDS = `id jobTitle company location url status notes appliedAt createdAt updatedAt`;
|
||||
const APP_FIELDS = `id jobTitle company location url status notes appliedAt createdAt updatedAt nextAction nextActionAt contactName contactEmail contactRole salaryRange workArrangement applicationSource resumeVersion requisitionId`;
|
||||
|
||||
export const useJobApplicationsStore = createCrudStore("jobApplications", {
|
||||
type: "JobApplication",
|
||||
@@ -21,19 +21,42 @@ export const useJobApplicationsStore = createCrudStore("jobApplications", {
|
||||
insert: "prepend",
|
||||
// deleteJobApplication returns Boolean!, and errors for an id that is gone.
|
||||
deleteReturns: "boolean",
|
||||
extend: () => ({
|
||||
extend: ({ update }) => ({
|
||||
/**
|
||||
* The captured posting text for one row; `""` when none was saved. Throws
|
||||
* on failure. Not cached here: the view keeps its own per-visit cache, so
|
||||
* returning to the page re-reads a posting the userscript may have
|
||||
* replaced.
|
||||
*/
|
||||
async fetchDescription(id) {
|
||||
async fetchDescription(id) {
|
||||
const data = await gql(
|
||||
`query JobDescription($id: ID!) { jobApplication(id: $id) { description } }`,
|
||||
{ id },
|
||||
);
|
||||
return data.jobApplication?.description ?? "";
|
||||
},
|
||||
}),
|
||||
return data.jobApplication?.description ?? "";
|
||||
},
|
||||
async fetchActivity(id) {
|
||||
const data = await gql(
|
||||
`query JobApplicationActivity($id: ID!) {
|
||||
jobApplicationEvents(applicationId: $id) { id kind note occurredAt createdAt }
|
||||
}`,
|
||||
{ id },
|
||||
);
|
||||
return data.jobApplicationEvents ?? [];
|
||||
},
|
||||
async updateFollowUp(id, input) {
|
||||
return update(id, input);
|
||||
},
|
||||
async addActivityEvent(applicationId, input) {
|
||||
const data = await gql(
|
||||
`mutation AddJobApplicationEvent($applicationId: ID!, $input: AddJobApplicationEventInput!) {
|
||||
addJobApplicationEvent(applicationId: $applicationId, input: $input) {
|
||||
id kind note occurredAt createdAt
|
||||
}
|
||||
}`,
|
||||
{ applicationId, input },
|
||||
);
|
||||
return data.addJobApplicationEvent;
|
||||
},
|
||||
}),
|
||||
});
|
||||
|
||||
@@ -31,14 +31,14 @@ export const useJobLeadsStore = defineStore("jobLeads", () => {
|
||||
* Load every lead, all states. `includeUnmatched` also returns the ones the
|
||||
* keyword pre-filter rejected, which is most of a company board.
|
||||
*/
|
||||
async function fetch({ includeUnmatched = false } = {}) {
|
||||
async function fetch({ includeUnmatched = false, filters = null } = {}) {
|
||||
loading.value = true;
|
||||
try {
|
||||
const data = await gql(
|
||||
`query JobLeads($includeUnmatched: Boolean) {
|
||||
jobLeads(includeUnmatched: $includeUnmatched) { ${LEAD_FIELDS} }
|
||||
`query JobLeads($includeUnmatched: Boolean, $filters: JobLeadFilters) {
|
||||
jobLeads(includeUnmatched: $includeUnmatched, filters: $filters) { ${LEAD_FIELDS} }
|
||||
}`,
|
||||
{ includeUnmatched },
|
||||
{ includeUnmatched, filters },
|
||||
);
|
||||
leads.value = data.jobLeads || [];
|
||||
error.value = null;
|
||||
@@ -63,11 +63,23 @@ export const useJobLeadsStore = defineStore("jobLeads", () => {
|
||||
return replace(data[mutation]);
|
||||
}
|
||||
|
||||
async function bulkTransition(mutation, ids) {
|
||||
const data = await gql(
|
||||
`mutation ${mutation}($ids: [ID!]!) { ${mutation}(ids: $ids) { ${LEAD_FIELDS} } }`,
|
||||
{ ids },
|
||||
);
|
||||
for (const lead of data[mutation] || []) replace(lead);
|
||||
return data[mutation] || [];
|
||||
}
|
||||
|
||||
/** Each returns the updated lead and throws on failure. */
|
||||
const dismiss = (id) => transition("dismissJobLead", id);
|
||||
const restore = (id) => transition("restoreJobLead", id);
|
||||
/** Adds the lead to the tracker as a saved application. */
|
||||
const promote = (id) => transition("promoteJobLead", id);
|
||||
const bulkDismiss = (ids) => bulkTransition("bulkDismissJobLeads", ids);
|
||||
const bulkRestore = (ids) => bulkTransition("bulkRestoreJobLeads", ids);
|
||||
const bulkPromote = (ids) => bulkTransition("bulkPromoteJobLeads", ids);
|
||||
|
||||
/** The posting text for one lead; `""` when the source gave none. Throws. */
|
||||
async function fetchDescription(id) {
|
||||
@@ -117,5 +129,5 @@ export const useJobLeadsStore = defineStore("jobLeads", () => {
|
||||
return data.rescoreJobLeads;
|
||||
}
|
||||
|
||||
return { leads, loading, error, status, fetch, dismiss, restore, promote, fetchDescription, fetchStatus, runSync, scoreAll, rescoreAll };
|
||||
return { leads, loading, error, status, fetch, dismiss, restore, promote, bulkDismiss, bulkRestore, bulkPromote, fetchDescription, fetchStatus, runSync, scoreAll, rescoreAll };
|
||||
});
|
||||
|
||||
@@ -0,0 +1,78 @@
|
||||
<script setup>
|
||||
import { computed, onMounted } from "vue";
|
||||
import { storeToRefs } from "pinia";
|
||||
import { useAnalyticsStore } from "@/stores/analytics";
|
||||
import Icon from "@/components/Icon.vue";
|
||||
|
||||
const store = useAnalyticsStore();
|
||||
const { data, loading, error } = storeToRefs(store);
|
||||
const statuses = computed(() => data.value?.statusCounts ?? []);
|
||||
const maxStatus = computed(() => Math.max(1, ...statuses.value.map((item) => item.count)));
|
||||
const rates = computed(() => [
|
||||
{ label: "Response", count: data.value?.responseCount ?? 0, rate: data.value?.responseRate ?? 0, color: "var(--st-screening)" },
|
||||
{ label: "Interview", count: data.value?.interviewCount ?? 0, rate: data.value?.interviewRate ?? 0, color: "var(--st-interviewing)" },
|
||||
{ label: "Offer", count: data.value?.offerCount ?? 0, rate: data.value?.offerRate ?? 0, color: "var(--st-offer)" },
|
||||
]);
|
||||
|
||||
function percent(value) { return `${Math.round(value * 100)}%`; }
|
||||
function days(value) { return value == null ? "No data" : `${value.toFixed(1)} days`; }
|
||||
function statusLabel(value) { return value.charAt(0).toUpperCase() + value.slice(1); }
|
||||
|
||||
onMounted(() => store.fetch());
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="page dashboard">
|
||||
<header class="page-header">
|
||||
<div><h1 class="page-title">Dashboard</h1><p class="page-sub">A read on your application funnel and momentum.</p></div>
|
||||
<button class="btn btn-ghost" :disabled="loading" @click="store.fetch"><Icon name="refresh" :size="15" /> Refresh</button>
|
||||
</header>
|
||||
<div v-if="error" class="alert">{{ error.message }}</div>
|
||||
<div v-if="loading && !data" class="empty">Loading analytics...</div>
|
||||
<template v-else-if="data">
|
||||
<section class="summary-grid" aria-label="Funnel summary">
|
||||
<article class="summary card"><span class="summary-label">Tracked applications</span><strong>{{ data.totalApplications }}</strong><span class="muted">all active records</span></article>
|
||||
<article class="summary card"><span class="summary-label">Response rate</span><strong>{{ percent(data.responseRate) }}</strong><span class="muted">{{ data.responseCount }} with a response</span></article>
|
||||
<article class="summary card"><span class="summary-label">Interview rate</span><strong>{{ percent(data.interviewRate) }}</strong><span class="muted">{{ data.interviewCount }} reached interview</span></article>
|
||||
<article class="summary card"><span class="summary-label">Offer rate</span><strong>{{ percent(data.offerRate) }}</strong><span class="muted">{{ data.offerCount }} offers</span></article>
|
||||
</section>
|
||||
<section class="dashboard-columns">
|
||||
<article class="card panel"><div class="card-header"><h2 class="card-title"><Icon name="briefcase" :size="16" /> Current pipeline</h2></div><div class="card-body pipeline">
|
||||
<div v-for="item in statuses" :key="item.status" class="pipeline-row"><span class="pipeline-name"><i :class="`dot status-${item.status}`"></i>{{ statusLabel(item.status) }}</span><span class="bar"><i :class="`bar-fill status-${item.status}`" :style="{ width: `${(item.count / maxStatus) * 100}%` }"></i></span><strong>{{ item.count }}</strong></div>
|
||||
<p v-if="!statuses.length" class="empty">No applications yet.</p>
|
||||
</div></article>
|
||||
<article class="card panel"><div class="card-header"><h2 class="card-title"><Icon name="clock" :size="16" /> Time to milestone</h2></div><div class="card-body timing">
|
||||
<div><span>Response</span><strong>{{ days(data.averageDaysToResponse) }}</strong></div><div><span>Interview</span><strong>{{ days(data.averageDaysToInterview) }}</strong></div><div><span>Offer</span><strong>{{ days(data.averageDaysToOffer) }}</strong></div>
|
||||
<p class="hint">Measured from applied date to the first matching history event.</p>
|
||||
</div></article>
|
||||
</section>
|
||||
<article class="card panel conversion"><div class="card-header"><h2 class="card-title">Conversion checkpoints</h2></div><div class="card-body rate-list"><div v-for="item in rates" :key="item.label" class="rate-row"><div><strong>{{ item.label }}</strong><span class="muted">{{ item.count }} applications</span></div><div class="rate-track"><i :style="{ width: `${item.rate * 100}%`, background: item.color }"></i></div><strong>{{ percent(item.rate) }}</strong></div></div></article>
|
||||
<article v-if="data.transitions.length" class="card panel"><div class="card-header"><h2 class="card-title">Recorded stage transitions</h2></div><div class="card-body transitions"><span v-for="item in data.transitions" :key="`${item.from}-${item.to}`">{{ statusLabel(item.from) }} <b>→</b> {{ statusLabel(item.to) }} <strong>{{ item.count }}</strong></span></div></article>
|
||||
</template>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.summary-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0.85rem; margin-bottom: 1rem; }
|
||||
.summary { display: flex; flex-direction: column; gap: 0.15rem; padding: 1rem 1.1rem; }
|
||||
.summary-label { color: var(--text-2); font-size: 0.8rem; font-weight: 600; }
|
||||
.summary strong { font-size: 2rem; line-height: 1.1; font-variant-numeric: tabular-nums; }
|
||||
.dashboard-columns { display: grid; grid-template-columns: 1.2fr 0.8fr; gap: 1rem; margin-bottom: 1rem; }
|
||||
.panel { overflow: hidden; margin-bottom: 1rem; }
|
||||
.pipeline, .timing { display: grid; gap: 0.85rem; }
|
||||
.pipeline-row, .rate-row { display: grid; grid-template-columns: 7rem minmax(4rem, 1fr) 2rem; align-items: center; gap: 0.7rem; }
|
||||
.pipeline-name { display: flex; align-items: center; gap: 0.45rem; font-size: 0.82rem; }
|
||||
.bar, .rate-track { height: 0.5rem; overflow: hidden; border-radius: 99px; background: var(--surface-hover); }
|
||||
.bar-fill, .rate-track i { display: block; height: 100%; min-width: 0.25rem; border-radius: inherit; background: var(--st, var(--accent)); }
|
||||
.timing > div { display: flex; justify-content: space-between; border-bottom: 1px solid var(--border); padding-bottom: 0.65rem; color: var(--text-2); }
|
||||
.timing strong { color: var(--text); font-variant-numeric: tabular-nums; }
|
||||
.rate-list { display: grid; gap: 1rem; }
|
||||
.rate-row > div:first-child { display: flex; flex-direction: column; gap: 0.1rem; }
|
||||
.rate-row > strong { text-align: right; font-variant-numeric: tabular-nums; }
|
||||
.transitions { display: flex; flex-wrap: wrap; gap: 0.6rem; }
|
||||
.transitions span { padding: 0.45rem 0.65rem; border: 1px solid var(--border); border-radius: var(--radius-sm); color: var(--text-2); font-size: 0.8rem; }
|
||||
.transitions b { color: var(--accent); margin: 0 0.25rem; }
|
||||
.transitions strong { margin-left: 0.4rem; color: var(--text); }
|
||||
@media (max-width: 800px) { .summary-grid { grid-template-columns: repeat(2, 1fr); } .dashboard-columns { grid-template-columns: 1fr; gap: 0; } }
|
||||
@media (max-width: 420px) { .summary-grid { grid-template-columns: 1fr; } .pipeline-row, .rate-row { grid-template-columns: 6.5rem minmax(3rem, 1fr) 1.6rem; gap: 0.45rem; } }
|
||||
</style>
|
||||
@@ -0,0 +1,179 @@
|
||||
<script setup>
|
||||
import { computed, onBeforeUnmount, onMounted, ref, watch } from "vue";
|
||||
import { useJobApplicationsStore } from "@/stores/jobApplications";
|
||||
import Icon from "@/components/Icon.vue";
|
||||
|
||||
const props = defineProps({ application: { type: Object, required: true } });
|
||||
const emit = defineEmits(["close", "updated", "fail"]);
|
||||
const store = useJobApplicationsStore();
|
||||
const events = ref([]);
|
||||
const loadingEvents = ref(true);
|
||||
const saving = ref(false);
|
||||
const addingEvent = ref(false);
|
||||
const form = ref({});
|
||||
const eventForm = ref({ kind: "note", note: "", occurredAt: toInputDate(new Date().toISOString()) });
|
||||
|
||||
function resetForm(application) {
|
||||
form.value = {
|
||||
nextAction: application.nextAction ?? "",
|
||||
nextActionAt: toInputDate(application.nextActionAt),
|
||||
contactName: application.contactName ?? "",
|
||||
contactEmail: application.contactEmail ?? "",
|
||||
contactRole: application.contactRole ?? "",
|
||||
salaryRange: application.salaryRange ?? "",
|
||||
workArrangement: application.workArrangement ?? "",
|
||||
applicationSource: application.applicationSource ?? "",
|
||||
resumeVersion: application.resumeVersion ?? "",
|
||||
requisitionId: application.requisitionId ?? "",
|
||||
};
|
||||
}
|
||||
|
||||
function closeOnEscape(event) {
|
||||
if (event.key === "Escape") emit("close");
|
||||
}
|
||||
|
||||
function toInputDate(value) {
|
||||
return value ? new Date(value).toISOString().slice(0, 16) : "";
|
||||
}
|
||||
|
||||
function displayDate(value) {
|
||||
return value
|
||||
? new Intl.DateTimeFormat(undefined, { dateStyle: "medium", timeStyle: "short" }).format(new Date(value))
|
||||
: "Unknown date";
|
||||
}
|
||||
|
||||
const sortedEvents = computed(() => [...events.value].sort((a, b) => new Date(b.occurredAt ?? b.createdAt) - new Date(a.occurredAt ?? a.createdAt)));
|
||||
|
||||
async function loadEvents() {
|
||||
loadingEvents.value = true;
|
||||
try {
|
||||
events.value = await store.fetchActivity(props.application.id);
|
||||
} catch (err) {
|
||||
emit("fail", err);
|
||||
} finally {
|
||||
loadingEvents.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
async function saveFollowUp() {
|
||||
saving.value = true;
|
||||
try {
|
||||
const updated = await store.updateFollowUp(props.application.id, {
|
||||
nextAction: form.value.nextAction || "",
|
||||
nextActionAt: form.value.nextActionAt ? new Date(form.value.nextActionAt).toISOString() : null,
|
||||
clearNextActionAt: !form.value.nextActionAt,
|
||||
contactName: form.value.contactName || "",
|
||||
contactEmail: form.value.contactEmail || "",
|
||||
contactRole: form.value.contactRole || "",
|
||||
salaryRange: form.value.salaryRange || "",
|
||||
workArrangement: form.value.workArrangement || "",
|
||||
applicationSource: form.value.applicationSource || "",
|
||||
resumeVersion: form.value.resumeVersion || "",
|
||||
requisitionId: form.value.requisitionId || "",
|
||||
});
|
||||
emit("updated", updated);
|
||||
} catch (err) {
|
||||
emit("fail", err);
|
||||
} finally {
|
||||
saving.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
async function addEvent() {
|
||||
if (!eventForm.value.note.trim()) return;
|
||||
addingEvent.value = true;
|
||||
try {
|
||||
const event = await store.addActivityEvent(props.application.id, {
|
||||
kind: eventForm.value.kind,
|
||||
note: eventForm.value.note.trim(),
|
||||
occurredAt: eventForm.value.occurredAt ? new Date(eventForm.value.occurredAt).toISOString() : undefined,
|
||||
});
|
||||
events.value = [event, ...events.value];
|
||||
eventForm.value.note = "";
|
||||
emit("updated", props.application);
|
||||
} catch (err) {
|
||||
emit("fail", err);
|
||||
} finally {
|
||||
addingEvent.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
document.addEventListener("keydown", closeOnEscape);
|
||||
loadEvents();
|
||||
});
|
||||
resetForm(props.application);
|
||||
watch(() => props.application.id, () => {
|
||||
events.value = [];
|
||||
resetForm(props.application);
|
||||
loadEvents();
|
||||
});
|
||||
onBeforeUnmount(() => document.removeEventListener("keydown", closeOnEscape));
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<aside class="detail-drawer" aria-label="Application details" tabindex="-1">
|
||||
<div class="detail-head">
|
||||
<div>
|
||||
<p class="detail-kicker">Application details</p>
|
||||
<h2>{{ application.jobTitle }}</h2>
|
||||
<p class="muted">{{ application.company }}</p>
|
||||
</div>
|
||||
<button class="btn btn-ghost btn-icon" aria-label="Close details" title="Close" @click="emit('close')"><Icon name="x" /></button>
|
||||
</div>
|
||||
|
||||
<div class="detail-body">
|
||||
<section class="detail-section">
|
||||
<div class="detail-section-title"><Icon name="clock" /> Follow-up</div>
|
||||
<form class="detail-fields" @submit.prevent="saveFollowUp">
|
||||
<label class="field"><span>Next action</span><input v-model="form.nextAction" class="input" placeholder="Send a follow-up email" /></label>
|
||||
<label class="field"><span>Due</span><input v-model="form.nextActionAt" class="input" type="datetime-local" /></label>
|
||||
<label class="field"><span>Contact name</span><input v-model="form.contactName" class="input" placeholder="Hiring manager" /></label>
|
||||
<label class="field"><span>Contact email</span><input v-model="form.contactEmail" class="input" type="email" placeholder="[email protected]" /></label>
|
||||
<label class="field"><span>Contact / referral role</span><input v-model="form.contactRole" class="input" placeholder="Hiring manager" /></label>
|
||||
<label class="field"><span>Salary / range</span><input v-model="form.salaryRange" class="input" /></label>
|
||||
<label class="field"><span>Work arrangement</span><input v-model="form.workArrangement" class="input" /></label>
|
||||
<label class="field"><span>Application source</span><input v-model="form.applicationSource" class="input" /></label>
|
||||
<label class="field"><span>Resume version</span><input v-model="form.resumeVersion" class="input" /></label>
|
||||
<label class="field"><span>Requisition ID</span><input v-model="form.requisitionId" class="input" /></label>
|
||||
<button class="btn btn-primary" type="submit" :disabled="saving">{{ saving ? "Saving…" : "Save follow-up" }}</button>
|
||||
</form>
|
||||
</section>
|
||||
|
||||
<section class="detail-section">
|
||||
<div class="detail-section-title"><Icon name="file" /> Activity</div>
|
||||
<form class="event-form" @submit.prevent="addEvent">
|
||||
<div class="event-row"><select v-model="eventForm.kind" class="input"><option value="note">Note</option><option value="email">Email</option><option value="call">Call</option><option value="interview">Interview</option></select><input v-model="eventForm.occurredAt" class="input" type="datetime-local" aria-label="Activity date" /></div>
|
||||
<textarea v-model="eventForm.note" class="input" rows="3" placeholder="What happened?" aria-label="Activity note" />
|
||||
<button class="btn" type="submit" :disabled="addingEvent || !eventForm.note.trim()"><Icon name="plus" /> Add activity</button>
|
||||
</form>
|
||||
<p v-if="loadingEvents" class="hint">Loading activity…</p>
|
||||
<p v-else-if="!sortedEvents.length" class="hint">No activity recorded yet.</p>
|
||||
<ol v-else class="activity-list">
|
||||
<li v-for="event in sortedEvents" :key="event.id">
|
||||
<div class="activity-meta"><strong>{{ event.kind }}</strong><time>{{ displayDate(event.occurredAt || event.createdAt) }}</time></div>
|
||||
<p>{{ event.note }}</p>
|
||||
</li>
|
||||
</ol>
|
||||
</section>
|
||||
</div>
|
||||
</aside>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.detail-drawer { position: fixed; z-index: 20; inset: 0 0 0 auto; display: flex; flex-direction: column; width: min(420px, 100vw); border-left: 1px solid var(--border); background: var(--surface); box-shadow: var(--shadow-lg); }
|
||||
.detail-head { display: flex; justify-content: space-between; gap: 1rem; padding: 1.25rem 1.25rem 1rem; border-bottom: 1px solid var(--border); }
|
||||
.detail-head h2 { margin-top: .15rem; font-size: 1.15rem; }
|
||||
.detail-kicker { color: var(--accent); font-size: .75rem; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; }
|
||||
.detail-body { overflow-y: auto; padding: 1.1rem 1.25rem 2rem; }
|
||||
.detail-section + .detail-section { margin-top: 1.5rem; padding-top: 1.5rem; border-top: 1px solid var(--border); }
|
||||
.detail-section-title { display: flex; align-items: center; gap: .45rem; margin-bottom: .8rem; font-weight: 600; }
|
||||
.detail-fields, .event-form { display: grid; gap: .7rem; }
|
||||
.event-row { display: grid; grid-template-columns: .8fr 1.2fr; gap: .5rem; }
|
||||
.activity-list { display: grid; gap: .85rem; margin: 1rem 0 0; padding: 0; list-style: none; }
|
||||
.activity-list li { padding-left: .8rem; border-left: 2px solid var(--border-strong); }
|
||||
.activity-meta { display: flex; justify-content: space-between; gap: .5rem; color: var(--text-2); font-size: .78rem; text-transform: capitalize; }
|
||||
.activity-meta time { color: var(--text-3); text-transform: none; }
|
||||
.activity-list p { margin-top: .2rem; white-space: pre-wrap; }
|
||||
@media (max-width: 640px) { .detail-drawer { position: fixed; inset: 0; width: 100%; } .detail-head { padding: 1rem; } .detail-body { padding: 1rem 1rem 2rem; } .event-row { grid-template-columns: 1fr; } }
|
||||
</style>
|
||||
@@ -30,6 +30,12 @@ function blankForm() {
|
||||
url: "",
|
||||
status: "applied",
|
||||
notes: "",
|
||||
salaryRange: "",
|
||||
workArrangement: "",
|
||||
applicationSource: "",
|
||||
resumeVersion: "",
|
||||
requisitionId: "",
|
||||
contactRole: "",
|
||||
// Logging an application on the day you send it is the common case, so the
|
||||
// date defaults to today rather than landing null and ageing as unknown.
|
||||
appliedAt: today(),
|
||||
@@ -48,6 +54,12 @@ async function createApplication() {
|
||||
location: form.value.location || undefined,
|
||||
url: form.value.url || undefined,
|
||||
notes: form.value.notes || undefined,
|
||||
salaryRange: form.value.salaryRange || undefined,
|
||||
workArrangement: form.value.workArrangement || undefined,
|
||||
applicationSource: form.value.applicationSource || undefined,
|
||||
resumeVersion: form.value.resumeVersion || undefined,
|
||||
requisitionId: form.value.requisitionId || undefined,
|
||||
contactRole: form.value.contactRole || undefined,
|
||||
appliedAt: form.value.appliedAt
|
||||
? new Date(form.value.appliedAt).toISOString()
|
||||
: undefined,
|
||||
@@ -109,6 +121,12 @@ async function createApplication() {
|
||||
<span>Notes</span>
|
||||
<textarea v-model="form.notes" class="input" rows="2" />
|
||||
</label>
|
||||
<label class="field af-span-2"><span>Salary / range</span><input v-model="form.salaryRange" class="input" placeholder="£60-70k" /></label>
|
||||
<label class="field af-span-2"><span>Work arrangement</span><input v-model="form.workArrangement" class="input" placeholder="Hybrid" /></label>
|
||||
<label class="field af-span-2"><span>Application source</span><input v-model="form.applicationSource" class="input" placeholder="LinkedIn" /></label>
|
||||
<label class="field af-span-2"><span>Resume version</span><input v-model="form.resumeVersion" class="input" placeholder="CV 2026-10" /></label>
|
||||
<label class="field af-span-2"><span>Requisition ID</span><input v-model="form.requisitionId" class="input" /></label>
|
||||
<label class="field af-span-2"><span>Contact / referral role</span><input v-model="form.contactRole" class="input" placeholder="Hiring manager" /></label>
|
||||
<div class="af-actions af-span-6">
|
||||
<button v-if="closable" type="button" class="btn" @click="emit('close')">
|
||||
Cancel
|
||||
|
||||
@@ -16,16 +16,20 @@
|
||||
* links to for installing, and the leads inbox at `/jobs/leads`
|
||||
* (JobLeads.vue), where tracking a lead adds it here as Saved.
|
||||
*/
|
||||
import { ref, computed, onMounted } from "vue";
|
||||
import { ref, computed, onMounted, watch } from "vue";
|
||||
import { useRoute, useRouter } from "vue-router";
|
||||
import { storeToRefs } from "pinia";
|
||||
import { useJobApplicationsStore } from "@/stores/jobApplications";
|
||||
import { STATUS_OPTIONS, OPEN_STATUSES } from "./jobStatus";
|
||||
import JobReferences from "./JobReferences.vue";
|
||||
import JobApplicationForm from "./JobApplicationForm.vue";
|
||||
import JobApplicationDetail from "./JobApplicationDetail.vue";
|
||||
import Icon from "@/components/Icon.vue";
|
||||
|
||||
const store = useJobApplicationsStore();
|
||||
const { applications } = storeToRefs(store);
|
||||
const route = useRoute();
|
||||
const router = useRouter();
|
||||
const editingId = ref(null);
|
||||
const editForm = ref({});
|
||||
const error = ref("");
|
||||
@@ -39,12 +43,29 @@ const descriptions = ref({});
|
||||
|
||||
// Filter/sort state. All of it runs over the already-loaded array — the query
|
||||
// has no arguments and the dataset is one person's applications.
|
||||
const search = ref("");
|
||||
const statusFilter = ref(null);
|
||||
const sortKey = ref("updatedAt");
|
||||
const sortDir = ref("desc");
|
||||
const search = ref(typeof route.query.q === "string" ? route.query.q : "");
|
||||
const statusFilter = ref(typeof route.query.status === "string" ? route.query.status : null);
|
||||
const sortKey = ref(["jobTitle", "company", "status", "appliedAt", "updatedAt"].includes(route.query.sort) ? route.query.sort : "updatedAt");
|
||||
const sortDir = ref(route.query.dir === "asc" ? "asc" : "desc");
|
||||
// Narrows the table to isStale() rows: the follow-up queue.
|
||||
const staleOnly = ref(false);
|
||||
const staleOnly = ref(route.query.stale === "1");
|
||||
const followUpFilter = ref(["all", "overdue", "upcoming", "unscheduled", "none"].includes(route.query.follow) ? route.query.follow : "all");
|
||||
const selectedApplication = ref(null);
|
||||
|
||||
function applicationQuery() {
|
||||
const query = { ...route.query };
|
||||
search.value ? (query.q = search.value) : delete query.q;
|
||||
statusFilter.value ? (query.status = statusFilter.value) : delete query.status;
|
||||
sortKey.value !== "updatedAt" ? (query.sort = sortKey.value) : delete query.sort;
|
||||
sortDir.value !== "desc" ? (query.dir = sortDir.value) : delete query.dir;
|
||||
staleOnly.value ? (query.stale = "1") : delete query.stale;
|
||||
followUpFilter.value !== "all" ? (query.follow = followUpFilter.value) : delete query.follow;
|
||||
return query;
|
||||
}
|
||||
|
||||
watch([search, statusFilter, sortKey, sortDir, staleOnly, followUpFilter], () => {
|
||||
router.replace({ query: applicationQuery() });
|
||||
});
|
||||
|
||||
// The add form is folded away behind the header's button once there is a
|
||||
// table to look at; with no rows yet it is the only thing to do.
|
||||
@@ -68,12 +89,53 @@ function clearError() {
|
||||
error.value = "";
|
||||
}
|
||||
|
||||
function followUpState(app) {
|
||||
if (!app.nextActionAt) return app.nextAction ? "unscheduled" : "none";
|
||||
return new Date(app.nextActionAt).getTime() < Date.now() ? "overdue" : "upcoming";
|
||||
}
|
||||
|
||||
function followUpLabel(app) {
|
||||
const state = followUpState(app);
|
||||
if (state === "overdue") return "overdue";
|
||||
if (state === "upcoming") return `due ${new Intl.DateTimeFormat(undefined, { month: "short", day: "numeric" }).format(new Date(app.nextActionAt))}`;
|
||||
return state === "unscheduled" ? "no date" : "no follow-up";
|
||||
}
|
||||
|
||||
function selectApplication(app, event) {
|
||||
if (event?.target?.closest?.("a,button,input,select,textarea")) return;
|
||||
selectedApplication.value = app;
|
||||
router.replace({ query: { ...applicationQuery(), app: String(app.id) } });
|
||||
}
|
||||
|
||||
function closeDetails() {
|
||||
selectedApplication.value = null;
|
||||
const query = { ...route.query };
|
||||
delete query.app;
|
||||
router.replace({ query });
|
||||
}
|
||||
|
||||
function onDetailUpdated(updated) {
|
||||
if (updated?.id) selectedApplication.value = updated;
|
||||
clearError();
|
||||
}
|
||||
|
||||
async function fetchApplications() {
|
||||
// The store's fetch() records its failure instead of throwing.
|
||||
await store.fetch();
|
||||
if (store.error) fail(store.error);
|
||||
}
|
||||
|
||||
watch(
|
||||
[applications, () => route.query.app],
|
||||
() => {
|
||||
const id = Number(route.query.app);
|
||||
selectedApplication.value = Number.isInteger(id)
|
||||
? applications.value.find((app) => app.id === id) ?? null
|
||||
: null;
|
||||
},
|
||||
{ immediate: true },
|
||||
);
|
||||
|
||||
function startEdit(app) {
|
||||
// Switching rows mid-edit would throw away unsaved typing silently, and the
|
||||
// Edit button sits in every row, so the misclick is easy to make.
|
||||
@@ -184,6 +246,12 @@ function exportCsv() {
|
||||
"Company",
|
||||
"Status",
|
||||
"Location",
|
||||
"Salary / range",
|
||||
"Work arrangement",
|
||||
"Source",
|
||||
"Resume version",
|
||||
"Requisition ID",
|
||||
"Contact role",
|
||||
"URL",
|
||||
"Applied",
|
||||
"Notes",
|
||||
@@ -194,6 +262,12 @@ function exportCsv() {
|
||||
a.company,
|
||||
a.status,
|
||||
a.location ?? "",
|
||||
a.salaryRange ?? "",
|
||||
a.workArrangement ?? "",
|
||||
a.applicationSource ?? "",
|
||||
a.resumeVersion ?? "",
|
||||
a.requisitionId ?? "",
|
||||
a.contactRole ?? "",
|
||||
a.url ?? "",
|
||||
a.appliedAt ? a.appliedAt.substring(0, 10) : "",
|
||||
a.notes ?? "",
|
||||
@@ -261,10 +335,11 @@ const visibleApplications = computed(() => {
|
||||
if (statusFilter.value && app.status?.toLowerCase() !== statusFilter.value)
|
||||
return false;
|
||||
if (staleOnly.value && !isStale(app)) return false;
|
||||
if (followUpFilter.value !== "all" && followUpState(app) !== followUpFilter.value) return false;
|
||||
if (!q) return true;
|
||||
// Notes are searched because captures and promoted leads append to them,
|
||||
// making them the de-facto history of the application.
|
||||
return [app.jobTitle, app.company, app.location, app.notes]
|
||||
return [app.jobTitle, app.company, app.location, app.notes, app.salaryRange, app.workArrangement, app.applicationSource, app.resumeVersion, app.requisitionId, app.contactRole]
|
||||
.filter(Boolean)
|
||||
.some((field) => field.toLowerCase().includes(q));
|
||||
});
|
||||
@@ -292,6 +367,8 @@ function toggleSort(key) {
|
||||
}
|
||||
|
||||
const staleCount = computed(() => applications.value.filter(isStale).length);
|
||||
const overdueCount = computed(() => applications.value.filter((app) => followUpState(app) === "overdue").length);
|
||||
const upcomingCount = computed(() => applications.value.filter((app) => followUpState(app) === "upcoming").length);
|
||||
|
||||
const openCount = computed(() =>
|
||||
applications.value.filter((app) =>
|
||||
@@ -398,6 +475,13 @@ onMounted(fetchApplications);
|
||||
aria-label="Search applications"
|
||||
/>
|
||||
</label>
|
||||
<select v-model="followUpFilter" class="input ja-follow-filter" aria-label="Follow-up filter">
|
||||
<option value="all">All follow-ups</option>
|
||||
<option value="overdue">Overdue ({{ overdueCount }})</option>
|
||||
<option value="upcoming">Upcoming ({{ upcomingCount }})</option>
|
||||
<option value="unscheduled">Needs a date</option>
|
||||
<option value="none">No follow-up</option>
|
||||
</select>
|
||||
<label class="check" :class="{ 'ja-check-dim': !staleCount }">
|
||||
<input v-model="staleOnly" type="checkbox" />
|
||||
Needs follow-up
|
||||
@@ -428,12 +512,13 @@ onMounted(fetchApplications);
|
||||
</button>
|
||||
</th>
|
||||
<th>Location</th>
|
||||
<th :aria-sort="ariaSort('appliedAt')">
|
||||
<th :aria-sort="ariaSort('appliedAt')">
|
||||
<button class="ja-sort" @click="toggleSort('appliedAt')">
|
||||
Applied <Icon v-if="sortIcon('appliedAt')" :name="sortIcon('appliedAt')" :size="14" />
|
||||
</button>
|
||||
</th>
|
||||
<th>Notes</th>
|
||||
</th>
|
||||
<th>Follow-up</th>
|
||||
<th>Notes</th>
|
||||
<th><span class="sr-only">Actions</span></th>
|
||||
</tr>
|
||||
</thead>
|
||||
@@ -442,6 +527,11 @@ onMounted(fetchApplications);
|
||||
<tr
|
||||
v-if="editingId !== app.id"
|
||||
:class="{ 'ja-stale': isStale(app), 'ja-open': descriptionId === app.id }"
|
||||
tabindex="0"
|
||||
:aria-label="`Open details for ${app.jobTitle} at ${app.company}`"
|
||||
@click="selectApplication(app, $event)"
|
||||
@keydown.enter="selectApplication(app)"
|
||||
@keydown.space.prevent="selectApplication(app)"
|
||||
>
|
||||
<td class="ja-role" data-label="Role">
|
||||
<a
|
||||
@@ -480,9 +570,12 @@ onMounted(fetchApplications);
|
||||
</option>
|
||||
</select>
|
||||
</td>
|
||||
<td class="ja-muted" data-label="Location">{{ app.location || "—" }}</td>
|
||||
<td
|
||||
class="ja-age"
|
||||
<td class="ja-muted" data-label="Location">
|
||||
{{ app.location || "—" }}
|
||||
<small v-if="app.workArrangement" class="ja-meta-line">{{ app.workArrangement }}</small>
|
||||
</td>
|
||||
<td
|
||||
class="ja-age"
|
||||
data-label="Applied"
|
||||
:title="app.appliedAt ? app.appliedAt.substring(0, 10) : ''"
|
||||
>
|
||||
@@ -491,11 +584,19 @@ onMounted(fetchApplications);
|
||||
v-if="isStale(app)"
|
||||
class="ja-stale-tag"
|
||||
:title="`Open, and nothing has changed for ${STALE_DAYS}+ days`"
|
||||
>follow up</span
|
||||
>follow up</span
|
||||
>
|
||||
</td>
|
||||
<td class="ja-notes-cell" data-label="Notes" :title="app.notes">
|
||||
{{ app.notes ?? "" }}
|
||||
</td>
|
||||
<td class="ja-follow" data-label="Follow-up">
|
||||
<span v-if="app.nextAction" class="ja-follow-action">{{ app.nextAction }}</span>
|
||||
<span class="ja-follow-state" :class="`ja-follow-${followUpState(app)}`">
|
||||
<Icon name="clock" :size="13" /> {{ followUpLabel(app) }}
|
||||
</span>
|
||||
</td>
|
||||
<td class="ja-notes-cell" data-label="Notes" :title="app.notes">
|
||||
<span v-if="app.salaryRange" class="ja-meta-line">{{ app.salaryRange }}</span>
|
||||
{{ app.notes ?? "" }}
|
||||
<small v-if="app.applicationSource" class="ja-meta-line">{{ app.applicationSource }}</small>
|
||||
</td>
|
||||
<td class="ja-actions">
|
||||
<button
|
||||
@@ -574,15 +675,16 @@ onMounted(fetchApplications);
|
||||
aria-label="Location"
|
||||
/>
|
||||
</td>
|
||||
<td data-label="Applied">
|
||||
<input
|
||||
<td data-label="Applied">
|
||||
<input
|
||||
v-model="editForm.appliedAt"
|
||||
class="input input-sm"
|
||||
type="date"
|
||||
aria-label="Applied date"
|
||||
/>
|
||||
</td>
|
||||
<td data-label="Notes">
|
||||
/>
|
||||
</td>
|
||||
<td data-label="Follow-up" class="ja-muted">Edit in details</td>
|
||||
<td data-label="Notes">
|
||||
<!-- Textarea, not an input: the pipeline appends newline-joined
|
||||
findings here, so notes are routinely multi-line. -->
|
||||
<textarea
|
||||
@@ -605,7 +707,7 @@ onMounted(fetchApplications);
|
||||
</td>
|
||||
</tr>
|
||||
<tr v-if="descriptionId === app.id" class="ja-desc-row">
|
||||
<td colspan="7">
|
||||
<td colspan="8">
|
||||
<p v-if="descriptions[app.id] === undefined" class="hint">
|
||||
Loading…
|
||||
</p>
|
||||
@@ -637,6 +739,14 @@ onMounted(fetchApplications);
|
||||
|
||||
<JobReferences class="ja-aside" @fail="fail" @ok="clearError" />
|
||||
</div>
|
||||
<JobApplicationDetail
|
||||
v-if="selectedApplication"
|
||||
:key="selectedApplication.id"
|
||||
:application="selectedApplication"
|
||||
@close="closeDetails"
|
||||
@updated="onDetailUpdated"
|
||||
@fail="fail"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -665,6 +775,38 @@ onMounted(fetchApplications);
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.ja-follow-filter {
|
||||
flex: 0 1 10rem;
|
||||
}
|
||||
.ja-follow {
|
||||
min-width: 9rem;
|
||||
}
|
||||
.ja-follow-action {
|
||||
display: block;
|
||||
max-width: 13rem;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
.ja-follow-state {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 0.25rem;
|
||||
margin-top: 0.2rem;
|
||||
color: var(--text-3);
|
||||
font-size: 0.75rem;
|
||||
}
|
||||
.ja-follow-overdue {
|
||||
color: var(--danger);
|
||||
font-weight: 600;
|
||||
}
|
||||
.ja-follow-upcoming {
|
||||
color: var(--accent);
|
||||
}
|
||||
.ja-follow-unscheduled {
|
||||
color: var(--warn);
|
||||
}
|
||||
|
||||
.ja-aside {
|
||||
position: sticky;
|
||||
top: 1.5rem;
|
||||
@@ -939,6 +1081,18 @@ a.ja-title:hover {
|
||||
/* Seven columns plus actions will not fit a phone, so the table becomes
|
||||
stacked cards with the header text carried by each cell's data-label. */
|
||||
@media (max-width: 720px) {
|
||||
.ja-toolbar {
|
||||
align-items: stretch;
|
||||
gap: 0.65rem;
|
||||
}
|
||||
.ja-toolbar .search,
|
||||
.ja-follow-filter {
|
||||
flex-basis: 100%;
|
||||
}
|
||||
.ja-showing {
|
||||
margin-left: 0;
|
||||
}
|
||||
|
||||
/* Eight tiles would take three rows; on a phone they scroll sideways. */
|
||||
.ja-pipeline {
|
||||
grid-template-columns: none;
|
||||
|
||||
+124
-13
@@ -19,8 +19,8 @@
|
||||
* button does not wait: the server starts the job and this page polls its
|
||||
* status, then reloads the list when it finishes.
|
||||
*/
|
||||
import { ref, computed, onMounted, onBeforeUnmount } from "vue";
|
||||
import { RouterLink } from "vue-router";
|
||||
import { ref, computed, onMounted, onBeforeUnmount, watch } from "vue";
|
||||
import { RouterLink, useRoute, useRouter } from "vue-router";
|
||||
import { storeToRefs } from "pinia";
|
||||
import { useJobLeadsStore } from "@/stores/jobLeads";
|
||||
import { useJobSearchProfileStore } from "@/stores/jobSearchProfile";
|
||||
@@ -38,23 +38,45 @@ const SOURCE_LABELS = { greenhouse: "Greenhouse", lever: "Lever", ashby: "Ashby"
|
||||
const POLL_MS = 3000;
|
||||
|
||||
const store = useJobLeadsStore();
|
||||
const route = useRoute();
|
||||
const router = useRouter();
|
||||
const { leads, status, loading } = storeToRefs(store);
|
||||
const { profile } = storeToRefs(useJobSearchProfileStore());
|
||||
|
||||
const error = ref("");
|
||||
const tab = ref("new");
|
||||
const search = ref("");
|
||||
const tab = ref(["new", "promoted", "dismissed"].includes(route.query.tab) ? route.query.tab : "new");
|
||||
const search = ref(typeof route.query.q === "string" ? route.query.q : "");
|
||||
// Two separate "show me the rest" switches: leads scored below the profile's
|
||||
// minimum (already loaded, hidden here), and leads the keyword filter
|
||||
// rejected (not loaded at all until asked for — that is most of every board).
|
||||
const showLowScores = ref(false);
|
||||
const showUnmatched = ref(false);
|
||||
const showLowScores = ref(route.query.low === "1");
|
||||
const showUnmatched = ref(route.query.unmatched === "1");
|
||||
// "score" is the order the server sends; "posted" re-sorts here by the
|
||||
// posting's own date.
|
||||
const sortBy = ref("score");
|
||||
const sortBy = ref(route.query.sort === "posted" ? "posted" : "score");
|
||||
const busyId = ref(null);
|
||||
const selected = ref(new Set());
|
||||
const sourceFilter = ref(typeof route.query.source === "string" ? route.query.source : "");
|
||||
const companyFilter = ref(typeof route.query.company === "string" ? route.query.company : "");
|
||||
const locationFilter = ref(typeof route.query.location === "string" ? route.query.location : "");
|
||||
const minFilter = ref(typeof route.query.min === "string" ? route.query.min : "");
|
||||
const maxFilter = ref(typeof route.query.max === "string" ? route.query.max : "");
|
||||
const bulkBusy = ref(false);
|
||||
const sourcesBox = ref(null);
|
||||
|
||||
function leadsQuery() {
|
||||
const query = { ...route.query };
|
||||
const values = { tab, q: search, sort: sortBy, source: sourceFilter, company: companyFilter, location: locationFilter, min: minFilter, max: maxFilter };
|
||||
for (const [key, state] of Object.entries(values)) state.value ? (query[key] = state.value) : delete query[key];
|
||||
showLowScores.value ? (query.low = "1") : delete query.low;
|
||||
showUnmatched.value ? (query.unmatched = "1") : delete query.unmatched;
|
||||
return query;
|
||||
}
|
||||
|
||||
watch([tab, search, sortBy, sourceFilter, companyFilter, locationFilter, minFilter, maxFilter, showLowScores, showUnmatched], () => {
|
||||
router.replace({ query: leadsQuery() });
|
||||
});
|
||||
|
||||
// The posting text for the one lead whose description is open.
|
||||
// `undefined` in the cache means "not fetched", `""` means "fetched, none".
|
||||
const descriptionId = ref(null);
|
||||
@@ -71,7 +93,16 @@ function clearError() {
|
||||
|
||||
async function fetchLeads() {
|
||||
// The store's fetch() records its failure instead of throwing.
|
||||
await store.fetch({ includeUnmatched: showUnmatched.value });
|
||||
await store.fetch({
|
||||
includeUnmatched: showUnmatched.value,
|
||||
filters: {
|
||||
sourceKind: sourceFilter.value || undefined,
|
||||
company: companyFilter.value || undefined,
|
||||
location: locationFilter.value || undefined,
|
||||
minScore: minFilter.value === "" ? undefined : Number(minFilter.value),
|
||||
maxScore: maxFilter.value === "" ? undefined : Number(maxFilter.value),
|
||||
},
|
||||
});
|
||||
if (store.error) fail(store.error);
|
||||
}
|
||||
|
||||
@@ -102,6 +133,11 @@ const visibleLeads = computed(() => {
|
||||
const needle = search.value.trim().toLowerCase();
|
||||
const shown = inTab.value.filter((lead) => {
|
||||
if (tab.value === "new" && !showLowScores.value && isLow(lead)) return false;
|
||||
if (sourceFilter.value && lead.sourceKind !== sourceFilter.value) return false;
|
||||
if (companyFilter.value && !lead.company.toLowerCase().includes(companyFilter.value.toLowerCase())) return false;
|
||||
if (locationFilter.value && !lead.location.toLowerCase().includes(locationFilter.value.toLowerCase())) return false;
|
||||
if (minFilter.value !== "" && (lead.score == null || lead.score < Number(minFilter.value))) return false;
|
||||
if (maxFilter.value !== "" && (lead.score == null || lead.score > Number(maxFilter.value))) return false;
|
||||
if (!needle) return true;
|
||||
return [lead.jobTitle, lead.company, lead.location, lead.scoreReasons]
|
||||
.some((field) => field?.toLowerCase().includes(needle));
|
||||
@@ -110,6 +146,19 @@ const visibleLeads = computed(() => {
|
||||
return shown;
|
||||
});
|
||||
|
||||
const selectedVisible = computed(() => visibleLeads.value.filter((lead) => selected.value.has(lead.id)));
|
||||
const allVisibleSelected = computed(() => visibleLeads.value.length > 0 && selectedVisible.value.length === visibleLeads.value.length);
|
||||
function toggleSelected(id) { const next = new Set(selected.value); next.has(id) ? next.delete(id) : next.add(id); selected.value = next; }
|
||||
function toggleAllVisible() { selected.value = allVisibleSelected.value ? new Set() : new Set(visibleLeads.value.map((lead) => lead.id)); }
|
||||
function clearSelection() { selected.value = new Set(); }
|
||||
async function bulkAct(action) {
|
||||
if (!selectedVisible.value.length) return;
|
||||
bulkBusy.value = true;
|
||||
try { await store[action](selectedVisible.value.map((lead) => lead.id)); clearSelection(); error.value = ""; }
|
||||
catch (err) { fail(err); }
|
||||
finally { bulkBusy.value = false; }
|
||||
}
|
||||
|
||||
function scoreClass(lead) {
|
||||
if (lead.score == null) return "jl-score-none";
|
||||
if (lead.score >= 80) return "jl-score-high";
|
||||
@@ -165,10 +214,9 @@ async function toggleDescription(lead) {
|
||||
}
|
||||
}
|
||||
|
||||
async function toggleUnmatched() {
|
||||
showUnmatched.value = !showUnmatched.value;
|
||||
await fetchLeads();
|
||||
}
|
||||
watch(showUnmatched, (value, oldValue) => {
|
||||
if (value !== oldValue) fetchLeads();
|
||||
});
|
||||
|
||||
// Run and poll
|
||||
|
||||
@@ -341,16 +389,34 @@ onBeforeUnmount(stopPolling);
|
||||
<option value="score">Best score first</option>
|
||||
<option value="posted">Newest posting first</option>
|
||||
</select>
|
||||
<select v-model="sourceFilter" class="input jl-sort" aria-label="Filter source">
|
||||
<option value="">All sources</option>
|
||||
<option v-for="(label, kind) in SOURCE_LABELS" :key="kind" :value="kind">{{ label }}</option>
|
||||
</select>
|
||||
<input v-model="companyFilter" class="input jl-filter" placeholder="Company" aria-label="Filter company" />
|
||||
<input v-model="locationFilter" class="input jl-filter" placeholder="Location" aria-label="Filter location" />
|
||||
<input v-model="minFilter" class="input jl-score-filter" type="number" min="0" max="100" placeholder="Min score" aria-label="Minimum score" />
|
||||
<input v-model="maxFilter" class="input jl-score-filter" type="number" min="0" max="100" placeholder="Max score" aria-label="Maximum score" />
|
||||
<label v-if="tab === 'new'" class="check">
|
||||
<input v-model="showLowScores" type="checkbox" />
|
||||
Below {{ minScore }}<template v-if="hiddenLow"> ({{ hiddenLow }} hidden)</template>
|
||||
</label>
|
||||
<label v-if="tab === 'new'" class="check" title="Postings the keyword filter rejected. They are never scored.">
|
||||
<input :checked="showUnmatched" type="checkbox" @change="toggleUnmatched" />
|
||||
<input v-model="showUnmatched" type="checkbox" />
|
||||
Filtered out
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div v-if="visibleLeads.length" class="jl-bulkbar">
|
||||
<label class="check"><input type="checkbox" :checked="allVisibleSelected" @change="toggleAllVisible" /> Select visible</label>
|
||||
<span v-if="selectedVisible.length">{{ selectedVisible.length }} selected</span>
|
||||
<template v-if="selectedVisible.length">
|
||||
<button v-if="tab === 'new'" class="btn btn-sm" :disabled="bulkBusy" @click="bulkAct('bulkDismiss')">Dismiss selected</button>
|
||||
<button v-if="tab === 'dismissed'" class="btn btn-sm" :disabled="bulkBusy" @click="bulkAct('bulkRestore')">Restore selected</button>
|
||||
<button v-if="tab === 'new'" class="btn btn-primary btn-sm" :disabled="bulkBusy" @click="bulkAct('bulkPromote')">Track selected</button>
|
||||
</template>
|
||||
</div>
|
||||
|
||||
<div class="jl-list">
|
||||
<article
|
||||
v-for="lead in visibleLeads"
|
||||
@@ -364,6 +430,7 @@ onBeforeUnmount(stopPolling);
|
||||
:style="{ '--arc': scoreArc(lead) }"
|
||||
:title="scoreTitle(lead)"
|
||||
>
|
||||
<input class="jl-select" type="checkbox" :checked="selected.has(lead.id)" :aria-label="`Select ${lead.jobTitle}`" @change="toggleSelected(lead.id)" />
|
||||
<span>{{ lead.score ?? "–" }}</span>
|
||||
</div>
|
||||
<div class="jl-lead-body">
|
||||
@@ -498,6 +565,30 @@ onBeforeUnmount(stopPolling);
|
||||
margin-bottom: 1rem;
|
||||
}
|
||||
|
||||
.jl-filter {
|
||||
flex: 0 1 10rem;
|
||||
width: auto;
|
||||
}
|
||||
.jl-score-filter {
|
||||
flex: 0 1 7rem;
|
||||
width: auto;
|
||||
}
|
||||
|
||||
.jl-bulkbar {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.75rem;
|
||||
flex-wrap: wrap;
|
||||
min-height: 2.5rem;
|
||||
margin-bottom: 0.75rem;
|
||||
padding: 0.5rem 0.75rem;
|
||||
border: 1px solid var(--border);
|
||||
border-radius: 0.4rem;
|
||||
background: var(--surface-2);
|
||||
color: var(--text-2);
|
||||
font-size: 0.875rem;
|
||||
}
|
||||
|
||||
.jl-sort {
|
||||
flex: 0 0 auto;
|
||||
width: auto;
|
||||
@@ -551,6 +642,15 @@ onBeforeUnmount(stopPolling);
|
||||
font-weight: 700;
|
||||
font-variant-numeric: tabular-nums;
|
||||
}
|
||||
.jl-select {
|
||||
position: absolute;
|
||||
top: 0.35rem;
|
||||
left: 0.35rem;
|
||||
z-index: 1;
|
||||
}
|
||||
.jl-score {
|
||||
position: relative;
|
||||
}
|
||||
.jl-score-high {
|
||||
--tone: var(--ok);
|
||||
}
|
||||
@@ -625,6 +725,17 @@ onBeforeUnmount(stopPolling);
|
||||
}
|
||||
|
||||
@media (max-width: 720px) {
|
||||
.jl-toolbar {
|
||||
align-items: stretch;
|
||||
gap: 0.65rem;
|
||||
}
|
||||
.jl-toolbar .search,
|
||||
.jl-sort,
|
||||
.jl-filter,
|
||||
.jl-score-filter {
|
||||
flex: 1 1 calc(50% - 0.65rem);
|
||||
}
|
||||
|
||||
.jl-lead {
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user