cambios en el formulario osp: rol autoridad, campos responsable cambiados, esquema cambiado, añadida columna fecha de creacion a la tabla

This commit is contained in:
2026-03-04 15:07:31 -04:00
parent f910aea3cc
commit d6de7527e4
13 changed files with 4916 additions and 125 deletions

View File

@@ -76,11 +76,10 @@ export function CreateTrainingForm({
const [disabledMunicipality, setDisabledMunicipality] = React.useState(true);
const [disabledParish, setDisabledParish] = React.useState(true);
const [coorState, setcoorState] = React.useState(0);
const [coorMunicipality, setcoorMunicipality] = React.useState(0);
const [disabledCoorMunicipality, setDisabledCoorMunicipality] =
React.useState(true);
const [disabledCoorParish, setDisabledCoorParish] = React.useState(true);
// const [coorState, setcoorState] = React.useState(0);
// const [coorMunicipality, setcoorMunicipality] = React.useState(0);
// const [disabledCoorMunicipality, setDisabledCoorMunicipality] = React.useState(true);
// const [disabledCoorParish, setDisabledCoorParish] = React.useState(true);
const [selectedFiles, setSelectedFiles] = React.useState<File[]>([]);
@@ -107,11 +106,11 @@ export function CreateTrainingForm({
coorParish: defaultValues?.coorParish || undefined,
coorPhone: defaultValues?.coorPhone || '',
visitDate: formatToLocalISO(defaultValues?.visitDate),
productiveActivity: defaultValues?.productiveActivity || '',
productiveActivity: defaultValues?.productiveActivity || undefined,
ecoSector: defaultValues?.ecoSector || undefined,
productiveSector: defaultValues?.productiveSector || undefined,
centralProductiveActivity: defaultValues?.centralProductiveActivity || '',
mainProductiveActivity: defaultValues?.mainProductiveActivity || '',
centralProductiveActivity: defaultValues?.centralProductiveActivity || undefined,
mainProductiveActivity: defaultValues?.mainProductiveActivity || undefined,
photo1: defaultValues?.photo1 || '',
photo2: defaultValues?.photo2 || '',
@@ -149,9 +148,9 @@ export function CreateTrainingForm({
generalObservations: defaultValues?.generalObservations || '',
ospResponsibleEmail: defaultValues?.ospResponsibleEmail || '',
paralysisReason: defaultValues?.paralysisReason || '',
infrastructureMt2: defaultValues?.infrastructureMt2 || '',
infrastructureMt2: defaultValues?.infrastructureMt2 || undefined,
hasTransport: defaultValues?.hasTransport || false,
structureType: defaultValues?.structureType || '',
structureType: defaultValues?.structureType || undefined,
isOpenSpace: defaultValues?.isOpenSpace || false,
equipmentList: defaultValues?.equipmentList || [],
productionList: defaultValues?.productionList || [],
@@ -249,14 +248,14 @@ export function CreateTrainingForm({
setDisabledParish(false);
}
if (defaultValues.coorState) {
setcoorState(Number(defaultValues.coorState));
setDisabledCoorMunicipality(false);
}
if (defaultValues.coorMunicipality) {
setcoorMunicipality(Number(defaultValues.coorMunicipality));
setDisabledCoorParish(false);
}
// if (defaultValues.coorState) {
// setcoorState(Number(defaultValues.coorState));
// setDisabledCoorMunicipality(false);
// }
// if (defaultValues.coorMunicipality) {
// setcoorMunicipality(Number(defaultValues.coorMunicipality));
// setDisabledCoorParish(false);
// }
}
}, [defaultValues]);
@@ -489,13 +488,11 @@ export function CreateTrainingForm({
2. Datos de la Organización Socioproductiva (OSP)
</CardTitle>
</CardHeader>
{/* CAMBIO 1: lg:grid-cols-2 para evitar columnas estrechas en tablets */}
<CardContent className="grid grid-cols-1 lg:grid-cols-2 gap-6 items-start">
<FormField
control={form.control}
name="ospType"
render={({ field }) => (
/* CAMBIO 2: flex flex-col y space-y-3 para forzar separación vertical interna */
<FormItem className="w-full flex flex-col space-y-3">
<FormLabel className="whitespace-normal leading-tight font-semibold">
Tipo de Organización
@@ -1103,7 +1100,7 @@ export function CreateTrainingForm({
name="womenCount"
render={({ field }) => (
<FormItem>
<FormLabel>Mujeres (cantidad)</FormLabel>
<FormLabel>Mujeres (Cantidad opcional)</FormLabel>
<FormControl>
<Input type="number" {...field} />
</FormControl>
@@ -1116,7 +1113,7 @@ export function CreateTrainingForm({
name="menCount"
render={({ field }) => (
<FormItem>
<FormLabel>Hombres (cantidad)</FormLabel>
<FormLabel>Hombres (Cantidad opcional)</FormLabel>
<FormControl>
<Input type="number" {...field} />
</FormControl>
@@ -1155,7 +1152,7 @@ export function CreateTrainingForm({
render={({ field }) => (
<FormItem className="col-span-1 lg:col-span-2 flex flex-col space-y-2">
<FormLabel>
Coordenadas de la Ubicación (Google Maps)
Coordenadas de la Ubicación (Google Maps. Opcional)
</FormLabel>
<FormControl>
<Input
@@ -1211,7 +1208,7 @@ export function CreateTrainingForm({
render={({ field }) => (
<FormItem className="w-full flex flex-col space-y-2">
<FormLabel className="font-semibold">
Rif de la Comuna
Rif de la Comuna (opcional)
</FormLabel>
<FormControl>
<Input {...field} value={field.value ?? ''} />
@@ -1227,7 +1224,7 @@ export function CreateTrainingForm({
render={({ field }) => (
<FormItem className="w-full flex flex-col space-y-2">
<FormLabel className="font-semibold">
Nombre del Vocero o Vocera
Nombre del Vocero o Vocera (opcional)
</FormLabel>
<FormControl>
<Input {...field} value={field.value ?? ''} />
@@ -1243,7 +1240,7 @@ export function CreateTrainingForm({
render={({ field }) => (
<FormItem className="w-full flex flex-col space-y-2">
<FormLabel className="font-semibold">
Número de Teléfono del Vocero
Número de Teléfono del Vocero (opcional)
</FormLabel>
<FormControl>
<Input
@@ -1325,7 +1322,7 @@ export function CreateTrainingForm({
render={({ field }) => (
<FormItem className="w-full flex flex-col space-y-2">
<FormLabel className="font-semibold">
Rif del Consejo Comunal
Rif del Consejo Comunal (opcional)
</FormLabel>
<FormControl>
<Input {...field} value={field.value ?? ''} />
@@ -1341,7 +1338,7 @@ export function CreateTrainingForm({
render={({ field }) => (
<FormItem className="w-full flex flex-col space-y-2">
<FormLabel className="font-semibold">
Nombre del Vocero o Vocera
Nombre del Vocero o Vocera (opcional)
</FormLabel>
<FormControl>
<Input {...field} value={field.value ?? ''} />
@@ -1357,7 +1354,7 @@ export function CreateTrainingForm({
render={({ field }) => (
<FormItem className="w-full flex flex-col space-y-2">
<FormLabel className="font-semibold">
Número de Teléfono del Vocero
Número de Teléfono del Vocero (opcional)
</FormLabel>
<FormControl>
<Input
@@ -1419,9 +1416,31 @@ export function CreateTrainingForm({
<FormField
control={form.control}
name="ospResponsibleFullname"
name="ospResponsiblePhone"
render={({ field }) => (
<FormItem>
<FormLabel>Teléfono</FormLabel>
<FormControl>
<Input
{...field}
value={field.value ?? ''}
placeholder="Ej. 04121234567"
onChange={(e) => {
const val = e.target.value.replace(/\D/g, '');
field.onChange(val.slice(0, 11));
}}
/>
</FormControl>
<FormMessage />
</FormItem>
)}
/>
<FormField
control={form.control}
name="ospResponsibleFullname"
render={({ field }) => (
<FormItem className="col-span-2">
<FormLabel>Nombre y apellido</FormLabel>
<FormControl>
<Input {...field} />
@@ -1431,7 +1450,7 @@ export function CreateTrainingForm({
)}
/>
<FormField
{/* <FormField
control={form.control}
name="ospResponsibleRif"
render={({ field }) => (
@@ -1443,9 +1462,9 @@ export function CreateTrainingForm({
<FormMessage />
</FormItem>
)}
/>
/> */}
<FormField
{/* <FormField
control={form.control}
name="civilState"
render={({ field }) => (
@@ -1471,31 +1490,9 @@ export function CreateTrainingForm({
<FormMessage />
</FormItem>
)}
/>
/> */}
<FormField
control={form.control}
name="ospResponsiblePhone"
render={({ field }) => (
<FormItem>
<FormLabel>Teléfono</FormLabel>
<FormControl>
<Input
{...field}
value={field.value ?? ''}
placeholder="Ej. 04121234567"
onChange={(e) => {
const val = e.target.value.replace(/\D/g, '');
field.onChange(val.slice(0, 11));
}}
/>
</FormControl>
<FormMessage />
</FormItem>
)}
/>
<FormField
{/* <FormField
control={form.control}
name="ospResponsibleEmail"
render={({ field }) => (
@@ -1511,9 +1508,9 @@ export function CreateTrainingForm({
<FormMessage />
</FormItem>
)}
/>
/> */}
<FormField
{/* <FormField
control={form.control}
name="familyBurden"
render={({ field }) => (
@@ -1529,9 +1526,9 @@ export function CreateTrainingForm({
<FormMessage />
</FormItem>
)}
/>
/> */}
<FormField
{/* <FormField
control={form.control}
name="numberOfChildren"
render={({ field }) => (
@@ -1547,7 +1544,7 @@ export function CreateTrainingForm({
<FormMessage />
</FormItem>
)}
/>
/> */}
</CardContent>
</Card>

View File

@@ -22,6 +22,15 @@ export function columns({ apiUrl }: ColumnsProps): ColumnDef<TrainingSchema>[] {
accessorKey: 'ospType',
header: 'Tipo',
},
{
accessorKey: 'created_at',
header: 'Fecha de creación',
cell: ({ row }) => {
// console.log(row.getValue('created_at'));
const date = row.getValue('created_at') as string;
return date ? new Date(date).toLocaleString() : 'N/A';
},
},
{
accessorKey: 'currentStatus',
header: 'Estatus',

View File

@@ -22,17 +22,17 @@ export default function TrainingTableAction() {
setPage={setPage}
/>
</div>{' '}
{['superadmin', 'admin', 'manager', 'coordinators'].includes(
{['superadmin', 'autoridad', 'admin', 'manager', 'coordinators'].includes(
role ?? '',
) && (
<Button
onClick={() => router.push(`/dashboard/formulario/nuevo`)}
size="sm"
>
<Plus className="h-4 w-4" />
<span className="hidden md:inline">Nuevo Registro</span>
</Button>
)}
<Button
onClick={() => router.push(`/dashboard/formulario/nuevo`)}
size="sm"
>
<Plus className="h-4 w-4" />
<span className="hidden md:inline">Nuevo Registro</span>
</Button>
)}
</div>
);
}

View File

@@ -356,10 +356,10 @@ export function TrainingViewModal({
))}
{(!data.equipmentList ||
data.equipmentList.length === 0) && (
<p className="text-sm text-muted-foreground italic">
No hay equipamiento registrado.
</p>
)}
<p className="text-sm text-muted-foreground italic">
No hay equipamiento registrado.
</p>
)}
</CardContent>
</Card>
@@ -389,10 +389,10 @@ export function TrainingViewModal({
))}
{(!data.productionList ||
data.productionList.length === 0) && (
<p className="text-sm text-muted-foreground italic">
No hay materia prima registrada.
</p>
)}
<p className="text-sm text-muted-foreground italic">
No hay materia prima registrada.
</p>
)}
</CardContent>
</Card>
</div>
@@ -438,12 +438,12 @@ export function TrainingViewModal({
label="Teléfono"
value={data.ospResponsiblePhone}
/>
<DetailItem label="Email" value={data.ospResponsibleEmail} />
{/* <DetailItem label="Email" value={data.ospResponsibleEmail} />
<DetailItem
label="Carga Familiar"
value={data.familyBurden}
/>
<DetailItem label="Hijos" value={data.numberOfChildren} />
<DetailItem label="Hijos" value={data.numberOfChildren} /> */}
</Section>
</div>