createCrudStore captures the places store's pattern and now backs places, job applications and job references. JobApplications.vue no longer calls gql() itself and is split into the applications table, the references table and the add form, with the status vocabulary in jobStatus.js. api.js is a thin REST client that turns failures into an ApiError carrying the backend's message; the admin views and Listening.vue use it in place of raw axios and fetch. The router guard waited on the home query's loaded flag, which is never set when that query fails, so /admin and /cv/jobs could hang. It now awaits a standalone me query owned by the auth store, and homeData gains a settled flag for widgets that only need to know the fetch finished. The Vite proxy targets are configurable through VITE_PROXY_*, and build:js runs the Vite build without wasm-pack. Co-Authored-By: Claude Opus 5.5 <[email protected]>
40 lines
1.4 KiB
JavaScript
40 lines
1.4 KiB
JavaScript
/**
|
|
* Job applications for the tracker at /cv/jobs — CRUD built on
|
|
* createCrudStore(), plus the on-demand posting text.
|
|
*
|
|
* Admin-only on the server, and only that one page uses it, so nothing fetches
|
|
* it until the view mounts.
|
|
*/
|
|
|
|
import { createCrudStore } from "@/stores/createCrudStore";
|
|
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`;
|
|
|
|
export const useJobApplicationsStore = createCrudStore("jobApplications", {
|
|
type: "JobApplication",
|
|
list: "jobApplications",
|
|
itemsKey: "applications",
|
|
fields: APP_FIELDS,
|
|
insert: "prepend",
|
|
// deleteJobApplication returns Boolean!, and errors for an id that is gone.
|
|
deleteReturns: "boolean",
|
|
extend: () => ({
|
|
/**
|
|
* 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) {
|
|
const data = await gql(
|
|
`query JobDescription($id: ID!) { jobApplication(id: $id) { description } }`,
|
|
{ id },
|
|
);
|
|
return data.jobApplication?.description ?? "";
|
|
},
|
|
}),
|
|
});
|