diff --git a/frontend/src/app/post-job/page.tsx b/frontend/src/app/post-job/page.tsx index 28a7687..1bda69e 100644 --- a/frontend/src/app/post-job/page.tsx +++ b/frontend/src/app/post-job/page.tsx @@ -20,6 +20,7 @@ import { RichTextEditor } from "@/components/rich-text-editor"; import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select"; import { useTranslation } from "@/lib/i18n"; import { JobFormBuilder, Question } from "@/components/job-form-builder"; +import { Checkbox } from "@/components/ui/checkbox"; // Common Country Codes const COUNTRY_CODES = [ @@ -50,6 +51,14 @@ const getCurrencySymbol = (code: string): string => { return symbols[code] || code; }; +type PostPaymentStatus = "pending_review" | "active" | "failed_payment"; + +const statusLabels: Record = { + pending_review: "pending_review", + active: "active", + failed_payment: "failed_payment", +}; + export default function PostJobPage() { @@ -73,6 +82,7 @@ export default function PostJobPage() { }; const [loading, setLoading] = useState(false); + const [transactionReceipt, setTransactionReceipt] = useState<{ id: string; status: PostPaymentStatus; createdAt: string } | null>(null); // Company/User data const [company, setCompany] = useState({ @@ -178,6 +188,12 @@ export default function PostJobPage() { return value.replace(/[^\d\s-]/g, ""); }; + const getPostPaymentStatus = (paymentMethod: string): PostPaymentStatus => { + if (!paymentMethod) return "failed_payment"; + if (paymentMethod === "boleto") return "pending_review"; + return "active"; + }; + const validateForm = () => { if (!company.name || !company.email || !company.password) { toast.error(t.errors.company_required); @@ -321,6 +337,8 @@ export default function PostJobPage() { const { token } = await registerRes.json(); // 2. Create Job with token + const calculatedPostPaymentStatus = getPostPaymentStatus(billing.paymentMethod); + const jobRes = await fetch(`${apiBase}/api/v1/jobs`, { method: "POST", headers: { @@ -367,6 +385,14 @@ export default function PostJobPage() { localStorage.setItem("token", token); localStorage.setItem("auth_token", token); + const receipt = { + id: `TX-${Date.now().toString(36).toUpperCase()}`, + status: calculatedPostPaymentStatus, + createdAt: new Date().toISOString(), + }; + localStorage.setItem("last_job_posting_receipt", JSON.stringify(receipt)); + setTransactionReceipt(receipt); + toast.success(t.success.job_created); router.push("/dashboard/jobs"); @@ -624,11 +650,10 @@ export default function PostJobPage() {
- setCompany({ ...company, hidePublicProfile: e.target.checked })} + onCheckedChange={(checked) => setCompany({ ...company, hidePublicProfile: checked === true })} className="mt-1" />
@@ -1084,9 +1109,17 @@ export default function PostJobPage() {

Plano: {PRICING_BY_COUNTRY[billing.billingCountry || job.country]?.amount || "Consulte comercial"} / {PRICING_BY_COUNTRY[billing.billingCountry || job.country]?.duration || "30 dias"}

Resumo: {job.title} · {job.country || "País não informado"} · {billing.billingCountry || "Faturamento não informado"}

Pagamento: {billing.paymentMethod ? (billing.paymentMethod === "card" ? "Cartão de crédito" : billing.paymentMethod === "pix" ? "PIX" : "Boleto") : "Não selecionado"}

-

Status após envio: review

+

Status após pagamento: {statusLabels[getPostPaymentStatus(billing.paymentMethod)]}

+ {transactionReceipt && ( +
+

Comprovante: {transactionReceipt.id}

+

Criado em: {new Date(transactionReceipt.createdAt).toLocaleString("pt-BR")}

+

Status registrado: {statusLabels[transactionReceipt.status]}

+
+ )} +