Merge pull request #58 from rede5/codex/implementar-25%-adicional-no-sistema
Codex-generated pull request
This commit is contained in:
commit
fbefcfdd00
1 changed files with 37 additions and 4 deletions
|
|
@ -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<PostPaymentStatus, string> = {
|
||||
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() {
|
|||
</div>
|
||||
|
||||
<div className="flex items-start gap-3 rounded-md border p-3">
|
||||
<input
|
||||
<Checkbox
|
||||
id="hide-company-data"
|
||||
type="checkbox"
|
||||
checked={company.hidePublicProfile}
|
||||
onChange={(e) => setCompany({ ...company, hidePublicProfile: e.target.checked })}
|
||||
onCheckedChange={(checked) => setCompany({ ...company, hidePublicProfile: checked === true })}
|
||||
className="mt-1"
|
||||
/>
|
||||
<div>
|
||||
|
|
@ -1084,9 +1109,17 @@ export default function PostJobPage() {
|
|||
<p><strong>Plano:</strong> {PRICING_BY_COUNTRY[billing.billingCountry || job.country]?.amount || "Consulte comercial"} / {PRICING_BY_COUNTRY[billing.billingCountry || job.country]?.duration || "30 dias"}</p>
|
||||
<p><strong>Resumo:</strong> {job.title} · {job.country || "País não informado"} · {billing.billingCountry || "Faturamento não informado"}</p>
|
||||
<p><strong>Pagamento:</strong> {billing.paymentMethod ? (billing.paymentMethod === "card" ? "Cartão de crédito" : billing.paymentMethod === "pix" ? "PIX" : "Boleto") : "Não selecionado"}</p>
|
||||
<p><strong>Status após envio:</strong> review</p>
|
||||
<p><strong>Status após pagamento:</strong> {statusLabels[getPostPaymentStatus(billing.paymentMethod)]}</p>
|
||||
</div>
|
||||
|
||||
{transactionReceipt && (
|
||||
<div className="rounded-lg border border-border bg-background p-4 text-sm">
|
||||
<p><strong>Comprovante:</strong> {transactionReceipt.id}</p>
|
||||
<p><strong>Criado em:</strong> {new Date(transactionReceipt.createdAt).toLocaleString("pt-BR")}</p>
|
||||
<p><strong>Status registrado:</strong> {statusLabels[transactionReceipt.status]}</p>
|
||||
</div>
|
||||
)}
|
||||
|
||||
<div className="flex gap-3">
|
||||
<Button variant="outline" onClick={() => setStep(3)} className="flex-1">
|
||||
{t.buttons.back}
|
||||
|
|
|
|||
Loading…
Reference in a new issue