Añadida la opcion "otro" en actividad productiva al registrar y ver los datos de OSP
This commit is contained in:
@@ -107,6 +107,7 @@ export function CreateTrainingForm({
|
||||
coorPhone: defaultValues?.coorPhone || '',
|
||||
visitDate: formatToLocalISO(defaultValues?.visitDate),
|
||||
productiveActivity: defaultValues?.productiveActivity || undefined,
|
||||
productiveActivityOther: defaultValues?.productiveActivityOther || undefined,
|
||||
ecoSector: defaultValues?.ecoSector || undefined,
|
||||
productiveSector: defaultValues?.productiveSector || undefined,
|
||||
centralProductiveActivity:
|
||||
@@ -202,6 +203,11 @@ export function CreateTrainingForm({
|
||||
name: 'mainProductiveActivity',
|
||||
});
|
||||
|
||||
const productiveActivity = useWatch({
|
||||
control: form.control,
|
||||
name: 'productiveActivity',
|
||||
});
|
||||
|
||||
const productiveSectorOptions = ecoSector
|
||||
? SECTOR_PRODUCTIVO_MAP[ecoSector] || []
|
||||
: [];
|
||||
@@ -215,6 +221,8 @@ export function CreateTrainingForm({
|
||||
? ACTIVIDAD_PRODUCTIVA_MAP[mainProductiveActivity] || []
|
||||
: [];
|
||||
|
||||
const other = productiveActivity == 'OTRO' ? true : false;
|
||||
|
||||
// Reset dependent fields when parent changes
|
||||
React.useEffect(() => {
|
||||
// This effect handles shifts in options, but react-hook-form values persist
|
||||
@@ -225,6 +233,7 @@ export function CreateTrainingForm({
|
||||
productiveSector,
|
||||
centralProductiveActivity,
|
||||
mainProductiveActivity,
|
||||
productiveActivity
|
||||
]);
|
||||
|
||||
const stateOptions = dataState?.data || [{ id: 0, name: 'Sin estados' }];
|
||||
@@ -249,15 +258,6 @@ export function CreateTrainingForm({
|
||||
setMunicipality(Number(defaultValues.municipality));
|
||||
setDisabledParish(false);
|
||||
}
|
||||
|
||||
// if (defaultValues.coorState) {
|
||||
// setcoorState(Number(defaultValues.coorState));
|
||||
// setDisabledCoorMunicipality(false);
|
||||
// }
|
||||
// if (defaultValues.coorMunicipality) {
|
||||
// setcoorMunicipality(Number(defaultValues.coorMunicipality));
|
||||
// setDisabledCoorParish(false);
|
||||
// }
|
||||
}
|
||||
}, [defaultValues]);
|
||||
|
||||
@@ -292,16 +292,6 @@ export function CreateTrainingForm({
|
||||
}
|
||||
});
|
||||
|
||||
// 2. Mapeo manual y conversión a numérico
|
||||
// if (formData.state) {
|
||||
// data.append('state', Number(formData.state).toString());
|
||||
// }
|
||||
// if (formData.municipality) {
|
||||
// data.append('municipality', Number(formData.municipality).toString());
|
||||
// }
|
||||
// if (formData.parish) {
|
||||
// data.append('parish', Number(formData.parish).toString());
|
||||
// }
|
||||
if (defaultValues?.id) {
|
||||
data.append('id', defaultValues.id.toString());
|
||||
}
|
||||
@@ -693,6 +683,27 @@ export function CreateTrainingForm({
|
||||
)}
|
||||
/>
|
||||
|
||||
|
||||
{other && (<FormField
|
||||
control={form.control}
|
||||
name="productiveActivityOther"
|
||||
render={({ field }) => (
|
||||
<FormItem className="w-full flex flex-col space-y-3">
|
||||
<FormLabel className="whitespace-normal leading-tight font-semibold">
|
||||
¿Cuál otra Actividad Productiva?
|
||||
</FormLabel>
|
||||
<FormControl>
|
||||
<Input
|
||||
{...field}
|
||||
value={field.value ?? ''}
|
||||
/>
|
||||
</FormControl>
|
||||
<FormMessage />
|
||||
</FormItem>
|
||||
)}
|
||||
/>)}
|
||||
|
||||
|
||||
<FormField
|
||||
control={form.control}
|
||||
name="ospRif"
|
||||
|
||||
Reference in New Issue
Block a user