"use client"; import { useState } from "react"; import { Plus, Trash2, GripVertical, X } from "lucide-react"; import { Button } from "@/components/ui/button"; import { Input } from "@/components/ui/input"; import { Label } from "@/components/ui/label"; import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue, } from "@/components/ui/select"; import { Switch } from "@/components/ui/switch"; import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card"; import { Badge } from "@/components/ui/badge"; export type QuestionType = "text" | "long_text" | "yes_no" | "multiple_choice" | "select"; export interface Question { id: string; type: QuestionType; label: string; required: boolean; options?: string[]; // For multiple_choice or select } interface JobFormBuilderProps { questions: Question[]; onChange: (questions: Question[]) => void; maxQuestions?: number; } export function JobFormBuilder({ questions, onChange, maxQuestions = 7 }: JobFormBuilderProps) { const [activeQuestion, setActiveQuestion] = useState(null); const addQuestion = () => { if (questions.length >= maxQuestions) return; const newQuestion: Question = { id: Math.random().toString(36).substr(2, 9), type: "text", label: "", required: false, }; onChange([...questions, newQuestion]); setActiveQuestion(newQuestion.id); }; const removeQuestion = (id: string) => { onChange(questions.filter((q) => q.id !== id)); if (activeQuestion === id) setActiveQuestion(null); }; const updateQuestion = (id: string, updates: Partial) => { onChange( questions.map((q) => (q.id === id ? { ...q, ...updates } : q)) ); }; const addOption = (qId: string) => { const q = questions.find(q => q.id === qId); if (!q) return; const options = q.options || []; updateQuestion(qId, { options: [...options, ""] }); }; const updateOption = (qId: string, idx: number, val: string) => { const q = questions.find(q => q.id === qId); if (!q || !q.options) return; const newOptions = [...q.options]; newOptions[idx] = val; updateQuestion(qId, { options: newOptions }); }; const removeOption = (qId: string, idx: number) => { const q = questions.find(q => q.id === qId); if (!q || !q.options) return; const newOptions = q.options.filter((_, i) => i !== idx); updateQuestion(qId, { options: newOptions }); }; return (

Formulário de Candidatura

Personalize as perguntas para os candidatos (Máx: {maxQuestions})

{/* Fixed CV Field */}

Currículo (CV)

Arquivo PDF, DOCX (Obrigatório)

Fixo
{questions.map((q, index) => (
updateQuestion(q.id, { label: e.target.value })} placeholder="Ex: Por que você quer trabalhar aqui?" />
{/* Options for Multiple Choice / Select */} {(q.type === 'multiple_choice' || q.type === 'select') && (
{q.options?.map((opt, i) => (
updateOption(q.id, i, e.target.value)} className="h-8 text-sm" placeholder={`Opção ${i + 1}`} />
))}
)}
updateQuestion(q.id, { required: checked })} id={`req-${q.id}`} />
))} {questions.length === 0 && (

Nenhuma pergunta personalizada adicionada.

Clique em "Adicionar Pergunta" para criar seu formulário.

)}
); }