feat: add salary options with toggle and candidate proposal
Backend: - Added migration 030_add_salary_negotiable.sql - Added SalaryNegotiable field to Job model Frontend: - Updated PostJobPage with salary mode toggle (fixed/range) - Added 'Candidato envia proposta' checkbox to hide salary - Updated job submission logic and confirmation display
This commit is contained in:
parent
fb79e987bb
commit
d6bb579260
4 changed files with 83 additions and 27 deletions
|
|
@ -13,10 +13,11 @@ type Job struct {
|
|||
Description string `json:"description" db:"description"`
|
||||
|
||||
// Salary
|
||||
SalaryMin *float64 `json:"salaryMin,omitempty" db:"salary_min"`
|
||||
SalaryMax *float64 `json:"salaryMax,omitempty" db:"salary_max"`
|
||||
SalaryType *string `json:"salaryType,omitempty" db:"salary_type"` // hourly, daily, weekly, monthly, yearly
|
||||
Currency *string `json:"currency,omitempty" db:"currency"` // BRL, USD, EUR, GBP, JPY
|
||||
SalaryMin *float64 `json:"salaryMin,omitempty" db:"salary_min"`
|
||||
SalaryMax *float64 `json:"salaryMax,omitempty" db:"salary_max"`
|
||||
SalaryType *string `json:"salaryType,omitempty" db:"salary_type"` // hourly, daily, weekly, monthly, yearly
|
||||
Currency *string `json:"currency,omitempty" db:"currency"` // BRL, USD, EUR, GBP, JPY
|
||||
SalaryNegotiable bool `json:"salaryNegotiable" db:"salary_negotiable"` // Candidate proposes salary
|
||||
|
||||
// Employment
|
||||
EmploymentType *string `json:"employmentType,omitempty" db:"employment_type"` // full-time, part-time, dispatch, contract
|
||||
|
|
|
|||
6
backend/migrations/030_add_salary_negotiable.sql
Normal file
6
backend/migrations/030_add_salary_negotiable.sql
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
-- Migration: Add salary_negotiable column to jobs table
|
||||
-- Description: When true, salary is hidden and candidate sends proposal
|
||||
|
||||
ALTER TABLE jobs ADD COLUMN IF NOT EXISTS salary_negotiable BOOLEAN DEFAULT false;
|
||||
|
||||
COMMENT ON COLUMN jobs.salary_negotiable IS 'When true, salary is not displayed and candidate proposes their own';
|
||||
|
|
@ -62,10 +62,15 @@ export default function PostJobPage() {
|
|||
location: "",
|
||||
salaryMin: "",
|
||||
salaryMax: "",
|
||||
salaryFixed: "", // For fixed salary mode
|
||||
employmentType: "",
|
||||
workMode: "remote",
|
||||
salaryNegotiable: false, // Candidate proposes salary
|
||||
});
|
||||
|
||||
// Salary mode toggle: 'fixed' | 'range'
|
||||
const [salaryMode, setSalaryMode] = useState<'fixed' | 'range'>('fixed');
|
||||
|
||||
const formatPhoneForDisplay = (value: string) => {
|
||||
// Simple formatting to just allow numbers and basic separators if needed
|
||||
// For now, just pass through but maybe restrict chars?
|
||||
|
|
@ -135,9 +140,11 @@ export default function PostJobPage() {
|
|||
title: job.title,
|
||||
description: job.description,
|
||||
location: job.location,
|
||||
salaryMin: job.salaryMin ? parseInt(job.salaryMin) : null,
|
||||
salaryMax: job.salaryMax ? parseInt(job.salaryMax) : null,
|
||||
employmentType: job.employmentType,
|
||||
// Salary logic: if negotiable, send null values
|
||||
salaryMin: job.salaryNegotiable ? null : (salaryMode === 'fixed' ? (job.salaryFixed ? parseInt(job.salaryFixed) : null) : (job.salaryMin ? parseInt(job.salaryMin) : null)),
|
||||
salaryMax: job.salaryNegotiable ? null : (salaryMode === 'fixed' ? (job.salaryFixed ? parseInt(job.salaryFixed) : null) : (job.salaryMax ? parseInt(job.salaryMax) : null)),
|
||||
salaryNegotiable: job.salaryNegotiable,
|
||||
employmentType: job.employmentType || null,
|
||||
workMode: job.workMode,
|
||||
status: "pending", // Pending review
|
||||
}),
|
||||
|
|
@ -356,25 +363,60 @@ export default function PostJobPage() {
|
|||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div className="grid grid-cols-2 gap-4">
|
||||
<div>
|
||||
<Label>Salário Mínimo (R$)</Label>
|
||||
<Input
|
||||
type="number"
|
||||
value={job.salaryMin}
|
||||
onChange={(e) => setJob({ ...job, salaryMin: e.target.value })}
|
||||
placeholder="5000"
|
||||
/>
|
||||
</div>
|
||||
<div>
|
||||
<Label>Salário Máximo (R$)</Label>
|
||||
<Input
|
||||
type="number"
|
||||
value={job.salaryMax}
|
||||
onChange={(e) => setJob({ ...job, salaryMax: e.target.value })}
|
||||
placeholder="10000"
|
||||
/>
|
||||
{/* Salary Section */}
|
||||
<div className="space-y-3">
|
||||
<div className="flex items-center justify-between">
|
||||
<Label>Salário</Label>
|
||||
<label className="flex items-center gap-2 text-sm cursor-pointer">
|
||||
<input
|
||||
type="checkbox"
|
||||
checked={job.salaryNegotiable}
|
||||
onChange={(e) => setJob({ ...job, salaryNegotiable: e.target.checked })}
|
||||
className="rounded"
|
||||
/>
|
||||
<span className="text-muted-foreground">Candidato envia proposta</span>
|
||||
</label>
|
||||
</div>
|
||||
|
||||
{!job.salaryNegotiable && (
|
||||
<>
|
||||
{salaryMode === 'fixed' ? (
|
||||
<div>
|
||||
<Input
|
||||
type="number"
|
||||
value={job.salaryFixed}
|
||||
onChange={(e) => setJob({ ...job, salaryFixed: e.target.value })}
|
||||
placeholder="Valor"
|
||||
/>
|
||||
</div>
|
||||
) : (
|
||||
<div className="grid grid-cols-2 gap-4">
|
||||
<Input
|
||||
type="number"
|
||||
value={job.salaryMin}
|
||||
onChange={(e) => setJob({ ...job, salaryMin: e.target.value })}
|
||||
placeholder="Mín"
|
||||
/>
|
||||
<Input
|
||||
type="number"
|
||||
value={job.salaryMax}
|
||||
onChange={(e) => setJob({ ...job, salaryMax: e.target.value })}
|
||||
placeholder="Máx"
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => setSalaryMode(salaryMode === 'fixed' ? 'range' : 'fixed')}
|
||||
className="flex items-center gap-1 text-sm text-primary hover:underline"
|
||||
>
|
||||
<svg className="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
||||
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15" />
|
||||
</svg>
|
||||
{salaryMode === 'fixed' ? 'Faixa salarial' : 'Salário fixo'}
|
||||
</button>
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
<div className="grid grid-cols-2 gap-4">
|
||||
<div>
|
||||
|
|
@ -433,8 +475,14 @@ export default function PostJobPage() {
|
|||
</h3>
|
||||
<p><strong>Título:</strong> {job.title}</p>
|
||||
<p><strong>Localização:</strong> {job.location || "Não informado"}</p>
|
||||
<p><strong>Salário:</strong> {job.salaryMin && job.salaryMax ? `R$ ${job.salaryMin} - R$ ${job.salaryMax}` : "A combinar"}</p>
|
||||
<p><strong>Tipo:</strong> {job.employmentType} / {job.workMode}</p>
|
||||
<p><strong>Salário:</strong> {
|
||||
job.salaryNegotiable
|
||||
? "Candidato envia proposta"
|
||||
: salaryMode === 'fixed'
|
||||
? (job.salaryFixed ? `R$ ${job.salaryFixed}` : "A combinar")
|
||||
: (job.salaryMin && job.salaryMax ? `R$ ${job.salaryMin} - R$ ${job.salaryMax}` : "A combinar")
|
||||
}</p>
|
||||
<p><strong>Tipo:</strong> {job.employmentType || "Qualquer"} / {job.workMode}</p>
|
||||
</div>
|
||||
<div className="flex gap-3">
|
||||
<Button variant="outline" onClick={() => setStep(2)} className="flex-1">
|
||||
|
|
|
|||
|
|
@ -319,6 +319,7 @@ export interface CreateJobPayload {
|
|||
salaryMax?: number;
|
||||
salaryType?: 'hourly' | 'daily' | 'weekly' | 'monthly' | 'yearly';
|
||||
currency?: 'BRL' | 'USD' | 'EUR' | 'GBP' | 'JPY';
|
||||
salaryNegotiable?: boolean; // When true, candidate proposes salary
|
||||
employmentType?: 'full-time' | 'part-time' | 'dispatch' | 'contract' | 'temporary' | 'training' | 'voluntary' | 'permanent';
|
||||
workingHours?: string;
|
||||
location?: string;
|
||||
|
|
|
|||
Loading…
Reference in a new issue