ajustes al formulario de organizaciones

This commit is contained in:
2026-02-23 10:57:45 -04:00
parent 510327de58
commit d71ad98e85
8 changed files with 32 additions and 213 deletions

View File

@@ -99,18 +99,14 @@ export const trainingSurveys = t.pgTable(
.notNull() .notNull()
.default(''), .default(''),
communeSpokespersonCedula: t communeSpokespersonCedula: t
.text('commune_spokesperson_cedula') .text('commune_spokesperson_cedula'),
.notNull()
.default(''),
communeSpokespersonRif: t communeSpokespersonRif: t
.text('commune_spokesperson_rif') .text('commune_spokesperson_rif'),
.notNull()
.default(''),
communeSpokespersonPhone: t communeSpokespersonPhone: t
.text('commune_spokesperson_phone') .text('commune_spokesperson_phone')
.notNull() .notNull()
.default(''), .default(''),
communeEmail: t.text('commune_email').notNull().default(''), communeEmail: t.text('commune_email'),
communalCouncil: t.text('communal_council').notNull(), communalCouncil: t.text('communal_council').notNull(),
siturCodeCommunalCouncil: t.text('situr_code_communal_council').notNull(), siturCodeCommunalCouncil: t.text('situr_code_communal_council').notNull(),
communalCouncilRif: t.text('communal_council_rif').notNull().default(''), communalCouncilRif: t.text('communal_council_rif').notNull().default(''),
@@ -119,13 +115,9 @@ export const trainingSurveys = t.pgTable(
.notNull() .notNull()
.default(''), .default(''),
communalCouncilSpokespersonCedula: t communalCouncilSpokespersonCedula: t
.text('communal_council_spokesperson_cedula') .text('communal_council_spokesperson_cedula'),
.notNull()
.default(''),
communalCouncilSpokespersonRif: t communalCouncilSpokespersonRif: t
.text('communal_council_spokesperson_rif') .text('communal_council_spokesperson_rif'),
.notNull()
.default(''),
communalCouncilSpokespersonPhone: t communalCouncilSpokespersonPhone: t
.text('communal_council_spokesperson_phone') .text('communal_council_spokesperson_phone')
.notNull() .notNull()

View File

@@ -30,11 +30,11 @@ export class CreateTrainingDto {
// === 2. DATOS OSP === // === 2. DATOS OSP ===
@ApiProperty() @ApiProperty()
@IsString() @IsOptional()
ospName: string; ospName: string;
@ApiProperty() @ApiProperty()
@IsString() @IsOptional()
ospRif: string; ospRif: string;
@ApiProperty() @ApiProperty()
@@ -165,20 +165,13 @@ export class CreateTrainingDto {
@IsString() @IsString()
communeSpokespersonName: string; communeSpokespersonName: string;
@ApiProperty()
@IsString()
communeSpokespersonCedula: string;
@ApiProperty()
@IsString()
communeSpokespersonRif: string;
@ApiProperty() @ApiProperty()
@IsString() @IsString()
communeSpokespersonPhone: string; communeSpokespersonPhone: string;
@ApiProperty() @ApiProperty()
@IsString() @IsOptional()
communeEmail: string; communeEmail: string;
@ApiProperty() @ApiProperty()
@@ -197,14 +190,6 @@ export class CreateTrainingDto {
@IsString() @IsString()
communalCouncilSpokespersonName: string; communalCouncilSpokespersonName: string;
@ApiProperty()
@IsString()
communalCouncilSpokespersonCedula: string;
@ApiProperty()
@IsString()
communalCouncilSpokespersonRif: string;
@ApiProperty() @ApiProperty()
@IsString() @IsString()
communalCouncilSpokespersonPhone: string; communalCouncilSpokespersonPhone: string;

View File

@@ -30,14 +30,13 @@ export function EquipmentList() {
const [isOpen, setIsOpen] = useState(false); const [isOpen, setIsOpen] = useState(false);
const [newItem, setNewItem] = useState({ const [newItem, setNewItem] = useState({
machine: '', machine: '',
specifications: '',
quantity: '', quantity: '',
}); });
const handleAdd = () => { const handleAdd = () => {
if (newItem.machine && newItem.quantity) { if (newItem.machine && newItem.quantity) {
append({ ...newItem, quantity: Number(newItem.quantity) }); append({ ...newItem, quantity: Number(newItem.quantity) });
setNewItem({ machine: '', specifications: '', quantity: '' }); setNewItem({ machine: '', quantity: '' });
setIsOpen(false); setIsOpen(false);
} }
}; };
@@ -68,16 +67,6 @@ export function EquipmentList() {
placeholder="Nombre de la maquinaria" placeholder="Nombre de la maquinaria"
/> />
</div> </div>
<div className="space-y-2">
<Label>Especificaciones</Label>
<Input
value={newItem.specifications}
onChange={(e) =>
setNewItem({ ...newItem, specifications: e.target.value })
}
placeholder="Especificaciones técnicas"
/>
</div>
<div className="space-y-2"> <div className="space-y-2">
<Label>Cantidad</Label> <Label>Cantidad</Label>
<Input <Input
@@ -126,14 +115,6 @@ export function EquipmentList() {
{/* @ts-ignore */} {/* @ts-ignore */}
{field.machine} {field.machine}
</TableCell> </TableCell>
<TableCell>
<input
type="hidden"
{...register(`equipmentList.${index}.specifications`)}
/>
{/* @ts-ignore */}
{field.specifications}
</TableCell>
<TableCell> <TableCell>
<input <input
type="hidden" type="hidden"

View File

@@ -118,8 +118,6 @@ export function CreateTrainingForm({
communeName: defaultValues?.communeName || '', communeName: defaultValues?.communeName || '',
communeRif: defaultValues?.communeRif || '', communeRif: defaultValues?.communeRif || '',
communeSpokespersonName: defaultValues?.communeSpokespersonName || '', communeSpokespersonName: defaultValues?.communeSpokespersonName || '',
communeSpokespersonCedula: defaultValues?.communeSpokespersonCedula || '',
communeSpokespersonRif: defaultValues?.communeSpokespersonRif || '',
communeSpokespersonPhone: defaultValues?.communeSpokespersonPhone || '', communeSpokespersonPhone: defaultValues?.communeSpokespersonPhone || '',
communeEmail: defaultValues?.communeEmail || '', communeEmail: defaultValues?.communeEmail || '',
communalCouncil: defaultValues?.communalCouncil || '', communalCouncil: defaultValues?.communalCouncil || '',
@@ -127,10 +125,6 @@ export function CreateTrainingForm({
communalCouncilRif: defaultValues?.communalCouncilRif || '', communalCouncilRif: defaultValues?.communalCouncilRif || '',
communalCouncilSpokespersonName: communalCouncilSpokespersonName:
defaultValues?.communalCouncilSpokespersonName || '', defaultValues?.communalCouncilSpokespersonName || '',
communalCouncilSpokespersonCedula:
defaultValues?.communalCouncilSpokespersonCedula || '',
communalCouncilSpokespersonRif:
defaultValues?.communalCouncilSpokespersonRif || '',
communalCouncilSpokespersonPhone: communalCouncilSpokespersonPhone:
defaultValues?.communalCouncilSpokespersonPhone || '', defaultValues?.communalCouncilSpokespersonPhone || '',
communalCouncilEmail: defaultValues?.communalCouncilEmail || '', communalCouncilEmail: defaultValues?.communalCouncilEmail || '',
@@ -215,27 +209,24 @@ export function CreateTrainingForm({
]; ];
const coorMunicipalityOptions = const coorMunicipalityOptions =
Array.isArray(dataCoorMunicipality?.data) && dataCoorMunicipality?.data?.length
dataCoorMunicipality.data.length > 0
? dataCoorMunicipality.data ? dataCoorMunicipality.data
: [{ id: 0, stateId: 0, name: 'Sin Municipios' }]; : [{ id: 0, stateId: 0, name: 'Sin Municipios' }];
const coorParishOptions = const coorParishOptions =
Array.isArray(dataCoorParish?.data) && dataCoorParish?.data.length > 0 Array.isArray(dataCoorParish?.data) && dataCoorParish?.data?.length
? dataCoorParish.data ? dataCoorParish.data
: [{ id: 0, stateId: 0, name: 'Sin Parroquias' }]; : [{ id: 0, stateId: 0, name: 'Sin Parroquias' }];
const stateOptions = dataState?.data || [{ id: 0, name: 'Sin estados' }]; const stateOptions = dataState?.data || [{ id: 0, name: 'Sin estados' }];
const municipalityOptions = const municipalityOptions = dataMunicipality?.data?.length
Array.isArray(dataMunicipality?.data) && dataMunicipality.data.length > 0 ? dataMunicipality.data
? dataMunicipality.data : [{ id: 0, stateId: 0, name: 'Sin Municipios' }];
: [{ id: 0, stateId: 0, name: 'Sin Municipios' }];
const parishOptions = const parishOptions = dataParish?.data?.length
Array.isArray(dataParish?.data) && dataParish.data.length > 0 ? dataParish.data
? dataParish.data : [{ id: 0, stateId: 0, name: 'Sin Parroquias' }];
: [{ id: 0, stateId: 0, name: 'Sin Parroquias' }];
// No local state needed for existing photos, we use form values // No local state needed for existing photos, we use form values
@@ -727,7 +718,7 @@ export function CreateTrainingForm({
render={({ field }) => ( render={({ field }) => (
<FormItem className="w-full flex flex-col space-y-3"> <FormItem className="w-full flex flex-col space-y-3">
<FormLabel className="whitespace-normal leading-tight font-semibold"> <FormLabel className="whitespace-normal leading-tight font-semibold">
Nombre de la organización Nombre de la organización (opcional)
</FormLabel> </FormLabel>
<FormControl> <FormControl>
<Input {...field} /> <Input {...field} />
@@ -1025,37 +1016,6 @@ export function CreateTrainingForm({
)} )}
/> />
<FormField
control={form.control}
name="communeSpokespersonCedula"
render={({ field }) => (
<FormItem className="w-full flex flex-col space-y-2">
<FormLabel className="font-semibold">
Cédula de Identidad del Vocero
</FormLabel>
<FormControl>
<Input {...field} />
</FormControl>
<FormMessage />
</FormItem>
)}
/>
<FormField
control={form.control}
name="communeSpokespersonRif"
render={({ field }) => (
<FormItem className="w-full flex flex-col space-y-2">
<FormLabel className="font-semibold">
RIF del Vocero
</FormLabel>
<FormControl>
<Input {...field} />
</FormControl>
<FormMessage />
</FormItem>
)}
/>
<FormField <FormField
control={form.control} control={form.control}
@@ -1159,38 +1119,6 @@ export function CreateTrainingForm({
)} )}
/> />
<FormField
control={form.control}
name="communalCouncilSpokespersonCedula"
render={({ field }) => (
<FormItem className="w-full flex flex-col space-y-2">
<FormLabel className="font-semibold">
Cédula de Identidad del Vocero
</FormLabel>
<FormControl>
<Input {...field} />
</FormControl>
<FormMessage />
</FormItem>
)}
/>
<FormField
control={form.control}
name="communalCouncilSpokespersonRif"
render={({ field }) => (
<FormItem className="w-full flex flex-col space-y-2">
<FormLabel className="font-semibold">
RIF del Vocero
</FormLabel>
<FormControl>
<Input {...field} />
</FormControl>
<FormMessage />
</FormItem>
)}
/>
<FormField <FormField
control={form.control} control={form.control}
name="communalCouncilSpokespersonPhone" name="communalCouncilSpokespersonPhone"

View File

@@ -220,76 +220,16 @@ export function ProductActivityList() {
</div> </div>
<hr /> <hr />
<h4 className="font-semibold">Distribución Interna</h4> <h4 className="font-semibold">Zona de Distribucción</h4>
<div className="grid grid-cols-3 gap-4"> <div className="grid grid-cols-1 gap-4">
<div className="space-y-2"> <div className="space-y-2">
<Label>Estado</Label> <Label>Breve Descripción de la Zona de Distribucción</Label>
<SelectSearchable
options={stateOptions.map((s) => ({
value: String(s.id),
label: s.name,
}))}
onValueChange={(val) => {
const id = Number(val);
setInternalStateId(id);
setNewItem({ ...newItem, internalState: id });
}}
placeholder="Estado"
/>
</div>
<div className="space-y-2">
<Label>Municipio</Label>
<SelectSearchable
options={internalMuniOptions.map((s) => ({
value: String(s.id),
label: s.name,
}))}
onValueChange={(val) => {
const id = Number(val);
setInternalMuniId(id);
setNewItem({ ...newItem, internalMunicipality: id });
}}
placeholder="Municipio"
disabled={!internalStateId}
/>
</div>
<div className="space-y-2">
<Label>Parroquia</Label>
<SelectSearchable
options={internalParishOptions.map((s) => ({
value: String(s.id),
label: s.name,
}))}
onValueChange={(val) =>
setNewItem({ ...newItem, internalParish: Number(val) })
}
placeholder="Parroquia"
disabled={!internalMuniId}
/>
</div>
</div>
<div className="grid grid-cols-2 gap-4">
<div className="space-y-2">
<Label>Breve Descripción</Label>
<Input <Input
value={newItem.internalDescription} value={newItem.internalDistributionZone}
onChange={(e) => onChange={(e) =>
setNewItem({ setNewItem({
...newItem, ...newItem,
internalDescription: e.target.value, internalDistributionZone: e.target.value,
})
}
/>
</div>
<div className="space-y-2">
<Label>Cantidad Numérica (Kg, TON, UNID. LT)</Label>
<Input
type="number"
value={newItem.internalQuantity}
onChange={(e) =>
setNewItem({
...newItem,
internalQuantity: e.target.value,
}) })
} }
/> />
@@ -297,7 +237,7 @@ export function ProductActivityList() {
</div> </div>
<hr /> <hr />
<h4 className="font-semibold">Distribución Externa</h4> <h4 className="font-semibold">Exportación</h4>
<div className="grid grid-cols-2 gap-4"> <div className="grid grid-cols-2 gap-4">
<div className="space-y-2"> <div className="space-y-2">
<Label>País</Label> <Label>País</Label>
@@ -397,7 +337,7 @@ export function ProductActivityList() {
/> />
</div> </div>
<div className="space-y-2"> <div className="space-y-2">
<Label>Cantidad Numérica (Kg, TON, UNID. LT)</Label> <Label>Cantidad Numérica (KG, TON, UNID. LT, MTS,QQ, HM2, SACOS)</Label>
<Input <Input
type="number" type="number"
value={newItem.externalQuantity} value={newItem.externalQuantity}

View File

@@ -79,7 +79,7 @@ export function ProductionList() {
/> />
</div> </div>
<div className="space-y-2"> <div className="space-y-2">
<Label>Cantidad Mensual (Kg, TON, UNID. LT)</Label> <Label>Cantidad Mensual (Kg, TON, UNID.LT, MTS,QQ,HM2,SACO)</Label>
<Input <Input
type="number" type="number"
value={newItem.quantity} value={newItem.quantity}

View File

@@ -128,6 +128,8 @@ export const ACTIVIDAD_PRODUCTIVA_MAP: Record<string, string[]> = {
'ELABORACION DE ACEITE COMESTIBLE', 'ELABORACION DE ACEITE COMESTIBLE',
'FABRICA DE HIELO', 'FABRICA DE HIELO',
'ELABORACION DE PAPELON', 'ELABORACION DE PAPELON',
'TORREFACTORA DE CÁFE',
'ESPULPADORA DE TOMATES Y FRUTAS',
'ARTESANIAS', 'ARTESANIAS',
], ],
[ACTIVIDAD_PRINCIPAL.TEXTIL]: [ [ACTIVIDAD_PRINCIPAL.TEXTIL]: [

View File

@@ -10,11 +10,7 @@ const productItemSchema = z.object({
monthlyCount: z.coerce.string().or(z.number()).optional(), monthlyCount: z.coerce.string().or(z.number()).optional(),
// Distribución Interna // Distribución Interna
internalState: z.number().optional(), internalDistributionZone: z.string().optional(),
internalMunicipality: z.number().optional(),
internalParish: z.number().optional(),
internalDescription: z.string().optional(),
internalQuantity: z.coerce.string().or(z.number()).optional(),
// Distribución Externa // Distribución Externa
externalCountry: z.string().optional(), externalCountry: z.string().optional(),
@@ -38,7 +34,6 @@ const productionItemSchema = z.object({
const equipmentItemSchema = z.object({ const equipmentItemSchema = z.object({
machine: z.string(), machine: z.string(),
specifications: z.string().optional(),
quantity: z.coerce.string().or(z.number()).optional(), // Aceptamos string o number por los inputs quantity: z.coerce.string().or(z.number()).optional(), // Aceptamos string o number por los inputs
}); });
@@ -62,7 +57,7 @@ export const trainingSchema = z.object({
.string() .string()
.min(1, { message: 'Actividad productiva es requerida' }), .min(1, { message: 'Actividad productiva es requerida' }),
ospRif: z.string().optional().or(z.literal('')), ospRif: z.string().optional().or(z.literal('')),
ospName: z.string().min(1, { message: 'Nombre de la OSP es requerido' }), ospName: z.string().optional().or(z.literal('')),
companyConstitutionYear: z.coerce companyConstitutionYear: z.coerce
.number() .number()
.min(1900, { message: 'Año inválido' }), .min(1900, { message: 'Año inválido' }),
@@ -98,8 +93,6 @@ export const trainingSchema = z.object({
siturCodeCommune: z.string().optional().or(z.literal('')), siturCodeCommune: z.string().optional().or(z.literal('')),
communeRif: z.string().optional().or(z.literal('')), communeRif: z.string().optional().or(z.literal('')),
communeSpokespersonName: z.string().optional().or(z.literal('')), communeSpokespersonName: z.string().optional().or(z.literal('')),
communeSpokespersonCedula: z.string().optional().or(z.literal('')),
communeSpokespersonRif: z.string().optional().or(z.literal('')),
communeSpokespersonPhone: z.string().optional().or(z.literal('')), communeSpokespersonPhone: z.string().optional().or(z.literal('')),
communeEmail: z communeEmail: z
.string() .string()
@@ -112,8 +105,6 @@ export const trainingSchema = z.object({
siturCodeCommunalCouncil: z.string().optional().or(z.literal('')), siturCodeCommunalCouncil: z.string().optional().or(z.literal('')),
communalCouncilRif: z.string().optional().or(z.literal('')), communalCouncilRif: z.string().optional().or(z.literal('')),
communalCouncilSpokespersonName: z.string().optional().or(z.literal('')), communalCouncilSpokespersonName: z.string().optional().or(z.literal('')),
communalCouncilSpokespersonCedula: z.string().optional().or(z.literal('')),
communalCouncilSpokespersonRif: z.string().optional().or(z.literal('')),
communalCouncilSpokespersonPhone: z.string().optional().or(z.literal('')), communalCouncilSpokespersonPhone: z.string().optional().or(z.literal('')),
communalCouncilEmail: z communalCouncilEmail: z
.string() .string()