1import { A as SelectValue, Ar as require_jsx_runtime, Ct as useToast, D as SelectContent, E as Select, Hr as __toESM, N as LoadingButton, O as SelectItem, at as Textarea, dt as DialogDescription, gt as DialogTitle, it as getUserFriendlyError, j as Label, k as SelectTrigger, kt as Button, lt as Dialog, pt as DialogHeader, st as useBackend, tt as Input, ut as DialogContent, zr as require_react } from "./index-Cqycx31B.js"; 2//#region components/CreateProjectDialog.tsx 3var import_react = /* @__PURE__ */ __toESM(require_react(), 1); 4var import_jsx_runtime = require_jsx_runtime(); 5function CreateProjectDialog({ open, onOpenChange, onSuccess }) { 6 const backend = useBackend(); 7 const { toast } = useToast(); 8 const [isCreating, setIsCreating] = (0, import_react.useState)(false); 9 const [responseType, setResponseType] = (0, import_react.useState)(""); 10 const [formData, setFormData] = (0, import_react.useState)({ 11 name: "", 12 description: "", 13 rfpNumber: "", 14 agency: "", 15 dueDate: "", 16 value: "" 17 }); 18 const handleSubmit = async (e) => { 19 e.preventDefault(); 20 setIsCreating(true); 21 try { 22 const project = await backend.project.create({ 23 name: formData.name, 24 description: formData.description || void 0, 25 rfpNumber: formData.rfpNumber || void 0, 26 agency: formData.agency || void 0, 27 dueDate: formData.dueDate ? new Date(formData.dueDate) : void 0, 28 value: formData.value ? parseFloat(formData.value) : void 0 29 }); 30 if (responseType) { 31 try { 32 await backend.proposal_workflow.create({ 33 projectId: project.id, 34 name: formData.name, 35 mode: responseType, 36 description: formData.description || void 0 37 }); 38 } catch (workflowError) { 39 console.error("Failed to auto-create workflow:", workflowError); 40 toast({ 41 title: "Warning", 42 description: "Proposal created but workflow setup failed. You can add a workflow from the canvas.", 43 variant: "destructive" 44 }); 45 } 46 try { 47 if (responseType === "rfp") await backend.proposal.createNode({ 48 project_id: project.id, 49 position_x: 100, 50 position_y: 100, 51 title: "Proposal Writer" 52 }); 53 else if (responseType === "rfi") await backend.response.createNode({ 54 project_id: project.id, 55 position_x: 100, 56 position_y: 100, 57 title: "RFI Response Writer", 58 agent_id: "response-rfi-standard" 59 }); 60 else if (responseType === "sources_sought") await backend.response.createNode({ 61 project_id: project.id, 62 position_x: 100, 63 position_y: 100, 64 title: "Sources Sought Response Writer", 65 agent_id: "response-sources-sought-standard" 66 }); 67 } catch (nodeError) { 68 console.error("Failed to auto-create canvas node:", nodeError); 69 toast({ 70 title: "Warning", 71 description: "Canvas node setup failed. You can add a writer node from the canvas sidebar.", 72 variant: "destructive" 73 }); 74 } 75 } 76 toast({ 77 title: "Success", 78 description: "Proposal created successfully" 79 }); 80 setFormData({ 81 name: "", 82 description: "", 83 rfpNumber: "", 84 agency: "", 85 dueDate: "", 86 value: "" 87 }); 88 setResponseType(""); 89 onSuccess(project.id); 90 } catch (error) { 91 console.error("Failed to create project:", error); 92 const friendlyError = getUserFriendlyError("project.create", error); 93 toast({ 94 title: friendlyError.title, 95 description: friendlyError.description, 96 variant: "destructive" 97 }); 98 } finally { 99 setIsCreating(false); 100 } 101 }; 102 return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Dialog, { 103 open, 104 onOpenChange, 105 children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(DialogContent, { 106 className: "sm:max-w-[500px]", 107 children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(DialogHeader, { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(DialogTitle, { children: "Create New Proposal" }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(DialogDescription, { children: "Enter your proposal details below" })] }
107), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("form", { 108 onSubmit: handleSubmit, 109 className: "space-y-4", 110 children: [ 111 /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { 112 className: "space-y-2", 113 children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Label, { 114 htmlFor: "name", 115 children: "Proposal Name *" 116 }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Input, { 117 id: "name", 118 value: formData.name, 119 onChange: (e) => setFormData({ 120 ...formData, 121 name: e.target.value 122 }), 123 placeholder: "e.g., IT Services Contract 2024", 124 required: true 125 })] 126 }), 127 /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { 128 className: "space-y-2", 129 children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Label, { 130 htmlFor: "rfpNumber", 131 children: "RFP Number" 132 }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Input, { 133 id: "rfpNumber", 134 value: formData.rfpNumber, 135 onChange: (e) => setFormData({ 136 ...formData, 137 rfpNumber: e.target.value 138 }), 139 placeholder: "e.g., FA8621-24-R-0001" 140 })] 141 }), 142 /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { 143 className: "space-y-2", 144 children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Label, { 145 htmlFor: "agency", 146 children: "Agency" 147 }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Input, { 148 id: "agency", 149 value: formData.agency, 150 onChange: (e) => setFormData({ 151 ...formData, 152 agency: e.target.value 153 }), 154 placeholder: "e.g., Department of Defense" 155 })] 156 }), 157 /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { 158 className: "space-y-2", 159 children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Label, { 160 htmlFor: "dueDate", 161 children: "Due Date" 162 }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Input, { 163 id: "dueDate", 164 type: "date", 165 value: formData.dueDate, 166 onChange: (e) => setFormData({ 167 ...formData, 168 dueDate: e.target.value 169 }) 170 })] 171 }), 172 /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { 173 className: "space-y-2", 174 children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Label, { 175 htmlFor: "value", 176 children: "Estimated Value" 177 }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Input, { 178 id: "value", 179 type: "number", 180 step: "0.01", 181 value: formData.value, 182 onChange: (e) => setFormData({ 183 ...formData, 184 value: e.target.value 185 }), 186 placeholder: "e.g., 5000000" 187 })] 188 }), 189 /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { 190 className: "space-y-2", 191 children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Label, { 192 htmlFor: "description", 193 children: "Description" 194 }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Textarea, { 195 id: "description", 196 value: formData.description, 197 onChange: (e) => setFormData({ 198 ...formData, 199 description: e.target.value 200 }), 201 placeholder: "Brief description of the proposal", 202 rows: 3 203 })] 204 }), 205 /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { 206 className: "space-y-2", 207 children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Label, { children: "What are you building? (Optional)" }), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Select, { 208 value: responseType, 209 onValueChange: (v) => setResponseType(v), 210 children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(SelectTrigger, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SelectValue, { placeholder: "Select the response type (optional)" }) }
210), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(SelectContent, { children: [ 211 /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SelectItem, { 212 value: "rfp", 213 children: "RFP / Solicitation" 214 }), 215 /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SelectItem, { 216 value: "rfi", 217 children: "RFI" 218 }), 219 /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SelectItem, { 220 value: "sources_sought", 221 children: "Sources Sought" 222 }) 223 ] })] 224 })] 225 }), 226 /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { 227 className: "flex justify-end space-x-2 pt-4", 228 children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Button, { 229 type: "button", 230 variant: "outline", 231 onClick: () => onOpenChange(false), 232 disabled: isCreating, 233 children: "Cancel" 234 }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(LoadingButton, { 235 type: "submit", 236 isLoading: isCreating, 237 loadingText: "Creating...", 238 children: "Create Proposal" 239 })] 240 }) 241 ] 242 })] 243 }) 244 }); 245} 246//#endregion 247export { CreateProjectDialog as t };
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.