Update src/app/post-job/page.tsx

This commit is contained in:
2026-03-08 22:37:16 +00:00
parent e800be26cd
commit 8b60177ad1

View File

@@ -3,15 +3,15 @@
import { ThemeProvider } from "@/providers/themeProvider/ThemeProvider";
import NavbarStyleCentered from "@/components/navbar/NavbarStyleCentered/NavbarStyleCentered";
import FooterBase from "@/components/sections/footer/FooterBase";
import { Briefcase, Mail } from "lucide-react";
import { useState } from "react";
import { Briefcase, Mail, CheckCircle, AlertCircle } from "lucide-react";
const navItems = [
{ name: "Search Jobs", id: "/search" },
{ name: "Search Jobs", id: "search" },
{ name: "Post a Job", id: "/post-job" },
{ name: "Admin", id: "admin-login" },
{ name: "Browse", id: "/browse" },
{ name: "Contact", id: "#contact" },
{ name: "Applications", id: "/applications" },
{ name: "Browse", id: "browse" },
{ name: "Contact", id: "contact" },
];
const footerColumns = [
@@ -19,7 +19,7 @@ const footerColumns = [
title: "Product", items: [
{ label: "Search Jobs", href: "/search" },
{ label: "Post a Job", href: "/post-job" },
{ label: "Browse by Province", href: "#provinces" },
{ label: "My Applications", href: "/applications" },
{ label: "For Employers", href: "#" },
],
},
@@ -41,111 +41,30 @@ const footerColumns = [
},
];
interface FormErrors {
jobTitle?: string;
company?: string;
location?: string;
salary?: string;
description?: string;
requirements?: string;
email?: string;
}
interface FormData {
jobTitle: string;
company: string;
location: string;
salary: string;
jobType: string;
description: string;
requirements: string;
email: string;
contactPhone?: string;
}
export default function PostJobPage() {
const [formData, setFormData] = useState<FormData>({
jobTitle: "", company: "", location: "", salary: "", jobType: "Full-time", description: "", requirements: "", email: "", contactPhone: ""});
const [formData, setFormData] = useState({
jobTitle: "", company: "", location: "", province: "", jobType: "Full-Time", salaryRange: "", description: "", requirements: "", contactEmail: "", benefits: ""});
const [errors, setErrors] = useState<FormErrors>({});
const [isSubmitting, setIsSubmitting] = useState(false);
const [submitStatus, setSubmitStatus] = useState<"idle" | "success" | "error">(
"idle"
);
const [submitted, setSubmitted] = useState(false);
const validateForm = (): boolean => {
const newErrors: FormErrors = {};
if (!formData.jobTitle.trim()) {
newErrors.jobTitle = "Job title is required";
}
if (!formData.company.trim()) {
newErrors.company = "Company name is required";
}
if (!formData.location.trim()) {
newErrors.location = "Location is required";
}
if (!formData.salary.trim()) {
newErrors.salary = "Salary range is required";
}
if (formData.description.trim().length < 20) {
newErrors.description = "Description must be at least 20 characters";
}
if (formData.requirements.trim().length < 10) {
newErrors.requirements = "Requirements must be at least 10 characters";
}
if (
!formData.email.trim() ||
!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(formData.email)
) {
newErrors.email = "Valid email is required";
}
setErrors(newErrors);
return Object.keys(newErrors).length === 0;
};
const handleSubmit = async (e: React.FormEvent) => {
e.preventDefault();
if (!validateForm()) {
setSubmitStatus("error");
return;
}
setIsSubmitting(true);
setSubmitStatus("idle");
try {
// Simulate API call
await new Promise((resolve) => setTimeout(resolve, 1500));
setSubmitStatus("success");
setFormData({
jobTitle: "", company: "", location: "", salary: "", jobType: "Full-time", description: "", requirements: "", email: "", contactPhone: ""});
setErrors({});
// Reset success message after 5 seconds
setTimeout(() => setSubmitStatus("idle"), 5000);
} catch (error) {
setSubmitStatus("error");
} finally {
setIsSubmitting(false);
}
};
const handleInputChange = (
const handleChange = (
e: React.ChangeEvent<
HTMLInputElement | HTMLTextAreaElement | HTMLSelectElement
>
) => {
const { name, value } = e.target;
setFormData((prev) => ({ ...prev, [name]: value }));
if (errors[name as keyof FormErrors]) {
setErrors((prev) => ({
...prev,
[name]: undefined,
}));
}
};
const handleSubmit = (e: React.FormEvent) => {
e.preventDefault();
console.log("Job Posted:", formData);
setSubmitted(true);
setTimeout(() => {
setFormData({
jobTitle: "", company: "", location: "", province: "", jobType: "Full-Time", salaryRange: "", description: "", requirements: "", contactEmail: "", benefits: ""});
setSubmitted(false);
}, 2000);
};
return (
@@ -170,270 +89,250 @@ export default function PostJobPage() {
/>
</div>
<main className="min-h-screen pt-24 pb-20">
<div className="min-h-screen bg-gradient-to-b from-slate-50 to-slate-100 pt-32 pb-20">
<div className="max-w-2xl mx-auto px-4">
{/* Header */}
<div className="mb-12 text-center">
<div className="flex items-center justify-center gap-2 mb-4">
<Briefcase className="w-8 h-8" />
<span className="text-sm font-semibold text-primary-cta uppercase tracking-wider">
Post a Job
<div className="mb-8">
<div className="flex items-center gap-3 mb-4">
<Briefcase className="w-6 h-6 text-blue-600" />
<span className="text-sm font-semibold text-blue-600 uppercase tracking-wide">
Post Your Job
</span>
</div>
<h1 className="text-4xl md:text-5xl font-bold mb-4">
Hire Top Talent in the Netherlands
<h1 className="text-4xl md:text-5xl font-bold text-slate-900 mb-3">
Create Your Job Listing
</h1>
<p className="text-lg text-foreground/75 max-w-xl mx-auto">
Post your job opening and reach qualified candidates across all Dutch
provinces
<p className="text-lg text-slate-600">
Fill in the details below to post your job opening and reach qualified candidates
across the Netherlands.
</p>
</div>
{/* Status Messages */}
{submitStatus === "success" && (
<div className="mb-8 p-4 rounded-lg bg-green-50 border border-green-200 flex items-start gap-3">
<CheckCircle className="w-5 h-5 text-green-600 flex-shrink-0 mt-0.5" />
<div>
<h3 className="font-semibold text-green-900">Job Posted Successfully!</h3>
<p className="text-sm text-green-800 mt-1">
Your job listing is now live and visible to job seekers across the
Netherlands.
</p>
</div>
{submitted && (
<div className="mb-6 p-4 bg-green-50 border border-green-200 rounded-lg">
<p className="text-green-800 font-semibold"> Job posted successfully!</p>
</div>
)}
{submitStatus === "error" && Object.keys(errors).length > 0 && (
<div className="mb-8 p-4 rounded-lg bg-red-50 border border-red-200 flex items-start gap-3">
<AlertCircle className="w-5 h-5 text-red-600 flex-shrink-0 mt-0.5" />
<div>
<h3 className="font-semibold text-red-900">Validation Errors</h3>
<p className="text-sm text-red-800 mt-1">
Please correct the errors below and try again.
</p>
</div>
</div>
)}
{/* Job Form */}
<form
onSubmit={handleSubmit}
className="space-y-6 bg-card p-8 rounded-2xl border border-background-accent/20 shadow-sm"
className="bg-white rounded-lg shadow-lg p-8 space-y-6"
>
{/* Job Title */}
<div>
<label htmlFor="jobTitle" className="block text-sm font-semibold mb-2">
Job Title <span className="text-red-500">*</span>
<label htmlFor="jobTitle" className="block text-sm font-semibold text-slate-900 mb-2">
Job Title *
</label>
<input
type="text"
id="jobTitle"
type="text"
value={formData.jobTitle}
onChange={handleInputChange}
name="jobTitle"
placeholder="e.g., Senior React Developer"
value={formData.jobTitle}
onChange={handleChange}
required
className="w-full px-4 py-2 rounded-lg bg-secondary-button text-foreground border border-background-accent/20 focus:outline-none focus:ring-2 focus:ring-primary-cta/50"
placeholder="e.g., Senior Software Developer"
className="w-full px-4 py-2 border border-slate-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-transparent"
/>
{errors.jobTitle && (
<p className="text-red-600 text-sm mt-1">{errors.jobTitle}</p>
)}
</div>
{/* Company Name */}
{/* Company */}
<div>
<label htmlFor="company" className="block text-sm font-semibold mb-2">
Company Name <span className="text-red-500">*</span>
<label htmlFor="company" className="block text-sm font-semibold text-slate-900 mb-2">
Company Name *
</label>
<input
id="company"
type="text"
value={formData.company}
onChange={handleInputChange}
id="company"
name="company"
placeholder="Your company name"
value={formData.company}
onChange={handleChange}
required
className="w-full px-4 py-2 rounded-lg bg-secondary-button text-foreground border border-background-accent/20 focus:outline-none focus:ring-2 focus:ring-primary-cta/50"
placeholder="Your company name"
className="w-full px-4 py-2 border border-slate-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-transparent"
/>
{errors.company && (
<p className="text-red-600 text-sm mt-1">{errors.company}</p>
)}
</div>
{/* Location and Job Type */}
{/* Location */}
<div className="grid grid-cols-1 md:grid-cols-2 gap-4">
<div>
<label htmlFor="location" className="block text-sm font-semibold mb-2">
Location <span className="text-red-500">*</span>
<label htmlFor="location" className="block text-sm font-semibold text-slate-900 mb-2">
City *
</label>
<input
id="location"
type="text"
value={formData.location}
onChange={handleInputChange}
id="location"
name="location"
placeholder="e.g., Amsterdam, Remote"
value={formData.location}
onChange={handleChange}
required
className="w-full px-4 py-2 rounded-lg bg-secondary-button text-foreground border border-background-accent/20 focus:outline-none focus:ring-2 focus:ring-primary-cta/50"
placeholder="e.g., Amsterdam"
className="w-full px-4 py-2 border border-slate-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-transparent"
/>
{errors.location && (
<p className="text-red-600 text-sm mt-1">{errors.location}</p>
)}
</div>
<div>
<label htmlFor="jobType" className="block text-sm font-semibold mb-2">
Job Type
<label htmlFor="province" className="block text-sm font-semibold text-slate-900 mb-2">
Province *
</label>
<select
id="province"
name="province"
value={formData.province}
onChange={handleChange}
required
className="w-full px-4 py-2 border border-slate-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-transparent"
>
<option value="">Select Province</option>
<option value="North Holland">North Holland</option>
<option value="South Holland">South Holland</option>
<option value="Utrecht">Utrecht</option>
<option value="Gelderland">Gelderland</option>
<option value="North Brabant">North Brabant</option>
<option value="Overijssel">Overijssel</option>
<option value="Flevoland">Flevoland</option>
<option value="Friesland">Friesland</option>
<option value="Groningen">Groningen</option>
<option value="Drenthe">Drenthe</option>
<option value="Limburg">Limburg</option>
<option value="Zeeland">Zeeland</option>
</select>
</div>
</div>
{/* Job Type */}
<div className="grid grid-cols-1 md:grid-cols-2 gap-4">
<div>
<label htmlFor="jobType" className="block text-sm font-semibold text-slate-900 mb-2">
Job Type *
</label>
<select
id="jobType"
name="jobType"
value={formData.jobType}
onChange={handleInputChange}
className="w-full px-4 py-2 rounded-lg bg-secondary-button text-foreground border border-background-accent/20 focus:outline-none focus:ring-2 focus:ring-primary-cta/50"
onChange={handleChange}
className="w-full px-4 py-2 border border-slate-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-transparent"
>
<option>Full-time</option>
<option>Part-time</option>
<option>Contract</option>
<option>Freelance</option>
<option value="Full-Time">Full-Time</option>
<option value="Part-Time">Part-Time</option>
<option value="Contract">Contract</option>
<option value="Temporary">Temporary</option>
<option value="Internship">Internship</option>
</select>
</div>
</div>
{/* Salary */}
<div>
<label htmlFor="salary" className="block text-sm font-semibold mb-2">
Salary Range <span className="text-red-500">*</span>
</label>
<input
id="salary"
type="text"
value={formData.salary}
onChange={handleInputChange}
name="salary"
placeholder="e.g., €50,000 - €70,000"
required
className="w-full px-4 py-2 rounded-lg bg-secondary-button text-foreground border border-background-accent/20 focus:outline-none focus:ring-2 focus:ring-primary-cta/50"
/>
{errors.salary && (
<p className="text-red-600 text-sm mt-1">{errors.salary}</p>
)}
<div>
<label htmlFor="salaryRange" className="block text-sm font-semibold text-slate-900 mb-2">
Salary Range
</label>
<input
type="text"
id="salaryRange"
name="salaryRange"
value={formData.salaryRange}
onChange={handleChange}
placeholder="e.g., €2,000 - €3,500"
className="w-full px-4 py-2 border border-slate-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-transparent"
/>
</div>
</div>
{/* Description */}
<div>
<label htmlFor="description" className="block text-sm font-semibold mb-2">
Job Description <span className="text-red-500">*</span>
<label htmlFor="description" className="block text-sm font-semibold text-slate-900 mb-2">
Job Description *
</label>
<textarea
id="description"
name="description"
value={formData.description}
onChange={handleInputChange}
placeholder="Describe the role, responsibilities, and what makes this opportunity unique..."
rows={6}
className="w-full px-4 py-3 rounded-lg bg-secondary-button text-foreground placeholder:opacity-75 border border-background-accent/20 focus:outline-none focus:ring-2 focus:ring-primary-cta/50 resize-vertical"
onChange={handleChange}
required
rows={4}
placeholder="Describe the role, responsibilities, and key tasks..."
className="w-full px-4 py-2 border border-slate-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-transparent"
/>
{errors.description && (
<p className="text-red-600 text-sm mt-1">{errors.description}</p>
)}
</div>
{/* Requirements */}
<div>
<label htmlFor="requirements" className="block text-sm font-semibold mb-2">
Requirements <span className="text-red-500">*</span>
<label htmlFor="requirements" className="block text-sm font-semibold text-slate-900 mb-2">
Requirements *
</label>
<textarea
id="requirements"
name="requirements"
value={formData.requirements}
onChange={handleInputChange}
placeholder="List required skills, experience, and qualifications. One per line recommended."
rows={5}
className="w-full px-4 py-3 rounded-lg bg-secondary-button text-foreground placeholder:opacity-75 border border-background-accent/20 focus:outline-none focus:ring-2 focus:ring-primary-cta/50 resize-vertical"
onChange={handleChange}
required
rows={4}
placeholder="List the required skills, experience, education, and qualifications..."
className="w-full px-4 py-2 border border-slate-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-transparent"
/>
{errors.requirements && (
<p className="text-red-600 text-sm mt-1">{errors.requirements}</p>
)}
</div>
{/* Contact Information */}
<div className="border-t border-background-accent/20 pt-6">
<h3 className="text-lg font-semibold mb-4">Contact Information</h3>
<div className="grid grid-cols-1 md:grid-cols-2 gap-4">
<div>
<label htmlFor="email" className="block text-sm font-semibold mb-2">
Email Address <span className="text-red-500">*</span>
</label>
<input
id="email"
type="email"
value={formData.email}
onChange={handleInputChange}
name="email"
placeholder="recruiter@company.com"
required
className="w-full px-4 py-2 rounded-lg bg-secondary-button text-foreground border border-background-accent/20 focus:outline-none focus:ring-2 focus:ring-primary-cta/50"
/>
{errors.email && (
<p className="text-red-600 text-sm mt-1">{errors.email}</p>
)}
</div>
<div>
<label htmlFor="contactPhone" className="block text-sm font-semibold mb-2">
Phone Number (Optional)
</label>
<input
id="contactPhone"
type="tel"
value={formData.contactPhone}
onChange={handleInputChange}
name="contactPhone"
placeholder="+31 (0)6 1234 5678"
className="w-full px-4 py-2 rounded-lg bg-secondary-button text-foreground border border-background-accent/20 focus:outline-none focus:ring-2 focus:ring-primary-cta/50"
/>
</div>
</div>
{/* Benefits */}
<div>
<label htmlFor="benefits" className="block text-sm font-semibold text-slate-900 mb-2">
Benefits & Perks
</label>
<textarea
id="benefits"
name="benefits"
value={formData.benefits}
onChange={handleChange}
rows={3}
placeholder="List benefits such as health insurance, remote work, stock options, etc..."
className="w-full px-4 py-2 border border-slate-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-transparent"
/>
</div>
{/* Contact Email */}
<div>
<label htmlFor="contactEmail" className="block text-sm font-semibold text-slate-900 mb-2">
Contact Email *
</label>
<input
type="email"
id="contactEmail"
name="contactEmail"
value={formData.contactEmail}
onChange={handleChange}
required
placeholder="recruiter@company.com"
className="w-full px-4 py-2 border border-slate-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-transparent"
/>
</div>
{/* Submit Button */}
<div className="flex gap-4 pt-4">
<div className="flex gap-4 pt-6">
<button
type="submit"
disabled={isSubmitting}
className="flex-1 px-6 py-3 rounded-lg bg-primary-cta text-white font-semibold disabled:opacity-60 disabled:cursor-not-allowed transition-opacity"
className="flex-1 bg-blue-600 hover:bg-blue-700 text-white font-semibold py-3 rounded-lg transition duration-200"
>
{isSubmitting ? "Posting Job..." : "Post Job"}
Post Job
</button>
<button
type="button"
onClick={() => window.history.back()}
className="px-6 py-3 rounded-lg bg-secondary-button text-foreground font-semibold hover:bg-background-accent/20 transition-colors"
onClick={() =>
setFormData({
jobTitle: "", company: "", location: "", province: "", jobType: "Full-Time", salaryRange: "", description: "", requirements: "", contactEmail: "", benefits: ""})
}
className="flex-1 bg-slate-200 hover:bg-slate-300 text-slate-900 font-semibold py-3 rounded-lg transition duration-200"
>
Cancel
Clear Form
</button>
</div>
</form>
{/* Info Section */}
<div className="mt-12 grid grid-cols-1 md:grid-cols-3 gap-6">
<div className="text-center">
<div className="text-3xl font-bold text-primary-cta mb-2">100%</div>
<p className="text-foreground/75">of jobs posted are visible immediately</p>
</div>
<div className="text-center">
<div className="text-3xl font-bold text-primary-cta mb-2">24/7</div>
<p className="text-foreground/75">job listings stay live around the clock</p>
</div>
<div className="text-center">
<div className="text-3xl font-bold text-primary-cta mb-2">All NL</div>
<p className="text-foreground/75">reach candidates across Netherlands</p>
</div>
<div className="mt-8 p-6 bg-blue-50 border border-blue-200 rounded-lg">
<h3 className="text-lg font-semibold text-slate-900 mb-2"> Tips for a Great Job Listing</h3>
<ul className="text-slate-700 space-y-1">
<li> Use clear, descriptive job titles</li>
<li> Include specific requirements and qualifications</li>
<li> Highlight company culture and benefits</li>
<li> Provide accurate salary ranges</li>
<li> Ensure contact information is correct</li>
</ul>
</div>
</div>
</main>
</div>
<div id="footer" data-section="footer">
<FooterBase