fernando-bold commited on
Commit
637ffd6
·
verified ·
1 Parent(s): 58ff976

'use client'

Browse files

import React, { useState } from 'react'
import { Button } from "@medusajs/ui"
import { useCreateSolarIntegrator } from '../../../lib/hooks/solar-integrators'
import { useCompany } from '../../../lib/hooks/companies'

interface SolarIntegratorRegistrationFormProps {
onSuccess?: () => void
onCancel?: () => void
}

const SolarIntegratorRegistrationForm: React.FC<SolarIntegratorRegistrationFormProps> = ({
onSuccess,
onCancel
}) => {
const [formData, setFormData] = useState({
company_id: '',
integrator_type: 'RESIDENTIAL_INSTALLER',
certification_level: 'LEVEL_1',
license_number: '',
license_expiry_date: '',
years_of_experience: 0,
completed_projects: 0,
warranty_offered: '',
insurance_coverage: '',
specialization: [] as string[],
coverage_area: [] as string[],
certifications: [] as string[],
equipment_brands: [] as string[],
minimum_project_size: '',
maximum_project_size: '',
installation_time_frame: '',
warranty_period: 10,
maintenance_services: false,
emergency_support: false,
design_services: false,
project_management: false,
})

const [currentStep, setCurrentStep] = useState(1)
const totalSteps = 3

const { mutateAsync: createIntegrator, isPending } = useCreateSolarIntegrator()
const { data: companyData } = useCompany({}) // Get company data

const handleInputChange = (
e: React.ChangeEvent<HTMLInputElement | HTMLSelectElement | HTMLTextAreaElement>
) => {
const { name, value, type } = e.target
if (type === 'checkbox') {
const checkbox = e.target as HTMLInputElement
setFormData(prev => ({ ...prev, [name]: checkbox.checked }))
} else {
setFormData(prev => ({ ...prev, [name]: value }))
}
}

const handleArrayChange = (name: string, value: string) => {
setFormData(prev => {
const currentArray = (prev as any)[name] as string[]
const newArray = currentArray.includes(value)
? currentArray.filter(item => item !== value)
: [...currentArray, value]
return { ...prev, [name]: newArray }
})
}

const handleSubmit = async (e: React.FormEvent) => {
e.preventDefault()

try {
// In a real app, you would first create or get the company
// For now, we'll simulate getting a company ID
const company_id = companyData?.companies?.[0]?.id || 'comp_123'

await createIntegrator({
...formData,
company_id
})

onSuccess?.()
} catch (error) {
console.error('Error creating solar integrator:', error)
alert('Erro ao registrar integrador solar. Por favor, tente novamente.')
}
}

// Step 1: Basic Information
const renderStep1 = () => (
<div className="space-y-4">
<h3 className="text-lg font-semibold">Informações Básicas</h3>

<div className="grid grid-cols-1 md:grid-cols-2 gap-4">
<div>
<label className="text-sm font-medium text-gray-700">Tipo de Integrador *</label>
<select
name="integrator_type"
value={formData.integrator_type}
onChange={handleInputChange}
className="mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500 sm:text-sm"
>
<option value="RESIDENTIAL_INSTALLER">Instalador Residencial</option>
<option value="COMMERCIAL_INSTALLER">Instalador Comercial</option>
<option value="UTILITY_INSTALLER">Instalador de Utilidade</option>
<option value="DESIGNER">Designer</option>
<option value="DISTRIBUTOR">Distribuidor</option>
</select>
</div>

<div>
<label className="text-sm font-medium text-gray-700">Nível de Certificação</label>
<select
name="certification_level"
value={formData.certification_level}
onChange={handleInputChange}
className="mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500 sm:text-sm"
>
<option value="LEVEL_1">Nível 1</option>
<option value="LEVEL_2">Nível 2</option>
<option value="LEVEL_3">Nível 3</option>
<option value="MASTER">Master</option>
</select>
</div>
</div>

<div className="grid grid-cols-1 md:grid-cols-2 gap-4">
<div>
<label className="text-sm font-medium text-gray-700">Número da Licença</label>
<input
type="text"
name="license_number"
value={formData.license_number}
onChange={handleInputChange}
className="mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500 sm:text-sm"
/>
</div>

<div>
<label className="text-sm font-medium text-gray-700">Data de Expiração da Licença</label>
<input
type="date"
name="license_expiry_date"
value={formData.license_expiry_date}
onChange={handleInputChange}
className="mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500 sm:text-sm"
/>
</div>
</div>

<div className="grid grid-cols-1 md:grid-cols-3 gap-4">
<div>
<label className="text-sm font-medium text-gray-700">Anos de Experiência</label>
<input
type="number"
name="years_of_experience"
value={formData.years_of_experience}
onChange={handleInputChange}
className="mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500 sm:text-sm"
/>
</div>

<div>
<label className="text-sm font-medium text-gray-700">Projetos Completados</label>
<input
type="number"
name="completed_projects"
value={formData.completed_projects}
onChange={handleInputChange}
className="mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500 sm:text-sm"
/>
</div>

<div>
<label className="text-sm font-medium text-gray-700">Período de Garantia (anos)</label>
<input
type="number"
name="warranty_period"
value={formData.warranty_period}
onChange={handleInputChange}
className="mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500 sm:text-sm"
/>
</div>
</div>
</div>
)

// Step 2: Services and Capabilities
const renderStep2 = () => (
<div className="space-y-4">
<h3 className="text-lg font-semibold">Serviços e Capabilities</h3>

<div className="grid grid-cols-1 md:grid-cols-2 gap-4">
<div>
<label className="text-sm font-medium text-gray-700">Áreas de Especialização</label>
<div className="mt-1 space-y-2">
{['roof_mount', 'ground_mount', 'tracking_systems', 'commercial', 'residential'].map((spec) => (
<div key={spec} className="flex items-center">
<input
id={`spec-${spec}`}
name="specialization"
type="checkbox"
checked={formData.specialization.includes(spec)}
onChange={() => handleArrayChange('specialization', spec)}
className="h-4 w-4 rounded border-gray-300 text-indigo-600 focus:ring-indigo-500"
/>
<label htmlFor={`spec-${spec}`} className="ml-2 block text-sm text-gray-900 capitalize">
{spec.replace('_', ' ')}
</label>
</div>
))}
</div>
</div>

<div>
<label className="text-sm font-medium text-gray-700">Marcas de Equipamentos</label>
<textarea
name="equipment_brands"
value={formData.equipment_brands.join(', ')}
onChange={(e) => setFormData(prev => ({...prev, equipment_brands: e.target.value.split(',').map(item => item.trim())}))}
placeholder="Digite marcas separadas por vírgula"
className="mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500 sm:text-sm"
/>
</div>
</div>

<div className="grid grid-cols-1 md:grid-cols-2 gap-4">
<div>
<label className="text-sm font-medium text-gray-700">Tamanho Mínimo do Projeto</label>
<input
type="text"
name="minimum_project_size"
value={formData.minimum_project_size}
onChange={handleInputChange}
placeholder="ex: 5kW"
className="mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500 sm:text-sm"
/>
</div>

<div>
<label className="text-sm font-medium text-gray-700">Tamanho Máximo do Projeto</label>
<input
type="text"
name="maximum_project_size"
value={formData.maximum_project_size}
onChange={handleInputChange}
placeholder="ex: 1MW"
className="mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500 sm:text-sm"
/>
</div>
</div>

<div>
<label className="text-sm font-medium text-gray-700">Prazo de Instalação</label>
<input
type="text"
name="installation_time_frame"
value={formData.installation_time_frame}
onChange={handleInputChange}
placeholder="ex: 4-6 semanas"
className="mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500 sm:text-sm"
/>
</div>

<div className="grid grid-cols-2 md:grid-cols-4 gap-4">
<div className="flex items-center">
<input
id="maintenance_services"

Files changed (2) hide show
  1. components/solar-integrator-form.js +603 -0
  2. index.html +4 -5
components/solar-integrator-form.js ADDED
@@ -0,0 +1,603 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ class CustomSolarIntegratorForm extends HTMLElement {
2
+ constructor() {
3
+ super();
4
+ this.currentStep = 1;
5
+ this.totalSteps = 3;
6
+ this.formData = {
7
+ company_id: '',
8
+ integrator_type: 'RESIDENTIAL_INSTALLER',
9
+ certification_level: 'LEVEL_1',
10
+ license_number: '',
11
+ license_expiry_date: '',
12
+ years_of_experience: 0,
13
+ completed_projects: 0,
14
+ warranty_offered: '',
15
+ insurance_coverage: '',
16
+ specialization: [],
17
+ coverage_area: [],
18
+ certifications: [],
19
+ equipment_brands: [],
20
+ minimum_project_size: '',
21
+ maximum_project_size: '',
22
+ installation_time_frame: '',
23
+ warranty_period: 10,
24
+ maintenance_services: false,
25
+ emergency_support: false,
26
+ design_services: false,
27
+ project_management: false,
28
+ };
29
+ }
30
+
31
+ connectedCallback() {
32
+ this.attachShadow({ mode: 'open' });
33
+ this.render();
34
+ }
35
+
36
+ handleInputChange(e) {
37
+ const { name, value, type, checked } = e.target;
38
+ if (type === 'checkbox') {
39
+ this.formData[name] = checked;
40
+ } else {
41
+ this.formData[name] = value;
42
+ }
43
+ this.render();
44
+ }
45
+
46
+ handleArrayChange(name, value) {
47
+ const currentArray = this.formData[name];
48
+ const newArray = currentArray.includes(value)
49
+ ? currentArray.filter(item => item !== value)
50
+ : [...currentArray, value];
51
+ this.formData[name] = newArray;
52
+ this.render();
53
+ }
54
+
55
+ nextStep() {
56
+ if (this.currentStep < this.totalSteps) {
57
+ this.currentStep++;
58
+ this.render();
59
+ }
60
+ }
61
+
62
+ prevStep() {
63
+ if (this.currentStep > 1) {
64
+ this.currentStep--;
65
+ this.render();
66
+ }
67
+ }
68
+
69
+ renderStep1() {
70
+ return `
71
+ <div class="space-y-4">
72
+ <h3 class="text-lg font-semibold">Informações Básicas</h3>
73
+
74
+ <div class="grid grid-cols-1 md:grid-cols-2 gap-4">
75
+ <div>
76
+ <label class="text-sm font-medium text-gray-700">Tipo de Integrador *</label>
77
+ <select
78
+ name="integrator_type"
79
+ value="${this.formData.integrator_type}"
80
+ onchange="this.getRootNode().host.handleInputChange(event)"
81
+ class="mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500 sm:text-sm"
82
+ >
83
+ <option value="RESIDENTIAL_INSTALLER">Instalador Residencial</option>
84
+ <option value="COMMERCIAL_INSTALLER">Instalador Comercial</option>
85
+ <option value="UTILITY_INSTALLER">Instalador de Utilidade</option>
86
+ <option value="DESIGNER">Designer</option>
87
+ <option value="DISTRIBUTOR">Distribuidor</option>
88
+ </select>
89
+ </div>
90
+
91
+ <div>
92
+ <label class="text-sm font-medium text-gray-700">Nível de Certificação</label>
93
+ <select
94
+ name="certification_level"
95
+ value="${this.formData.certification_level}"
96
+ onchange="this.getRootNode().host.handleInputChange(event)"
97
+ class="mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500 sm:text-sm"
98
+ >
99
+ <option value="LEVEL_1">Nível 1</option>
100
+ <option value="LEVEL_2">Nível 2</option>
101
+ <option value="LEVEL_3">Nível 3</option>
102
+ <option value="MASTER">Master</option>
103
+ </select>
104
+ </div>
105
+ </div>
106
+
107
+ <div class="grid grid-cols-1 md:grid-cols-2 gap-4">
108
+ <div>
109
+ <label class="text-sm font-medium text-gray-700">Número da Licença</label>
110
+ <input
111
+ type="text"
112
+ name="license_number"
113
+ value="${this.formData.license_number}"
114
+ onchange="this.getRootNode().host.handleInputChange(event)"
115
+ class="mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500 sm:text-sm"
116
+ />
117
+ </div>
118
+
119
+ <div>
120
+ <label class="text-sm font-medium text-gray-700">Data de Expiração da Licença</label>
121
+ <input
122
+ type="date"
123
+ name="license_expiry_date"
124
+ value="${this.formData.license_expiry_date}"
125
+ onchange="this.getRootNode().host.handleInputChange(event)"
126
+ class="mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500 sm:text-sm"
127
+ />
128
+ </div>
129
+ </div>
130
+
131
+ <div class="grid grid-cols-1 md:grid-cols-3 gap-4">
132
+ <div>
133
+ <label class="text-sm font-medium text-gray-700">Anos de Experiência</label>
134
+ <input
135
+ type="number"
136
+ name="years_of_experience"
137
+ value="${this.formData.years_of_experience}"
138
+ onchange="this.getRootNode().host.handleInputChange(event)"
139
+ class="mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500 sm:text-sm"
140
+ />
141
+ </div>
142
+
143
+ <div>
144
+ <label class="text-sm font-medium text-gray-700">Projetos Completados</label>
145
+ <input
146
+ type="number"
147
+ name="completed_projects"
148
+ value="${this.formData.completed_projects}"
149
+ onchange="this.getRootNode().host.handleInputChange(event)"
150
+ class="mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500 sm:text-sm"
151
+ />
152
+ </div>
153
+
154
+ <div>
155
+ <label class="text-sm font-medium text-gray-700">Período de Garantia (anos)</label>
156
+ <input
157
+ type="number"
158
+ name="warranty_period"
159
+ value="${this.formData.warranty_period}"
160
+ onchange="this.getRootNode().host.handleInputChange(event)"
161
+ class="mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500 sm:text-sm"
162
+ />
163
+ </div>
164
+ </div>
165
+ </div>
166
+ `;
167
+ }
168
+
169
+ renderStep2() {
170
+ return `
171
+ <div class="space-y-4">
172
+ <h3 class="text-lg font-semibold">Serviços e Capabilities</h3>
173
+
174
+ <div class="grid grid-cols-1 md:grid-cols-2 gap-4">
175
+ <div>
176
+ <label class="text-sm font-medium text-gray-700">Áreas de Especialização</label>
177
+ <div class="mt-1 space-y-2">
178
+ ${['roof_mount', 'ground_mount', 'tracking_systems', 'commercial', 'residential'].map(spec => `
179
+ <div key="${spec}" class="flex items-center">
180
+ <input
181
+ id="spec-${spec}"
182
+ name="specialization"
183
+ type="checkbox"
184
+ ${this.formData.specialization.includes(spec) ? 'checked' : ''}
185
+ onchange="this.getRootNode().host.handleArrayChange('specialization', '${spec}')"
186
+ class="h-4 w-4 rounded border-gray-300 text-indigo-600 focus:ring-indigo-500"
187
+ />
188
+ <label for="spec-${spec}" class="ml-2 block text-sm text-gray-900 capitalize">
189
+ ${spec.replace('_', ' ')}
190
+ </label>
191
+ </div>
192
+ `).join('')}
193
+ </div>
194
+ </div>
195
+
196
+ <div>
197
+ <label class="text-sm font-medium text-gray-700">Marcas de Equipamentos</label>
198
+ <textarea
199
+ name="equipment_brands"
200
+ value="${this.formData.equipment_brands.join(', ')}"
201
+ onchange="this.getRootNode().host.handleInputChange(event)"
202
+ placeholder="Digite marcas separadas por vírgula"
203
+ class="mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500 sm:text-sm"
204
+ ></textarea>
205
+ </div>
206
+ </div>
207
+
208
+ <div class="grid grid-cols-1 md:grid-cols-2 gap-4">
209
+ <div>
210
+ <label class="text-sm font-medium text-gray-700">Tamanho Mínimo do Projeto</label>
211
+ <input
212
+ type="text"
213
+ name="minimum_project_size"
214
+ value="${this.formData.minimum_project_size}"
215
+ onchange="this.getRootNode().host.handleInputChange(event)"
216
+ placeholder="ex: 5kW"
217
+ class="mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500 sm:text-sm"
218
+ />
219
+ </div>
220
+
221
+ <div>
222
+ <label class="text-sm font-medium text-gray-700">Tamanho Máximo do Projeto</label>
223
+ <input
224
+ type="text"
225
+ name="maximum_project_size"
226
+ value="${this.formData.maximum_project_size}"
227
+ onchange="this.getRootNode().host.handleInputChange(event)"
228
+ placeholder="ex: 1MW"
229
+ class="mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500 sm:text-sm"
230
+ />
231
+ </div>
232
+ </div>
233
+
234
+ <div>
235
+ <label class="text-sm font-medium text-gray-700">Prazo de Instalação</label>
236
+ <input
237
+ type="text"
238
+ name="installation_time_frame"
239
+ value="${this.formData.installation_time_frame}"
240
+ onchange="this.getRootNode().host.handleInputChange(event)"
241
+ placeholder="ex: 4-6 semanas"
242
+ class="mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500 sm:text-sm"
243
+ />
244
+ </div>
245
+
246
+ <div class="grid grid-cols-2 md:grid-cols-4 gap-4">
247
+ <div class="flex items-center">
248
+ <input
249
+ id="maintenance_services"
250
+ name="maintenance_services"
251
+ type="checkbox"
252
+ ${this.formData.maintenance_services ? 'checked' : ''}
253
+ onchange="this.getRootNode().host.handleInputChange(event)"
254
+ class="h-4 w-4 rounded border-gray-300 text-indigo-600 focus:ring-indigo-500"
255
+ />
256
+ <label for="maintenance_services" class="ml-2 block text-sm text-gray-900">
257
+ Serviços de Manutenção
258
+ </label>
259
+ </div>
260
+
261
+ <div class="flex items-center">
262
+ <input
263
+ id="emergency_support"
264
+ name="emergency_support"
265
+ type="checkbox"
266
+ ${this.formData.emergency_support ? 'checked' : ''}
267
+ onchange="this.getRootNode().host.handleInputChange(event)"
268
+ class="h-4 w-4 rounded border-gray-300 text-indigo-600 focus:ring-indigo-500"
269
+ />
270
+ <label for="emergency_support" class="ml-2 block text-sm text-gray-900">
271
+ Suporte de Emergência
272
+ </label>
273
+ </div>
274
+
275
+ <div class="flex items-center">
276
+ <input
277
+ id="design_services"
278
+ name="design_services"
279
+ type="checkbox"
280
+ ${this.formData.design_services ? 'checked' : ''}
281
+ onchange="this.getRootNode().host.handleInputChange(event)"
282
+ class="h-4 w-4 rounded border-gray-300 text-indigo-600 focus:ring-indigo-500"
283
+ />
284
+ <label for="design_services" class="ml-2 block text-sm text-gray-900">
285
+ Serviços de Design
286
+ </label>
287
+ </div>
288
+
289
+ <div class="flex items-center">
290
+ <input
291
+ id="project_management"
292
+ name="project_management"
293
+ type="checkbox"
294
+ ${this.formData.project_management ? 'checked' : ''}
295
+ onchange="this.getRootNode().host.handleInputChange(event)"
296
+ class="h-4 w-4 rounded border-gray-300 text-indigo-600 focus:ring-indigo-500"
297
+ />
298
+ <label for="project_management" class="ml-2 block text-sm text-gray-900">
299
+ Gerenciamento de Projetos
300
+ </label>
301
+ </div>
302
+ </div>
303
+ </div>
304
+ `;
305
+ }
306
+
307
+ renderStep3() {
308
+ return `
309
+ <div class="space-y-4">
310
+ <h3 class="text-lg font-semibold">Cobertura e Certificações</h3>
311
+
312
+ <div>
313
+ <label class="text-sm font-medium text-gray-700">Áreas de Cobertura</label>
314
+ <textarea
315
+ name="coverage_area"
316
+ value="${this.formData.coverage_area.join(', ')}"
317
+ onchange="this.getRootNode().host.handleInputChange(event)"
318
+ placeholder="Digite áreas separadas por vírgula, ex: São Paulo, Rio de Janeiro"
319
+ class="mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500 sm:text-sm"
320
+ ></textarea>
321
+ </div>
322
+
323
+ <div>
324
+ <label class="text-sm font-medium text-gray-700">Certificações</label>
325
+ <textarea
326
+ name="certifications"
327
+ value="${this.formData.certifications.join(', ')}"
328
+ onchange="this.getRootNode().host.handleInputChange(event)"
329
+ placeholder="Digite certificações separadas por vírgula, ex: NABCEP, UL, CSA"
330
+ class="mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500 sm:text-sm"
331
+ ></textarea>
332
+ </div>
333
+
334
+ <div>
335
+ <label class="text-sm font-medium text-gray-700">Cobertura de Seguro</label>
336
+ <input
337
+ type="text"
338
+ name="insurance_coverage"
339
+ value="${this.formData.insurance_coverage}"
340
+ onchange="this.getRootNode().host.handleInputChange(event)"
341
+ placeholder="ex: 500k de responsabilidade civil"
342
+ class="mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500 sm:text-sm"
343
+ />
344
+ </div>
345
+
346
+ <div>
347
+ <label class="text-sm font-medium text-gray-700">Garantia Oferecida</label>
348
+ <input
349
+ type="text"
350
+ name="warranty_offered"
351
+ value="${this.formData.warranty_offered}"
352
+ onchange="this.getRootNode().host.handleInputChange(event)"
353
+ placeholder="ex: 20 anos"
354
+ class="mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500 sm:text-sm"
355
+ />
356
+ </div>
357
+ </div>
358
+ `;
359
+ }
360
+
361
+ render() {
362
+ this.shadowRoot.innerHTML = `
363
+ <style>
364
+ @import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');
365
+
366
+ :host {
367
+ display: block;
368
+ font-family: 'Inter', sans-serif;
369
+ }
370
+
371
+ .space-y-4 > * + * {
372
+ margin-top: 1rem;
373
+ }
374
+
375
+ .space-y-6 > * + * {
376
+ margin-top: 1.5rem;
377
+ }
378
+
379
+ .grid {
380
+ display: grid;
381
+ }
382
+
383
+ .gap-4 {
384
+ gap: 1rem;
385
+ }
386
+
387
+ .rounded-md {
388
+ border-radius: 0.375rem;
389
+ }
390
+
391
+ .border-gray-300 {
392
+ border-color: #d1d5db;
393
+ }
394
+
395
+ .focus\\:border-indigo-500:focus {
396
+ border-color: #6366f1;
397
+ }
398
+
399
+ .focus\\:ring-indigo-500:focus {
400
+ --tw-ring-color: #6366f1;
401
+ }
402
+
403
+ .shadow-sm {
404
+ box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
405
+ }
406
+
407
+ .text-sm {
408
+ font-size: 0.875rem;
409
+ line-height: 1.25rem;
410
+ }
411
+
412
+ .text-lg {
413
+ font-size: 1.125rem;
414
+ line-height: 1.75rem;
415
+ }
416
+
417
+ .text-xl {
418
+ font-size: 1.25rem;
419
+ line-height: 1.75rem;
420
+ }
421
+
422
+ .font-semibold {
423
+ font-weight: 600;
424
+ }
425
+
426
+ .font-bold {
427
+ font-weight: 700;
428
+ }
429
+
430
+ .text-gray-700 {
431
+ color: #374151;
432
+ }
433
+
434
+ .text-gray-900 {
435
+ color: #111827;
436
+ }
437
+
438
+ .text-gray-500 {
439
+ color: #6b7280;
440
+ }
441
+
442
+ .text-indigo-600 {
443
+ color: #4f46e5;
444
+ }
445
+
446
+ .bg-gray-200 {
447
+ background-color: #e5e7eb;
448
+ }
449
+
450
+ .bg-blue-600 {
451
+ background-color: #2563eb;
452
+ }
453
+
454
+ .h-2\\.5 {
455
+ height: 0.625rem;
456
+ }
457
+
458
+ .rounded-full {
459
+ border-radius: 9999px;
460
+ }
461
+
462
+ .transition-all {
463
+ transition-property: all;
464
+ }
465
+
466
+ .duration-300 {
467
+ transition-duration: 300ms;
468
+ }
469
+
470
+ .w-full {
471
+ width: 100%;
472
+ }
473
+
474
+ .block {
475
+ display: block;
476
+ }
477
+
478
+ .flex {
479
+ display: flex;
480
+ }
481
+
482
+ .items-center {
483
+ align-items: center;
484
+ }
485
+
486
+ .justify-between {
487
+ justify-content: space-between;
488
+ }
489
+
490
+ .mt-1 {
491
+ margin-top: 0.25rem;
492
+ }
493
+
494
+ .mb-4 {
495
+ margin-bottom: 1rem;
496
+ }
497
+
498
+ .mb-6 {
499
+ margin-bottom: 1.5rem;
500
+ }
501
+
502
+ .ml-2 {
503
+ margin-left: 0.5rem;
504
+ }
505
+
506
+ .pt-4 {
507
+ padding-top: 1rem;
508
+ }
509
+
510
+ .p-6 {
511
+ padding: 1.5rem;
512
+ }
513
+
514
+ .p-8 {
515
+ padding: 2rem;
516
+ }
517
+
518
+ .space-x-3 > * + * {
519
+ margin-left: 0.75rem;
520
+ }
521
+
522
+ @media (min-width: 768px) {
523
+ .md\\:grid-cols-2 {
524
+ grid-template-columns: repeat(2, minmax(0, 1fr));
525
+ }
526
+
527
+ .md\\:grid-cols-3 {
528
+ grid-template-columns: repeat(3, minmax(0, 1fr));
529
+ }
530
+
531
+ .md\\:grid-cols-4 {
532
+ grid-template-columns: repeat(4, minmax(0, 1fr));
533
+ }
534
+ }
535
+ </style>
536
+
537
+ <form class="space-y-6">
538
+ <div class="mb-6">
539
+ <div class="flex items-center justify-between mb-4">
540
+ <h2 class="text-xl font-bold">Registro de Integrador Solar</h2>
541
+ <div class="text-sm text-gray-500">
542
+ Passo ${this.currentStep} de ${this.totalSteps}
543
+ </div>
544
+ </div>
545
+
546
+ <div class="w-full bg-gray-200 rounded-full h-2.5">
547
+ <div
548
+ class="bg-blue-600 h-2.5 rounded-full transition-all duration-300"
549
+ style="width: ${(this.currentStep / this.totalSteps) * 100}%"
550
+ ></div>
551
+ </div>
552
+ </div>
553
+
554
+ ${this.currentStep === 1 ? this.renderStep1() : ''}
555
+ ${this.currentStep === 2 ? this.renderStep2() : ''}
556
+ ${this.currentStep === 3 ? this.renderStep3() : ''}
557
+
558
+ <div class="flex justify-between pt-4">
559
+ <div>
560
+ ${this.currentStep > 1 ? `
561
+ <button
562
+ type="button"
563
+ onclick="this.getRootNode().host.prevStep()"
564
+ class="px-4 py-2 border border-gray-300 rounded-md shadow-sm text-sm font-medium text-gray-700 bg-white hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500"
565
+ >
566
+ Voltar
567
+ </button>
568
+ ` : ''}
569
+ </div>
570
+
571
+ <div class="flex space-x-3">
572
+ ${this.currentStep < this.totalSteps ? `
573
+ <button
574
+ type="button"
575
+ onclick="this.getRootNode().host.nextStep()"
576
+ class="px-4 py-2 border border-transparent rounded-md shadow-sm text-sm font-medium text-white bg-indigo-600 hover:bg-indigo-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500"
577
+ >
578
+ Próximo
579
+ </button>
580
+ ` : `
581
+ <button
582
+ type="button"
583
+ onclick="this.getRootNode().host.dispatchEvent(new CustomEvent('cancel'))"
584
+ class="px-4 py-2 border border-gray-300 rounded-md shadow-sm text-sm font-medium text-gray-700 bg-white hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500"
585
+ >
586
+ Cancelar
587
+ </button>
588
+ <button
589
+ type="button"
590
+ onclick="this.getRootNode().host.dispatchEvent(new CustomEvent('submit', { detail: this.getRootNode().host.formData }))"
591
+ class="px-4 py-2 border border-transparent rounded-md shadow-sm text-sm font-medium text-white bg-indigo-600 hover:bg-indigo-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500"
592
+ >
593
+ Cadastrar
594
+ </button>
595
+ `}
596
+ </div>
597
+ </div>
598
+ </form>
599
+ `;
600
+ }
601
+ }
602
+
603
+ customElements.define('custom-solar-integrator-form', CustomSolarIntegratorForm);
index.html CHANGED
@@ -47,13 +47,12 @@
47
  <div class="min-h-screen flex items-center justify-center p-4">
48
  <div class="w-full max-w-4xl bg-white rounded-xl shadow-lg overflow-hidden">
49
  <div class="p-6 sm:p-8">
50
- <custom-solar-form></custom-solar-form>
51
- </div>
52
  </div>
53
  </div>
54
-
55
- <script src="components/solar-form.js"></script>
56
- <script src="script.js"></script>
57
  <script>feather.replace();</script>
58
  <script src="https://huggingface.co/deepsite/deepsite-badge.js"></script>
59
  </body>
 
47
  <div class="min-h-screen flex items-center justify-center p-4">
48
  <div class="w-full max-w-4xl bg-white rounded-xl shadow-lg overflow-hidden">
49
  <div class="p-6 sm:p-8">
50
+ <custom-solar-integrator-form></custom-solar-integrator-form>
51
+ </div>
52
  </div>
53
  </div>
54
+ <script src="components/solar-integrator-form.js"></script>
55
+ <script src="script.js"></script>
 
56
  <script>feather.replace();</script>
57
  <script src="https://huggingface.co/deepsite/deepsite-badge.js"></script>
58
  </body>