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"`
|
Description string `json:"description" db:"description"`
|
||||||
|
|
||||||
// Salary
|
// Salary
|
||||||
SalaryMin *float64 `json:"salaryMin,omitempty" db:"salary_min"`
|
SalaryMin *float64 `json:"salaryMin,omitempty" db:"salary_min"`
|
||||||
SalaryMax *float64 `json:"salaryMax,omitempty" db:"salary_max"`
|
SalaryMax *float64 `json:"salaryMax,omitempty" db:"salary_max"`
|
||||||
SalaryType *string `json:"salaryType,omitempty" db:"salary_type"` // hourly, daily, weekly, monthly, yearly
|
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
|
Currency *string `json:"currency,omitempty" db:"currency"` // BRL, USD, EUR, GBP, JPY
|
||||||
|
SalaryNegotiable bool `json:"salaryNegotiable" db:"salary_negotiable"` // Candidate proposes salary
|
||||||
|
|
||||||
// Employment
|
// Employment
|
||||||
EmploymentType *string `json:"employmentType,omitempty" db:"employment_type"` // full-time, part-time, dispatch, contract
|
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: "",
|
location: "",
|
||||||
salaryMin: "",
|
salaryMin: "",
|
||||||
salaryMax: "",
|
salaryMax: "",
|
||||||
|
salaryFixed: "", // For fixed salary mode
|
||||||
employmentType: "",
|
employmentType: "",
|
||||||
workMode: "remote",
|
workMode: "remote",
|
||||||
|
salaryNegotiable: false, // Candidate proposes salary
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Salary mode toggle: 'fixed' | 'range'
|
||||||
|
const [salaryMode, setSalaryMode] = useState<'fixed' | 'range'>('fixed');
|
||||||
|
|
||||||
const formatPhoneForDisplay = (value: string) => {
|
const formatPhoneForDisplay = (value: string) => {
|
||||||
// Simple formatting to just allow numbers and basic separators if needed
|
// Simple formatting to just allow numbers and basic separators if needed
|
||||||
// For now, just pass through but maybe restrict chars?
|
// For now, just pass through but maybe restrict chars?
|
||||||
|
|
@ -135,9 +140,11 @@ export default function PostJobPage() {
|
||||||
title: job.title,
|
title: job.title,
|
||||||
description: job.description,
|
description: job.description,
|
||||||
location: job.location,
|
location: job.location,
|
||||||
salaryMin: job.salaryMin ? parseInt(job.salaryMin) : null,
|
// Salary logic: if negotiable, send null values
|
||||||
salaryMax: job.salaryMax ? parseInt(job.salaryMax) : null,
|
salaryMin: job.salaryNegotiable ? null : (salaryMode === 'fixed' ? (job.salaryFixed ? parseInt(job.salaryFixed) : null) : (job.salaryMin ? parseInt(job.salaryMin) : null)),
|
||||||
employmentType: job.employmentType,
|
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,
|
workMode: job.workMode,
|
||||||
status: "pending", // Pending review
|
status: "pending", // Pending review
|
||||||
}),
|
}),
|
||||||
|
|
@ -356,25 +363,60 @@ export default function PostJobPage() {
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div className="grid grid-cols-2 gap-4">
|
{/* Salary Section */}
|
||||||
<div>
|
<div className="space-y-3">
|
||||||
<Label>Salário Mínimo (R$)</Label>
|
<div className="flex items-center justify-between">
|
||||||
<Input
|
<Label>Salário</Label>
|
||||||
type="number"
|
<label className="flex items-center gap-2 text-sm cursor-pointer">
|
||||||
value={job.salaryMin}
|
<input
|
||||||
onChange={(e) => setJob({ ...job, salaryMin: e.target.value })}
|
type="checkbox"
|
||||||
placeholder="5000"
|
checked={job.salaryNegotiable}
|
||||||
/>
|
onChange={(e) => setJob({ ...job, salaryNegotiable: e.target.checked })}
|
||||||
</div>
|
className="rounded"
|
||||||
<div>
|
/>
|
||||||
<Label>Salário Máximo (R$)</Label>
|
<span className="text-muted-foreground">Candidato envia proposta</span>
|
||||||
<Input
|
</label>
|
||||||
type="number"
|
|
||||||
value={job.salaryMax}
|
|
||||||
onChange={(e) => setJob({ ...job, salaryMax: e.target.value })}
|
|
||||||
placeholder="10000"
|
|
||||||
/>
|
|
||||||
</div>
|
</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>
|
||||||
<div className="grid grid-cols-2 gap-4">
|
<div className="grid grid-cols-2 gap-4">
|
||||||
<div>
|
<div>
|
||||||
|
|
@ -433,8 +475,14 @@ export default function PostJobPage() {
|
||||||
</h3>
|
</h3>
|
||||||
<p><strong>Título:</strong> {job.title}</p>
|
<p><strong>Título:</strong> {job.title}</p>
|
||||||
<p><strong>Localização:</strong> {job.location || "Não informado"}</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>Salário:</strong> {
|
||||||
<p><strong>Tipo:</strong> {job.employmentType} / {job.workMode}</p>
|
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>
|
||||||
<div className="flex gap-3">
|
<div className="flex gap-3">
|
||||||
<Button variant="outline" onClick={() => setStep(2)} className="flex-1">
|
<Button variant="outline" onClick={() => setStep(2)} className="flex-1">
|
||||||
|
|
|
||||||
|
|
@ -319,6 +319,7 @@ export interface CreateJobPayload {
|
||||||
salaryMax?: number;
|
salaryMax?: number;
|
||||||
salaryType?: 'hourly' | 'daily' | 'weekly' | 'monthly' | 'yearly';
|
salaryType?: 'hourly' | 'daily' | 'weekly' | 'monthly' | 'yearly';
|
||||||
currency?: 'BRL' | 'USD' | 'EUR' | 'GBP' | 'JPY';
|
currency?: 'BRL' | 'USD' | 'EUR' | 'GBP' | 'JPY';
|
||||||
|
salaryNegotiable?: boolean; // When true, candidate proposes salary
|
||||||
employmentType?: 'full-time' | 'part-time' | 'dispatch' | 'contract' | 'temporary' | 'training' | 'voluntary' | 'permanent';
|
employmentType?: 'full-time' | 'part-time' | 'dispatch' | 'contract' | 'temporary' | 'training' | 'voluntary' | 'permanent';
|
||||||
workingHours?: string;
|
workingHours?: string;
|
||||||
location?: string;
|
location?: string;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue