2026-04-10 01:25:49 +02:00
|
|
|
/**
|
|
|
|
|
* Company Jobs Page - Wired to real backend APIs
|
|
|
|
|
* Endpoints:
|
|
|
|
|
* GET /api/companies/jobs - List company's jobs
|
|
|
|
|
* POST /api/companies/jobs - Create new job
|
|
|
|
|
* PATCH /api/companies/jobs/:id - Update job
|
|
|
|
|
* DELETE /api/companies/jobs/:id - Delete job
|
|
|
|
|
*/
|
2026-04-26 23:58:43 +02:00
|
|
|
import { For, Show, createMemo, createSignal, onMount } from "solid-js";
|
2026-04-10 01:25:49 +02:00
|
|
|
import {
|
|
|
|
|
BTN_GHOST,
|
|
|
|
|
BTN_PRIMARY,
|
|
|
|
|
CARD,
|
|
|
|
|
INPUT,
|
|
|
|
|
LABEL,
|
|
|
|
|
} from "~/components/DashboardShell";
|
2026-04-08 22:40:43 +02:00
|
|
|
|
2026-04-10 01:25:49 +02:00
|
|
|
const API = "/api/gateway";
|
2026-04-08 22:40:43 +02:00
|
|
|
|
|
|
|
|
interface JobItem {
|
|
|
|
|
id: string;
|
|
|
|
|
title: string;
|
|
|
|
|
description: string;
|
|
|
|
|
location: string;
|
|
|
|
|
job_type: string;
|
|
|
|
|
status: string;
|
|
|
|
|
category?: string | null;
|
|
|
|
|
salary_min?: number | null;
|
|
|
|
|
salary_max?: number | null;
|
|
|
|
|
experience_years?: number | null;
|
|
|
|
|
skills?: string[] | null;
|
|
|
|
|
created_at?: string;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
interface JobFormState {
|
|
|
|
|
title: string;
|
|
|
|
|
category: string;
|
|
|
|
|
description: string;
|
|
|
|
|
location: string;
|
|
|
|
|
job_type: string;
|
|
|
|
|
salary_min: string;
|
|
|
|
|
salary_max: string;
|
|
|
|
|
experience_years: string;
|
|
|
|
|
skills: string;
|
|
|
|
|
}
|
|
|
|
|
|
2026-04-26 23:58:43 +02:00
|
|
|
type SortKey = "newest" | "salary_desc" | "salary_asc" | "title_asc";
|
|
|
|
|
|
2026-04-08 22:40:43 +02:00
|
|
|
const EMPTY_FORM: JobFormState = {
|
2026-04-10 01:25:49 +02:00
|
|
|
title: "",
|
|
|
|
|
category: "",
|
|
|
|
|
description: "",
|
|
|
|
|
location: "",
|
|
|
|
|
job_type: "FULL_TIME",
|
|
|
|
|
salary_min: "",
|
|
|
|
|
salary_max: "",
|
|
|
|
|
experience_years: "",
|
|
|
|
|
skills: "",
|
2026-04-08 22:40:43 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
async function apiFetch(path: string, opts?: RequestInit) {
|
2026-04-22 01:32:43 +02:00
|
|
|
const token =
|
|
|
|
|
typeof window !== "undefined"
|
|
|
|
|
? window.sessionStorage.getItem("nxtgauge_access_token") || ""
|
|
|
|
|
: "";
|
2026-04-08 22:40:43 +02:00
|
|
|
return fetch(`${API}${path}`, {
|
|
|
|
|
...opts,
|
2026-04-10 01:25:49 +02:00
|
|
|
credentials: "include",
|
2026-04-22 01:32:43 +02:00
|
|
|
headers: {
|
|
|
|
|
"Content-Type": "application/json",
|
|
|
|
|
...(token ? { Authorization: `Bearer ${token}` } : {}),
|
|
|
|
|
...(opts?.headers ?? {}),
|
|
|
|
|
},
|
2026-04-08 22:40:43 +02:00
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export default function CompanyJobsPage() {
|
|
|
|
|
const [jobs, setJobs] = createSignal<JobItem[]>([]);
|
|
|
|
|
const [loading, setLoading] = createSignal(true);
|
|
|
|
|
const [showForm, setShowForm] = createSignal(false);
|
|
|
|
|
const [form, setForm] = createSignal<JobFormState>({ ...EMPTY_FORM });
|
|
|
|
|
const [saving, setSaving] = createSignal(false);
|
2026-04-10 01:25:49 +02:00
|
|
|
const [error, setError] = createSignal("");
|
|
|
|
|
const [actionMsg, setActionMsg] = createSignal("");
|
2026-04-08 22:40:43 +02:00
|
|
|
const [busyJobId, setBusyJobId] = createSignal<string | null>(null);
|
2026-04-26 23:58:43 +02:00
|
|
|
const [search, setSearch] = createSignal("");
|
|
|
|
|
const [sortBy, setSortBy] = createSignal<SortKey>("newest");
|
|
|
|
|
const [activeTag, setActiveTag] = createSignal("");
|
|
|
|
|
|
|
|
|
|
const rowTags = (row: JobItem) => {
|
|
|
|
|
const tags = new Set<string>();
|
|
|
|
|
if (row.category) tags.add(String(row.category));
|
|
|
|
|
if (Array.isArray(row.skills)) {
|
|
|
|
|
for (const skill of row.skills) {
|
|
|
|
|
const val = String(skill || "").trim();
|
|
|
|
|
if (val) tags.add(val);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return Array.from(tags);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const availableTags = createMemo(() => {
|
|
|
|
|
const tags = new Set<string>();
|
|
|
|
|
for (const row of jobs()) {
|
|
|
|
|
for (const tag of rowTags(row)) tags.add(tag);
|
|
|
|
|
}
|
|
|
|
|
return Array.from(tags).sort((a, b) => a.localeCompare(b));
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
const filteredSortedJobs = createMemo(() => {
|
|
|
|
|
const q = search().trim().toLowerCase();
|
|
|
|
|
const tag = activeTag().trim().toLowerCase();
|
|
|
|
|
const next = jobs().filter((row) => {
|
|
|
|
|
const tags = rowTags(row);
|
|
|
|
|
const matchesTag = !tag || tags.some((t) => t.toLowerCase() === tag);
|
|
|
|
|
if (!matchesTag) return false;
|
|
|
|
|
if (!q) return true;
|
|
|
|
|
return (
|
|
|
|
|
String(row.title || "").toLowerCase().includes(q) ||
|
|
|
|
|
String(row.location || "").toLowerCase().includes(q) ||
|
|
|
|
|
String(row.description || "").toLowerCase().includes(q) ||
|
|
|
|
|
String(row.job_type || "").toLowerCase().includes(q) ||
|
|
|
|
|
tags.some((t) => t.toLowerCase().includes(q))
|
|
|
|
|
);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
next.sort((a, b) => {
|
|
|
|
|
if (sortBy() === "salary_desc") return Number(b.salary_max || b.salary_min || 0) - Number(a.salary_max || a.salary_min || 0);
|
|
|
|
|
if (sortBy() === "salary_asc") return Number(a.salary_min || a.salary_max || 0) - Number(b.salary_min || b.salary_max || 0);
|
|
|
|
|
if (sortBy() === "title_asc") return String(a.title || "").localeCompare(String(b.title || ""));
|
|
|
|
|
return new Date(String(b.created_at || 0)).getTime() - new Date(String(a.created_at || 0)).getTime();
|
|
|
|
|
});
|
|
|
|
|
return next;
|
|
|
|
|
});
|
2026-04-08 22:40:43 +02:00
|
|
|
|
|
|
|
|
const loadJobs = async () => {
|
|
|
|
|
setLoading(true);
|
|
|
|
|
try {
|
2026-04-10 01:25:49 +02:00
|
|
|
const res = await apiFetch("/api/companies/jobs?page=1&limit=50");
|
2026-04-08 22:40:43 +02:00
|
|
|
if (!res.ok) {
|
|
|
|
|
setJobs([]);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
const payload = await res.json().catch(() => ({}));
|
|
|
|
|
setJobs(Array.isArray(payload?.data) ? payload.data : []);
|
|
|
|
|
} finally {
|
|
|
|
|
setLoading(false);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
onMount(loadJobs);
|
|
|
|
|
|
|
|
|
|
const setField = (key: keyof JobFormState, val: string) =>
|
|
|
|
|
setForm((prev) => ({ ...prev, [key]: val }));
|
|
|
|
|
|
|
|
|
|
const openCreate = () => {
|
|
|
|
|
setForm({ ...EMPTY_FORM });
|
2026-04-10 01:25:49 +02:00
|
|
|
setError("");
|
|
|
|
|
setActionMsg("");
|
2026-04-08 22:40:43 +02:00
|
|
|
setShowForm(true);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const closeCreate = () => {
|
|
|
|
|
setShowForm(false);
|
|
|
|
|
setForm({ ...EMPTY_FORM });
|
2026-04-10 01:25:49 +02:00
|
|
|
setError("");
|
2026-04-08 22:40:43 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const handleCreate = async () => {
|
|
|
|
|
if (!form().title.trim() || !form().description.trim() || !form().location.trim()) {
|
2026-04-10 01:25:49 +02:00
|
|
|
setError("Title, description, and location are required.");
|
2026-04-08 22:40:43 +02:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
setSaving(true);
|
2026-04-10 01:25:49 +02:00
|
|
|
setError("");
|
|
|
|
|
setActionMsg("");
|
2026-04-08 22:40:43 +02:00
|
|
|
|
|
|
|
|
const payload = {
|
|
|
|
|
title: form().title.trim(),
|
|
|
|
|
category: form().category.trim() || undefined,
|
|
|
|
|
description: form().description.trim(),
|
|
|
|
|
location: form().location.trim(),
|
|
|
|
|
job_type: form().job_type,
|
|
|
|
|
salary_min: form().salary_min ? Number(form().salary_min) : undefined,
|
|
|
|
|
salary_max: form().salary_max ? Number(form().salary_max) : undefined,
|
|
|
|
|
experience_years: form().experience_years ? Number(form().experience_years) : undefined,
|
2026-04-10 01:25:49 +02:00
|
|
|
skills: form()
|
|
|
|
|
.skills.split(",")
|
2026-04-08 22:40:43 +02:00
|
|
|
.map((s) => s.trim())
|
|
|
|
|
.filter(Boolean),
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
try {
|
2026-04-10 01:25:49 +02:00
|
|
|
const res = await apiFetch("/api/companies/jobs", {
|
|
|
|
|
method: "POST",
|
2026-04-08 22:40:43 +02:00
|
|
|
body: JSON.stringify(payload),
|
|
|
|
|
});
|
|
|
|
|
const data = await res.json().catch(() => ({}));
|
|
|
|
|
if (!res.ok) {
|
2026-04-10 01:25:49 +02:00
|
|
|
setError(data.error ?? data.message ?? "Failed to create job.");
|
2026-04-08 22:40:43 +02:00
|
|
|
return;
|
|
|
|
|
}
|
2026-04-10 01:25:49 +02:00
|
|
|
setActionMsg("Job created as draft.");
|
2026-04-08 22:40:43 +02:00
|
|
|
closeCreate();
|
|
|
|
|
await loadJobs();
|
|
|
|
|
} catch {
|
2026-04-10 01:25:49 +02:00
|
|
|
setError("Network error. Please try again.");
|
2026-04-08 22:40:43 +02:00
|
|
|
} finally {
|
|
|
|
|
setSaving(false);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const submitJob = async (jobId: string) => {
|
|
|
|
|
setBusyJobId(jobId);
|
2026-04-10 01:25:49 +02:00
|
|
|
setActionMsg("");
|
2026-04-08 22:40:43 +02:00
|
|
|
try {
|
2026-04-10 01:25:49 +02:00
|
|
|
const res = await apiFetch(`/api/companies/jobs/${jobId}/submit`, { method: "POST" });
|
2026-04-08 22:40:43 +02:00
|
|
|
if (res.ok) {
|
2026-04-10 01:25:49 +02:00
|
|
|
setActionMsg("Job submitted for verification.");
|
2026-04-08 22:40:43 +02:00
|
|
|
await loadJobs();
|
|
|
|
|
} else {
|
|
|
|
|
const data = await res.json().catch(() => ({}));
|
2026-04-10 01:25:49 +02:00
|
|
|
setActionMsg(data.error ?? data.message ?? "Unable to submit this job.");
|
2026-04-08 22:40:43 +02:00
|
|
|
}
|
|
|
|
|
} finally {
|
|
|
|
|
setBusyJobId(null);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const closeJob = async (jobId: string) => {
|
|
|
|
|
setBusyJobId(jobId);
|
2026-04-10 01:25:49 +02:00
|
|
|
setActionMsg("");
|
2026-04-08 22:40:43 +02:00
|
|
|
try {
|
2026-04-10 01:25:49 +02:00
|
|
|
const res = await apiFetch(`/api/companies/jobs/${jobId}/close`, { method: "POST" });
|
2026-04-08 22:40:43 +02:00
|
|
|
if (res.ok) {
|
2026-04-10 01:25:49 +02:00
|
|
|
setActionMsg("Job closed.");
|
2026-04-08 22:40:43 +02:00
|
|
|
await loadJobs();
|
|
|
|
|
} else {
|
|
|
|
|
const data = await res.json().catch(() => ({}));
|
2026-04-10 01:25:49 +02:00
|
|
|
setActionMsg(data.error ?? data.message ?? "Unable to close this job.");
|
2026-04-08 22:40:43 +02:00
|
|
|
}
|
|
|
|
|
} finally {
|
|
|
|
|
setBusyJobId(null);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const statusColor = (status: string) => {
|
|
|
|
|
switch (status) {
|
2026-04-10 01:25:49 +02:00
|
|
|
case "DRAFT":
|
|
|
|
|
return "#6B7280";
|
|
|
|
|
case "PENDING_APPROVAL":
|
|
|
|
|
return "#F59E0B";
|
|
|
|
|
case "LIVE":
|
|
|
|
|
return "#10B981";
|
|
|
|
|
case "REJECTED":
|
|
|
|
|
return "#EF4444";
|
|
|
|
|
case "CLOSED":
|
|
|
|
|
return "#374151";
|
|
|
|
|
default:
|
|
|
|
|
return "#6B7280";
|
2026-04-08 22:40:43 +02:00
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
return (
|
2026-04-10 01:25:49 +02:00
|
|
|
<div style={{ "max-width": "920px" }}>
|
|
|
|
|
<div
|
|
|
|
|
style={{
|
|
|
|
|
display: "flex",
|
|
|
|
|
"justify-content": "space-between",
|
|
|
|
|
"align-items": "center",
|
|
|
|
|
"margin-bottom": "16px",
|
|
|
|
|
gap: "12px",
|
|
|
|
|
"flex-wrap": "wrap",
|
|
|
|
|
}}
|
|
|
|
|
>
|
2026-04-08 22:40:43 +02:00
|
|
|
<div>
|
2026-04-22 01:26:36 +02:00
|
|
|
<p style={{ margin: "0", "font-size": "18px", "font-weight": "800", color: "#111827" }}>
|
2026-04-10 01:25:49 +02:00
|
|
|
Jobs
|
|
|
|
|
</p>
|
|
|
|
|
<p style={{ margin: "4px 0 0", "font-size": "13px", color: "#6B7280" }}>
|
2026-04-08 22:40:43 +02:00
|
|
|
Create and manage your job postings.
|
|
|
|
|
</p>
|
|
|
|
|
</div>
|
2026-04-26 23:58:43 +02:00
|
|
|
<button type="button" onClick={openCreate} style={BTN_PRIMARY}>
|
2026-04-08 22:40:43 +02:00
|
|
|
+ Create Job
|
|
|
|
|
</button>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<Show when={actionMsg()}>
|
2026-04-10 01:25:49 +02:00
|
|
|
<div
|
|
|
|
|
style={{
|
|
|
|
|
...CARD,
|
|
|
|
|
"margin-bottom": "14px",
|
|
|
|
|
padding: "12px 14px",
|
|
|
|
|
"font-size": "13px",
|
|
|
|
|
color: "#374151",
|
|
|
|
|
}}
|
|
|
|
|
>
|
2026-04-08 22:40:43 +02:00
|
|
|
{actionMsg()}
|
|
|
|
|
</div>
|
|
|
|
|
</Show>
|
|
|
|
|
|
|
|
|
|
<Show when={showForm()}>
|
2026-04-10 01:25:49 +02:00
|
|
|
<div style={{ ...CARD, "margin-bottom": "16px", border: "1px solid #FF5E13" }}>
|
|
|
|
|
<p
|
|
|
|
|
style={{
|
|
|
|
|
margin: "0 0 14px",
|
|
|
|
|
"font-size": "16px",
|
|
|
|
|
"font-weight": "800",
|
|
|
|
|
color: "#111827",
|
|
|
|
|
}}
|
|
|
|
|
>
|
2026-04-08 22:40:43 +02:00
|
|
|
New Job
|
|
|
|
|
</p>
|
2026-04-10 01:25:49 +02:00
|
|
|
<div style={{ display: "grid", "grid-template-columns": "1fr 1fr", gap: "12px" }}>
|
|
|
|
|
<div style={{ "grid-column": "span 2" }}>
|
2026-04-08 22:40:43 +02:00
|
|
|
<label style={LABEL}>Job Title</label>
|
2026-04-10 01:25:49 +02:00
|
|
|
<input
|
|
|
|
|
value={form().title}
|
|
|
|
|
onInput={(e) => setField("title", e.currentTarget.value)}
|
|
|
|
|
style={INPUT}
|
|
|
|
|
placeholder="Frontend Developer"
|
|
|
|
|
/>
|
2026-04-08 22:40:43 +02:00
|
|
|
</div>
|
|
|
|
|
<div>
|
|
|
|
|
<label style={LABEL}>Category</label>
|
2026-04-10 01:25:49 +02:00
|
|
|
<input
|
|
|
|
|
value={form().category}
|
|
|
|
|
onInput={(e) => setField("category", e.currentTarget.value)}
|
|
|
|
|
style={INPUT}
|
|
|
|
|
placeholder="Engineering"
|
|
|
|
|
/>
|
2026-04-08 22:40:43 +02:00
|
|
|
</div>
|
|
|
|
|
<div>
|
|
|
|
|
<label style={LABEL}>Job Type</label>
|
2026-04-10 01:25:49 +02:00
|
|
|
<select
|
|
|
|
|
value={form().job_type}
|
|
|
|
|
onChange={(e) => setField("job_type", e.currentTarget.value)}
|
|
|
|
|
style={INPUT}
|
|
|
|
|
>
|
2026-04-08 22:40:43 +02:00
|
|
|
<option value="FULL_TIME">Full Time</option>
|
|
|
|
|
<option value="PART_TIME">Part Time</option>
|
|
|
|
|
<option value="CONTRACT">Contract</option>
|
|
|
|
|
</select>
|
|
|
|
|
</div>
|
2026-04-10 01:25:49 +02:00
|
|
|
<div style={{ "grid-column": "span 2" }}>
|
2026-04-08 22:40:43 +02:00
|
|
|
<label style={LABEL}>Location</label>
|
2026-04-10 01:25:49 +02:00
|
|
|
<input
|
|
|
|
|
value={form().location}
|
|
|
|
|
onInput={(e) => setField("location", e.currentTarget.value)}
|
|
|
|
|
style={INPUT}
|
|
|
|
|
placeholder="Bengaluru (Hybrid)"
|
|
|
|
|
/>
|
2026-04-08 22:40:43 +02:00
|
|
|
</div>
|
2026-04-10 01:25:49 +02:00
|
|
|
<div style={{ "grid-column": "span 2" }}>
|
2026-04-08 22:40:43 +02:00
|
|
|
<label style={LABEL}>Description</label>
|
|
|
|
|
<textarea
|
|
|
|
|
rows={4}
|
|
|
|
|
value={form().description}
|
2026-04-10 01:25:49 +02:00
|
|
|
onInput={(e) => setField("description", e.currentTarget.value)}
|
|
|
|
|
style={{ ...INPUT, height: "auto", padding: "10px 12px", resize: "vertical" }}
|
2026-04-08 22:40:43 +02:00
|
|
|
placeholder="Role overview, responsibilities, and requirements"
|
|
|
|
|
/>
|
|
|
|
|
</div>
|
|
|
|
|
<div>
|
|
|
|
|
<label style={LABEL}>Min Salary</label>
|
2026-04-10 01:25:49 +02:00
|
|
|
<input
|
|
|
|
|
type="number"
|
|
|
|
|
value={form().salary_min}
|
|
|
|
|
onInput={(e) => setField("salary_min", e.currentTarget.value)}
|
|
|
|
|
style={INPUT}
|
|
|
|
|
/>
|
2026-04-08 22:40:43 +02:00
|
|
|
</div>
|
|
|
|
|
<div>
|
|
|
|
|
<label style={LABEL}>Max Salary</label>
|
2026-04-10 01:25:49 +02:00
|
|
|
<input
|
|
|
|
|
type="number"
|
|
|
|
|
value={form().salary_max}
|
|
|
|
|
onInput={(e) => setField("salary_max", e.currentTarget.value)}
|
|
|
|
|
style={INPUT}
|
|
|
|
|
/>
|
2026-04-08 22:40:43 +02:00
|
|
|
</div>
|
|
|
|
|
<div>
|
|
|
|
|
<label style={LABEL}>Experience (years)</label>
|
2026-04-10 01:25:49 +02:00
|
|
|
<input
|
|
|
|
|
type="number"
|
|
|
|
|
value={form().experience_years}
|
|
|
|
|
onInput={(e) => setField("experience_years", e.currentTarget.value)}
|
|
|
|
|
style={INPUT}
|
|
|
|
|
/>
|
2026-04-08 22:40:43 +02:00
|
|
|
</div>
|
|
|
|
|
<div>
|
|
|
|
|
<label style={LABEL}>Skills (comma separated)</label>
|
2026-04-10 01:25:49 +02:00
|
|
|
<input
|
|
|
|
|
value={form().skills}
|
|
|
|
|
onInput={(e) => setField("skills", e.currentTarget.value)}
|
|
|
|
|
style={INPUT}
|
|
|
|
|
placeholder="Rust, SQL, Docker"
|
|
|
|
|
/>
|
2026-04-08 22:40:43 +02:00
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
<Show when={error()}>
|
2026-04-10 01:25:49 +02:00
|
|
|
<p
|
|
|
|
|
style={{
|
|
|
|
|
margin: "12px 0 0",
|
|
|
|
|
"font-size": "13px",
|
|
|
|
|
color: "#EF4444",
|
|
|
|
|
"font-weight": "600",
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
{error()}
|
|
|
|
|
</p>
|
2026-04-08 22:40:43 +02:00
|
|
|
</Show>
|
2026-04-10 01:25:49 +02:00
|
|
|
<div style={{ display: "flex", gap: "10px", "margin-top": "14px" }}>
|
|
|
|
|
<button
|
|
|
|
|
type="button"
|
|
|
|
|
onClick={handleCreate}
|
|
|
|
|
disabled={saving()}
|
|
|
|
|
style={{ ...BTN_PRIMARY, opacity: saving() ? "0.7" : "1" }}
|
|
|
|
|
>
|
|
|
|
|
{saving() ? "Creating…" : "Create Draft"}
|
|
|
|
|
</button>
|
|
|
|
|
<button type="button" onClick={closeCreate} style={BTN_GHOST}>
|
|
|
|
|
Cancel
|
2026-04-08 22:40:43 +02:00
|
|
|
</button>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</Show>
|
|
|
|
|
|
2026-04-26 23:58:43 +02:00
|
|
|
<div style={CARD}>
|
|
|
|
|
<div
|
|
|
|
|
style={{
|
|
|
|
|
display: "flex",
|
|
|
|
|
"justify-content": "space-between",
|
|
|
|
|
"align-items": "center",
|
|
|
|
|
"margin-bottom": "10px",
|
|
|
|
|
gap: "10px",
|
|
|
|
|
"flex-wrap": "wrap",
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
<p style={{ margin: "0", "font-size": "16px", "font-weight": "700", color: "#111827" }}>
|
|
|
|
|
My Job Postings
|
|
|
|
|
</p>
|
|
|
|
|
<button type="button" onClick={loadJobs} style={BTN_GHOST}>
|
|
|
|
|
Refresh
|
|
|
|
|
</button>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<div style={{ display: "grid", gap: "10px" }}>
|
|
|
|
|
<div style={{ display: "grid", "grid-template-columns": "1fr 180px", gap: "10px" }}>
|
|
|
|
|
<input
|
|
|
|
|
value={search()}
|
|
|
|
|
onInput={(e) => setSearch(e.currentTarget.value)}
|
|
|
|
|
style={INPUT}
|
|
|
|
|
placeholder="Search by title, location, type, description, tags"
|
|
|
|
|
/>
|
|
|
|
|
<select value={sortBy()} onChange={(e) => setSortBy(e.currentTarget.value as SortKey)} style={INPUT}>
|
|
|
|
|
<option value="newest">Sort: Newest</option>
|
|
|
|
|
<option value="salary_desc">Salary High to Low</option>
|
|
|
|
|
<option value="salary_asc">Salary Low to High</option>
|
|
|
|
|
<option value="title_asc">Title A-Z</option>
|
|
|
|
|
</select>
|
|
|
|
|
</div>
|
|
|
|
|
<Show when={availableTags().length > 0}>
|
|
|
|
|
<div style={{ display: "flex", gap: "6px", "flex-wrap": "wrap" }}>
|
|
|
|
|
<button
|
|
|
|
|
type="button"
|
|
|
|
|
onClick={() => setActiveTag("")}
|
|
|
|
|
style={{ ...BTN_GHOST, height: "28px", padding: "0 10px", "font-size": "11px", ...(activeTag() ? {} : { border: "1px solid #0D0D2A", color: "#0D0D2A" }) }}
|
|
|
|
|
>
|
|
|
|
|
All Tags
|
|
|
|
|
</button>
|
|
|
|
|
<For each={availableTags()}>
|
|
|
|
|
{(tag) => (
|
|
|
|
|
<button
|
|
|
|
|
type="button"
|
|
|
|
|
onClick={() => setActiveTag(tag)}
|
|
|
|
|
style={{ ...BTN_GHOST, height: "28px", padding: "0 10px", "font-size": "11px", ...(activeTag() === tag ? { border: "1px solid #0D0D2A", color: "#0D0D2A" } : {}) }}
|
|
|
|
|
>
|
|
|
|
|
{tag}
|
|
|
|
|
</button>
|
|
|
|
|
)}
|
|
|
|
|
</For>
|
|
|
|
|
</div>
|
|
|
|
|
</Show>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
|
2026-04-08 22:40:43 +02:00
|
|
|
<Show when={loading()}>
|
2026-04-10 01:25:49 +02:00
|
|
|
<div style={{ ...CARD, "text-align": "center", color: "#9CA3AF" }}>Loading jobs…</div>
|
2026-04-08 22:40:43 +02:00
|
|
|
</Show>
|
|
|
|
|
|
2026-04-26 23:58:43 +02:00
|
|
|
<Show when={!loading() && filteredSortedJobs().length === 0}>
|
2026-04-10 01:25:49 +02:00
|
|
|
<div style={{ ...CARD, "text-align": "center", padding: "34px 24px" }}>
|
|
|
|
|
<p
|
|
|
|
|
style={{
|
|
|
|
|
margin: "0 0 6px",
|
|
|
|
|
"font-size": "16px",
|
|
|
|
|
"font-weight": "700",
|
|
|
|
|
color: "#111827",
|
|
|
|
|
}}
|
|
|
|
|
>
|
2026-04-26 23:58:43 +02:00
|
|
|
No jobs found
|
2026-04-10 01:25:49 +02:00
|
|
|
</p>
|
|
|
|
|
<p style={{ margin: "0", "font-size": "13px", color: "#6B7280" }}>
|
2026-04-26 23:58:43 +02:00
|
|
|
Try a different search or create your first draft job.
|
2026-04-10 01:25:49 +02:00
|
|
|
</p>
|
2026-04-08 22:40:43 +02:00
|
|
|
</div>
|
|
|
|
|
</Show>
|
|
|
|
|
|
2026-04-26 23:58:43 +02:00
|
|
|
<Show when={!loading() && filteredSortedJobs().length > 0}>
|
2026-04-10 01:25:49 +02:00
|
|
|
<div style={{ display: "grid", gap: "10px" }}>
|
2026-04-26 23:58:43 +02:00
|
|
|
<For each={filteredSortedJobs()}>
|
2026-04-08 22:40:43 +02:00
|
|
|
{(job) => (
|
2026-04-10 01:25:49 +02:00
|
|
|
<div style={{ ...CARD, padding: "16px" }}>
|
|
|
|
|
<div
|
|
|
|
|
style={{
|
|
|
|
|
display: "flex",
|
|
|
|
|
"justify-content": "space-between",
|
|
|
|
|
gap: "10px",
|
|
|
|
|
"align-items": "flex-start",
|
|
|
|
|
"flex-wrap": "wrap",
|
|
|
|
|
}}
|
|
|
|
|
>
|
2026-04-08 22:40:43 +02:00
|
|
|
<div>
|
2026-04-10 01:25:49 +02:00
|
|
|
<p
|
|
|
|
|
style={{
|
|
|
|
|
margin: "0",
|
|
|
|
|
"font-size": "15px",
|
|
|
|
|
"font-weight": "800",
|
|
|
|
|
color: "#111827",
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
{job.title}
|
|
|
|
|
</p>
|
|
|
|
|
<p style={{ margin: "3px 0 0", "font-size": "12px", color: "#6B7280" }}>
|
|
|
|
|
{[job.location, job.job_type, job.category || "General"].join(" • ")}
|
2026-04-08 22:40:43 +02:00
|
|
|
</p>
|
|
|
|
|
</div>
|
2026-04-10 01:25:49 +02:00
|
|
|
<span
|
|
|
|
|
style={{
|
|
|
|
|
display: "inline-flex",
|
|
|
|
|
"align-items": "center",
|
|
|
|
|
padding: "0 10px",
|
|
|
|
|
height: "24px",
|
|
|
|
|
"border-radius": "999px",
|
|
|
|
|
background: `${statusColor(job.status)}20`,
|
|
|
|
|
color: statusColor(job.status),
|
|
|
|
|
"font-size": "11px",
|
|
|
|
|
"font-weight": "700",
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
{job.status.replace(/_/g, " ")}
|
2026-04-08 22:40:43 +02:00
|
|
|
</span>
|
|
|
|
|
</div>
|
2026-04-10 01:25:49 +02:00
|
|
|
<p
|
|
|
|
|
style={{
|
|
|
|
|
margin: "8px 0 0",
|
|
|
|
|
"font-size": "13px",
|
|
|
|
|
color: "#374151",
|
|
|
|
|
"line-height": "1.5",
|
|
|
|
|
}}
|
|
|
|
|
>
|
2026-04-08 22:40:43 +02:00
|
|
|
{job.description}
|
|
|
|
|
</p>
|
2026-04-26 23:58:43 +02:00
|
|
|
<Show when={rowTags(job).length > 0}>
|
2026-04-10 01:25:49 +02:00
|
|
|
<div
|
|
|
|
|
style={{
|
|
|
|
|
display: "flex",
|
|
|
|
|
gap: "6px",
|
|
|
|
|
"flex-wrap": "wrap",
|
|
|
|
|
"margin-top": "8px",
|
|
|
|
|
}}
|
|
|
|
|
>
|
2026-04-26 23:58:43 +02:00
|
|
|
<For each={rowTags(job).slice(0, 8)}>
|
|
|
|
|
{(tag) => (
|
2026-04-10 01:25:49 +02:00
|
|
|
<span
|
|
|
|
|
style={{
|
|
|
|
|
"font-size": "11px",
|
|
|
|
|
color: "#4B5563",
|
|
|
|
|
background: "#F3F4F6",
|
|
|
|
|
border: "1px solid #E5E7EB",
|
|
|
|
|
"border-radius": "6px",
|
|
|
|
|
padding: "2px 8px",
|
|
|
|
|
}}
|
|
|
|
|
>
|
2026-04-26 23:58:43 +02:00
|
|
|
{tag}
|
2026-04-08 22:40:43 +02:00
|
|
|
</span>
|
|
|
|
|
)}
|
|
|
|
|
</For>
|
|
|
|
|
</div>
|
|
|
|
|
</Show>
|
2026-04-10 01:25:49 +02:00
|
|
|
<div
|
|
|
|
|
style={{ display: "flex", gap: "8px", "margin-top": "12px", "flex-wrap": "wrap" }}
|
|
|
|
|
>
|
|
|
|
|
<Show when={job.status === "DRAFT"}>
|
2026-04-08 22:40:43 +02:00
|
|
|
<button
|
|
|
|
|
type="button"
|
|
|
|
|
onClick={() => submitJob(job.id)}
|
|
|
|
|
disabled={busyJobId() === job.id}
|
2026-04-10 01:25:49 +02:00
|
|
|
style={{
|
2026-04-26 23:58:43 +02:00
|
|
|
...BTN_PRIMARY,
|
2026-04-10 01:25:49 +02:00
|
|
|
height: "32px",
|
|
|
|
|
"font-size": "12px",
|
|
|
|
|
padding: "0 14px",
|
|
|
|
|
opacity: busyJobId() === job.id ? "0.65" : "1",
|
|
|
|
|
}}
|
2026-04-08 22:40:43 +02:00
|
|
|
>
|
|
|
|
|
Submit for Approval
|
|
|
|
|
</button>
|
|
|
|
|
</Show>
|
2026-04-10 01:25:49 +02:00
|
|
|
<Show when={job.status !== "CLOSED"}>
|
2026-04-08 22:40:43 +02:00
|
|
|
<button
|
|
|
|
|
type="button"
|
|
|
|
|
onClick={() => closeJob(job.id)}
|
|
|
|
|
disabled={busyJobId() === job.id}
|
2026-04-10 01:25:49 +02:00
|
|
|
style={{
|
|
|
|
|
...BTN_GHOST,
|
|
|
|
|
height: "32px",
|
|
|
|
|
"font-size": "12px",
|
|
|
|
|
padding: "0 14px",
|
|
|
|
|
opacity: busyJobId() === job.id ? "0.65" : "1",
|
|
|
|
|
}}
|
2026-04-08 22:40:43 +02:00
|
|
|
>
|
|
|
|
|
Close Job
|
|
|
|
|
</button>
|
|
|
|
|
</Show>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
)}
|
|
|
|
|
</For>
|
|
|
|
|
</div>
|
|
|
|
|
</Show>
|
|
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
}
|