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,29 +1,30 @@
|
||||
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()
|
||||
export class UsersService {
|
||||
constructor(
|
||||
@Inject(DRIZZLE_PROVIDER) private drizzle: NodePgDatabase<typeof schema>,
|
||||
) { }
|
||||
) {}
|
||||
|
||||
async StateAll(): Promise< State[]> {
|
||||
async StateAll(): Promise<State[]> {
|
||||
const find = await this.drizzle
|
||||
.select()
|
||||
.from(states)
|
||||
.where(ne(states.name, 'EMBAJADA'));
|
||||
|
||||
return find;
|
||||
}
|
||||
|
||||
async MunicioalityAll(id: string): Promise< Municipality[]> {
|
||||
async MunicioalityAll(id: string): Promise<Municipality[]> {
|
||||
const find = await this.drizzle
|
||||
.select()
|
||||
.from(municipalities)
|
||||
@@ -32,7 +33,7 @@ export class UsersService {
|
||||
return find;
|
||||
}
|
||||
|
||||
async ParishAll(id: string): Promise< Parish[]> {
|
||||
async ParishAll(id: string): Promise<Parish[]> {
|
||||
const find = await this.drizzle
|
||||
.select()
|
||||
.from(parishes)
|
||||
@@ -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,26 +691,23 @@ 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>
|
||||
)}
|
||||
/>)}
|
||||
|
||||
{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}
|
||||
@@ -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>
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user