corregido estado, estatus osp
This commit is contained in:
@@ -158,7 +158,7 @@ export const trainingSurveys = t.pgTable(
|
||||
updatedBy: t
|
||||
.integer('updated_by')
|
||||
.references(() => users.id, { onDelete: 'cascade' }),
|
||||
surveyStatus: t.text('survey_status').notNull().default('PUBLICADO'),
|
||||
surveyStatus: t.text('survey_status').notNull().default('COMPLETADA'),
|
||||
...timestamps,
|
||||
},
|
||||
(trainingSurveys) => ({
|
||||
|
||||
@@ -2,7 +2,7 @@ import { DRIZZLE_PROVIDER } from '@/database/drizzle-provider';
|
||||
import * as schema from '@/database/index';
|
||||
import { states } from '@/database/schema/general';
|
||||
import { HttpException, HttpStatus, Inject, Injectable } from '@nestjs/common';
|
||||
import { eq } from 'drizzle-orm';
|
||||
import { and, eq, ne } from 'drizzle-orm';
|
||||
import { NodePgDatabase } from 'drizzle-orm/node-postgres';
|
||||
import { CreateStateDto } from './dto/create-state.dto';
|
||||
import { UpdateStateDto } from './dto/update-state.dto';
|
||||
@@ -15,14 +15,17 @@ export class StatesService {
|
||||
) {}
|
||||
|
||||
async findAll(): Promise<State[]> {
|
||||
return await this.drizzle.select().from(states);
|
||||
return await this.drizzle
|
||||
.select()
|
||||
.from(states)
|
||||
.where(ne(states.name, 'EMBAJADA'));
|
||||
}
|
||||
|
||||
async findOne(id: number): Promise<State> {
|
||||
const state = await this.drizzle
|
||||
.select()
|
||||
.from(states)
|
||||
.where(eq(states.id, id));
|
||||
.where(and(eq(states.id, id), ne(states.name, 'EMBAJADA')));
|
||||
|
||||
if (state.length === 0) {
|
||||
throw new HttpException('State not found', HttpStatus.NOT_FOUND);
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
import { DRIZZLE_PROVIDER } from 'src/database/drizzle-provider';
|
||||
// import { Env, validateString } from '@/common/utils';
|
||||
import { Inject, Injectable, HttpException, HttpStatus, NotFoundException, UnauthorizedException } from '@nestjs/common';
|
||||
import { Inject, Injectable } from '@nestjs/common';
|
||||
import { eq, ne } from 'drizzle-orm';
|
||||
import { NodePgDatabase } from 'drizzle-orm/node-postgres';
|
||||
import * as schema from 'src/database/index';
|
||||
import { states, municipalities, parishes } from 'src/database/index';
|
||||
import { eq, like, or, SQL, sql, and, not } from 'drizzle-orm';
|
||||
import * as bcrypt from 'bcryptjs';
|
||||
import { State, Municipality, Parish } from './entities/user.entity';
|
||||
import { municipalities, parishes, states } from 'src/database/index';
|
||||
|
||||
import { Municipality, Parish, State } from './entities/user.entity';
|
||||
// import { PaginationDto } from '../../common/dto/pagination.dto';
|
||||
|
||||
@Injectable()
|
||||
@@ -19,6 +19,7 @@ export class UsersService {
|
||||
const find = await this.drizzle
|
||||
.select()
|
||||
.from(states)
|
||||
.where(ne(states.name, 'EMBAJADA'));
|
||||
|
||||
return find;
|
||||
}
|
||||
@@ -41,4 +42,3 @@ export class UsersService {
|
||||
return find;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -107,7 +107,8 @@ export function CreateTrainingForm({
|
||||
coorPhone: defaultValues?.coorPhone || '',
|
||||
visitDate: formatToLocalISO(defaultValues?.visitDate),
|
||||
productiveActivity: defaultValues?.productiveActivity || undefined,
|
||||
productiveActivityOther: defaultValues?.productiveActivityOther || undefined,
|
||||
productiveActivityOther:
|
||||
defaultValues?.productiveActivityOther || undefined,
|
||||
ecoSector: defaultValues?.ecoSector || undefined,
|
||||
productiveSector: defaultValues?.productiveSector || undefined,
|
||||
centralProductiveActivity:
|
||||
@@ -172,7 +173,7 @@ export function CreateTrainingForm({
|
||||
|
||||
womenCount: defaultValues?.womenCount || 0,
|
||||
menCount: defaultValues?.menCount || 0,
|
||||
surveyStatus: defaultValues?.surveyStatus || 'BORRADOR'
|
||||
surveyStatus: defaultValues?.surveyStatus || 'BORRADOR',
|
||||
},
|
||||
mode: 'onChange',
|
||||
});
|
||||
@@ -240,7 +241,7 @@ export function CreateTrainingForm({
|
||||
productiveSector,
|
||||
centralProductiveActivity,
|
||||
mainProductiveActivity,
|
||||
productiveActivity
|
||||
productiveActivity,
|
||||
]);
|
||||
|
||||
const stateOptions = dataState?.data || [{ id: 0, name: 'Sin estados' }];
|
||||
@@ -690,8 +691,8 @@ export function CreateTrainingForm({
|
||||
)}
|
||||
/>
|
||||
|
||||
|
||||
{other && (<FormField
|
||||
{other && (
|
||||
<FormField
|
||||
control={form.control}
|
||||
name="productiveActivityOther"
|
||||
render={({ field }) => (
|
||||
@@ -700,16 +701,13 @@ export function CreateTrainingForm({
|
||||
¿Cuál otra Actividad Productiva?
|
||||
</FormLabel>
|
||||
<FormControl>
|
||||
<Input
|
||||
{...field}
|
||||
value={field.value}
|
||||
/>
|
||||
<Input {...field} value={field.value} />
|
||||
</FormControl>
|
||||
<FormMessage />
|
||||
</FormItem>
|
||||
)}
|
||||
/>)}
|
||||
|
||||
/>
|
||||
)}
|
||||
|
||||
<FormField
|
||||
control={form.control}
|
||||
@@ -756,11 +754,7 @@ export function CreateTrainingForm({
|
||||
Año de constitución
|
||||
</FormLabel>
|
||||
<FormControl>
|
||||
<Input
|
||||
type="number"
|
||||
{...field}
|
||||
value={field.value}
|
||||
/>
|
||||
<Input type="number" {...field} value={field.value} />
|
||||
</FormControl>
|
||||
<FormMessage />
|
||||
</FormItem>
|
||||
@@ -1291,11 +1285,7 @@ export function CreateTrainingForm({
|
||||
Correo Electrónico de la Comuna (Opcional)
|
||||
</FormLabel>
|
||||
<FormControl>
|
||||
<Input
|
||||
type="email"
|
||||
{...field}
|
||||
value={field.value}
|
||||
/>
|
||||
<Input type="email" {...field} value={field.value} />
|
||||
</FormControl>
|
||||
<FormMessage />
|
||||
</FormItem>
|
||||
@@ -1405,11 +1395,7 @@ export function CreateTrainingForm({
|
||||
Correo Electrónico del Consejo Comunal (Opcional)
|
||||
</FormLabel>
|
||||
<FormControl>
|
||||
<Input
|
||||
type="email"
|
||||
{...field}
|
||||
value={field.value}
|
||||
/>
|
||||
<Input type="email" {...field} value={field.value} />
|
||||
</FormControl>
|
||||
<FormMessage />
|
||||
</FormItem>
|
||||
@@ -1555,9 +1541,7 @@ export function CreateTrainingForm({
|
||||
</div>
|
||||
|
||||
<div className="flex flex-col gap-2">
|
||||
<FormLabel>
|
||||
Subir imágenes (Máximo 3 y opcional)
|
||||
</FormLabel>
|
||||
<FormLabel>Subir imágenes (Máximo 3 y opcional)</FormLabel>
|
||||
<Input
|
||||
type="file"
|
||||
multiple
|
||||
@@ -1643,13 +1627,8 @@ export function CreateTrainingForm({
|
||||
</CardContent>
|
||||
</Card>
|
||||
|
||||
<div className="grid grid-cols-2 md:grid-cols-3 justify-items-end gap-3 mt-8">
|
||||
<Button
|
||||
variant="outline"
|
||||
type="button"
|
||||
onClick={onCancel}
|
||||
className="w-32 col-span-2 md:col-span-1"
|
||||
>
|
||||
<div className="flex justify-end gap-4">
|
||||
<Button variant="outline" type="button" onClick={onCancel}>
|
||||
Cancelar
|
||||
</Button>
|
||||
|
||||
@@ -1668,8 +1647,10 @@ export function CreateTrainingForm({
|
||||
</SelectTrigger>
|
||||
</FormControl>
|
||||
<SelectContent>
|
||||
<SelectItem defaultChecked value="BORRADOR">BORRADOR</SelectItem>
|
||||
<SelectItem value="PUBLICADO">PUBLICADO</SelectItem>
|
||||
<SelectItem defaultChecked value="BORRADOR">
|
||||
BORRADOR
|
||||
</SelectItem>
|
||||
<SelectItem value="COMPLETADA">COMPLETADA</SelectItem>
|
||||
</SelectContent>
|
||||
</Select>
|
||||
<FormMessage />
|
||||
|
||||
@@ -43,22 +43,13 @@ export function columns({ apiUrl }: ColumnsProps): ColumnDef<TrainingSchema>[] {
|
||||
return date ? new Date(date).toLocaleString() : 'N/A';
|
||||
},
|
||||
},
|
||||
|
||||
{
|
||||
accessorKey: 'visitDate',
|
||||
header: 'Fecha Visita',
|
||||
cell: ({ row }) => {
|
||||
const date = row.getValue('visitDate') as string;
|
||||
return date ? new Date(date).toLocaleString() : 'N/A';
|
||||
},
|
||||
},
|
||||
{
|
||||
accessorKey: 'surveyStatus',
|
||||
header: '',
|
||||
cell: ({ row }) => {
|
||||
const status = row.getValue('surveyStatus') as string;
|
||||
return (
|
||||
<Badge variant={status === 'PUBLICADO' ? 'default' : 'secondary'}>
|
||||
<Badge variant={status === 'COMPLETADA' ? 'success' : 'secondary'}>
|
||||
{status}
|
||||
</Badge>
|
||||
);
|
||||
|
||||
@@ -1,38 +1,40 @@
|
||||
import * as React from "react"
|
||||
import { Slot } from "@radix-ui/react-slot"
|
||||
import { cva, type VariantProps } from "class-variance-authority"
|
||||
import { Slot } from '@radix-ui/react-slot';
|
||||
import { cva, type VariantProps } from 'class-variance-authority';
|
||||
import * as React from 'react';
|
||||
|
||||
import { cn } from "@repo/shadcn/lib/utils"
|
||||
import { cn } from '@repo/shadcn/lib/utils';
|
||||
|
||||
const badgeVariants = cva(
|
||||
"inline-flex items-center justify-center rounded-md border px-2 py-0.5 text-xs font-medium w-fit whitespace-nowrap shrink-0 [&>svg]:size-3 gap-1 [&>svg]:pointer-events-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive transition-[color,box-shadow] overflow-hidden",
|
||||
'inline-flex items-center justify-center rounded-md border px-2 py-0.5 text-xs font-medium w-fit whitespace-nowrap shrink-0 [&>svg]:size-3 gap-1 [&>svg]:pointer-events-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive transition-[color,box-shadow] overflow-hidden',
|
||||
{
|
||||
variants: {
|
||||
variant: {
|
||||
default:
|
||||
"border-transparent bg-primary text-primary-foreground [a&]:hover:bg-primary/90",
|
||||
'border-transparent bg-primary text-primary-foreground [a&]:hover:bg-primary/90',
|
||||
secondary:
|
||||
"border-transparent bg-secondary text-secondary-foreground [a&]:hover:bg-secondary/90",
|
||||
'border-transparent bg-secondary text-secondary-foreground [a&]:hover:bg-secondary/90',
|
||||
destructive:
|
||||
"border-transparent bg-destructive text-white [a&]:hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/70",
|
||||
'border-transparent bg-destructive text-white [a&]:hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/70',
|
||||
outline:
|
||||
"text-foreground [a&]:hover:bg-accent [a&]:hover:text-accent-foreground",
|
||||
'text-foreground [a&]:hover:bg-accent [a&]:hover:text-accent-foreground',
|
||||
success:
|
||||
'border-transparent bg-green-500 text-black [a&]:hover:bg-green-300',
|
||||
},
|
||||
},
|
||||
defaultVariants: {
|
||||
variant: "default",
|
||||
variant: 'default',
|
||||
},
|
||||
}
|
||||
)
|
||||
},
|
||||
);
|
||||
|
||||
function Badge({
|
||||
className,
|
||||
variant,
|
||||
asChild = false,
|
||||
...props
|
||||
}: React.ComponentProps<"span"> &
|
||||
}: React.ComponentProps<'span'> &
|
||||
VariantProps<typeof badgeVariants> & { asChild?: boolean }) {
|
||||
const Comp = asChild ? Slot : "span"
|
||||
const Comp = asChild ? Slot : 'span';
|
||||
|
||||
return (
|
||||
<Comp
|
||||
@@ -40,7 +42,7 @@ function Badge({
|
||||
className={cn(badgeVariants({ variant }), className)}
|
||||
{...props}
|
||||
/>
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
export { Badge, badgeVariants }
|
||||
export { Badge, badgeVariants };
|
||||
|
||||
Reference in New Issue
Block a user