formulario de capacitacion
This commit is contained in:
@@ -18,8 +18,8 @@ import { MailModule } from './features/mail/mail.module';
|
|||||||
import { RolesModule } from './features/roles/roles.module';
|
import { RolesModule } from './features/roles/roles.module';
|
||||||
import { UserRolesModule } from './features/user-roles/user-roles.module';
|
import { UserRolesModule } from './features/user-roles/user-roles.module';
|
||||||
import { SurveysModule } from './features/surveys/surveys.module';
|
import { SurveysModule } from './features/surveys/surveys.module';
|
||||||
import {InventoryModule} from './features/inventory/inventory.module'
|
import { InventoryModule } from './features/inventory/inventory.module';
|
||||||
import { PicturesModule } from './features/pictures/pictures.module';
|
import { TrainingModule } from './features/training/training.module';
|
||||||
|
|
||||||
@Module({
|
@Module({
|
||||||
providers: [
|
providers: [
|
||||||
@@ -61,7 +61,7 @@ import { PicturesModule } from './features/pictures/pictures.module';
|
|||||||
SurveysModule,
|
SurveysModule,
|
||||||
LocationModule,
|
LocationModule,
|
||||||
InventoryModule,
|
InventoryModule,
|
||||||
PicturesModule
|
TrainingModule
|
||||||
],
|
],
|
||||||
})
|
})
|
||||||
export class AppModule { }
|
export class AppModule { }
|
||||||
|
|||||||
37
apps/api/src/database/migrations/0008_plain_scream.sql
Normal file
37
apps/api/src/database/migrations/0008_plain_scream.sql
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
CREATE TABLE "training_surveys" (
|
||||||
|
"id" serial PRIMARY KEY NOT NULL,
|
||||||
|
"firstname" text NOT NULL,
|
||||||
|
"lastname" text NOT NULL,
|
||||||
|
"visit_date" timestamp NOT NULL,
|
||||||
|
"productive_activity" text NOT NULL,
|
||||||
|
"financial_requirement_description" text NOT NULL,
|
||||||
|
"situr_code_commune" text NOT NULL,
|
||||||
|
"communal_council" text NOT NULL,
|
||||||
|
"situr_code_communal_council" text NOT NULL,
|
||||||
|
"osp_name" text NOT NULL,
|
||||||
|
"osp_address" text NOT NULL,
|
||||||
|
"osp_rif" text NOT NULL,
|
||||||
|
"osp_type" text NOT NULL,
|
||||||
|
"current_status" text NOT NULL,
|
||||||
|
"company_constitution_year" integer NOT NULL,
|
||||||
|
"producer_count" integer NOT NULL,
|
||||||
|
"product_description" text NOT NULL,
|
||||||
|
"installed_capacity" text NOT NULL,
|
||||||
|
"operational_capacity" text NOT NULL,
|
||||||
|
"osp_responsible_fullname" text NOT NULL,
|
||||||
|
"osp_responsible_cedula" text NOT NULL,
|
||||||
|
"osp_responsible_rif" text NOT NULL,
|
||||||
|
"osp_responsible_phone" text NOT NULL,
|
||||||
|
"civil_state" text NOT NULL,
|
||||||
|
"family_burden" integer NOT NULL,
|
||||||
|
"number_of_children" integer NOT NULL,
|
||||||
|
"general_observations" text NOT NULL,
|
||||||
|
"photo1" text NOT NULL,
|
||||||
|
"photo2" text NOT NULL,
|
||||||
|
"photo3" text NOT NULL,
|
||||||
|
"paralysis_reason" text NOT NULL,
|
||||||
|
"created_at" timestamp DEFAULT now() NOT NULL,
|
||||||
|
"updated_at" timestamp (3)
|
||||||
|
);
|
||||||
|
--> statement-breakpoint
|
||||||
|
CREATE INDEX "training_surveys_index_00" ON "training_surveys" USING btree ("firstname");
|
||||||
1778
apps/api/src/database/migrations/meta/0008_snapshot.json
Normal file
1778
apps/api/src/database/migrations/meta/0008_snapshot.json
Normal file
File diff suppressed because it is too large
Load Diff
@@ -57,6 +57,13 @@
|
|||||||
"when": 1754420096323,
|
"when": 1754420096323,
|
||||||
"tag": "0007_curved_fantastic_four",
|
"tag": "0007_curved_fantastic_four",
|
||||||
"breakpoints": true
|
"breakpoints": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"idx": 8,
|
||||||
|
"version": "7",
|
||||||
|
"when": 1764623430844,
|
||||||
|
"tag": "0008_plain_scream",
|
||||||
|
"breakpoints": true
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
@@ -44,7 +44,47 @@ export const answersSurveys = t.pgTable(
|
|||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// Tabla training_surveys
|
||||||
|
export const trainingSurveys = t.pgTable(
|
||||||
|
'training_surveys',
|
||||||
|
{
|
||||||
|
id: t.serial('id').primaryKey(),
|
||||||
|
firstname: t.text('firstname').notNull(),
|
||||||
|
lastname: t.text('lastname').notNull(),
|
||||||
|
visitDate: t.timestamp('visit_date').notNull(),
|
||||||
|
productiveActivity: t.text('productive_activity').notNull(),
|
||||||
|
financialRequirementDescription: t.text('financial_requirement_description').notNull(),
|
||||||
|
siturCodeCommune: t.text('situr_code_commune').notNull(),
|
||||||
|
communalCouncil: t.text('communal_council').notNull(),
|
||||||
|
siturCodeCommunalCouncil: t.text('situr_code_communal_council').notNull(),
|
||||||
|
ospName: t.text('osp_name').notNull(),
|
||||||
|
ospAddress: t.text('osp_address').notNull(),
|
||||||
|
ospRif: t.text('osp_rif').notNull(),
|
||||||
|
ospType: t.text('osp_type').notNull(),
|
||||||
|
currentStatus: t.text('current_status').notNull(),
|
||||||
|
companyConstitutionYear: t.integer('company_constitution_year').notNull(),
|
||||||
|
producerCount: t.integer('producer_count').notNull(),
|
||||||
|
productDescription: t.text('product_description').notNull(),
|
||||||
|
installedCapacity: t.text('installed_capacity').notNull(),
|
||||||
|
operationalCapacity: t.text('operational_capacity').notNull(),
|
||||||
|
ospResponsibleFullname: t.text('osp_responsible_fullname').notNull(),
|
||||||
|
ospResponsibleCedula: t.text('osp_responsible_cedula').notNull(),
|
||||||
|
ospResponsibleRif: t.text('osp_responsible_rif').notNull(),
|
||||||
|
ospResponsiblePhone: t.text('osp_responsible_phone').notNull(),
|
||||||
|
civilState: t.text('civil_state').notNull(),
|
||||||
|
familyBurden: t.integer('family_burden').notNull(),
|
||||||
|
numberOfChildren: t.integer('number_of_children').notNull(),
|
||||||
|
generalObservations: t.text('general_observations').notNull(),
|
||||||
|
photo1: t.text('photo1').notNull(),
|
||||||
|
photo2: t.text('photo2').notNull(),
|
||||||
|
photo3: t.text('photo3').notNull(),
|
||||||
|
paralysisReason: t.text('paralysis_reason').notNull(),
|
||||||
|
...timestamps,
|
||||||
|
},
|
||||||
|
(trainingSurveys) => ({
|
||||||
|
trainingSurveysIndex: t.index('training_surveys_index_00').on(trainingSurveys.firstname),
|
||||||
|
})
|
||||||
|
);
|
||||||
|
|
||||||
export const viewSurveys = t.pgView('v_surveys', {
|
export const viewSurveys = t.pgView('v_surveys', {
|
||||||
surverId: t.integer('survey_id'),
|
surverId: t.integer('survey_id'),
|
||||||
|
|||||||
@@ -89,7 +89,7 @@ export class AuthService {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
secret: envs.access_token_secret,
|
secret: envs.access_token_secret,
|
||||||
expiresIn: envs.access_token_expiration,
|
expiresIn: envs.access_token_expiration as any,
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
this.jwtService.signAsync(
|
this.jwtService.signAsync(
|
||||||
@@ -99,7 +99,7 @@ export class AuthService {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
secret: envs.refresh_token_secret,
|
secret: envs.refresh_token_secret,
|
||||||
expiresIn: envs.refresh_token_expiration,
|
expiresIn: envs.refresh_token_expiration as any,
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
]);
|
]);
|
||||||
|
|||||||
@@ -1,19 +0,0 @@
|
|||||||
import { Controller, Post, UploadedFiles, UseInterceptors, Body } from '@nestjs/common';
|
|
||||||
import { FilesInterceptor } from '@nestjs/platform-express';
|
|
||||||
import { PicturesService } from './pictures.service';
|
|
||||||
|
|
||||||
@Controller('pictures')
|
|
||||||
export class PicturesController {
|
|
||||||
constructor(private readonly picturesService: PicturesService) {}
|
|
||||||
|
|
||||||
@Post('upload')
|
|
||||||
@UseInterceptors(FilesInterceptor('urlImg'))
|
|
||||||
async uploadFile(@UploadedFiles() files: Express.Multer.File[], @Body() body: any) {
|
|
||||||
// Aquí puedes acceder a los campos del formulario
|
|
||||||
// console.log('Archivos:', files);
|
|
||||||
// console.log('Otros campos del formulario:', body);
|
|
||||||
const result = await this.picturesService.saveImages(files);
|
|
||||||
|
|
||||||
return { data: result };
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,10 +0,0 @@
|
|||||||
|
|
||||||
import { Module } from '@nestjs/common';
|
|
||||||
import { PicturesController } from './pictures.controller';
|
|
||||||
import { PicturesService } from './pictures.service';
|
|
||||||
|
|
||||||
@Module({
|
|
||||||
controllers: [PicturesController],
|
|
||||||
providers: [PicturesService],
|
|
||||||
})
|
|
||||||
export class PicturesModule {}
|
|
||||||
@@ -1,41 +0,0 @@
|
|||||||
|
|
||||||
import { Injectable } from '@nestjs/common';
|
|
||||||
import { writeFile } from 'fs/promises';
|
|
||||||
import { join } from 'path';
|
|
||||||
|
|
||||||
@Injectable()
|
|
||||||
export class PicturesService {
|
|
||||||
/**
|
|
||||||
* Guarda una imagen en el directorio de imágenes.
|
|
||||||
* @param file - El archivo de imagen a guardar.
|
|
||||||
* @returns La ruta de la imagen guardada.
|
|
||||||
*/
|
|
||||||
async saveImages(file: Express.Multer.File[]): Promise<string[]> {
|
|
||||||
// Construye la ruta al directorio de imágenes.
|
|
||||||
|
|
||||||
const picturesPath = join(__dirname, '..', '..', '..', '..', 'uploads','pict');
|
|
||||||
|
|
||||||
console.log(picturesPath);
|
|
||||||
|
|
||||||
let images : string[] = [];
|
|
||||||
|
|
||||||
let count = 0;
|
|
||||||
|
|
||||||
file.forEach(async (file) => {
|
|
||||||
count++
|
|
||||||
// Crea un nombre de archivo único para la imagen.
|
|
||||||
const fileName = `${Date.now()}-${count}-${file.originalname}`;
|
|
||||||
images.push(fileName);
|
|
||||||
// console.log(fileName);
|
|
||||||
|
|
||||||
// Construye la ruta completa al archivo de imagen.
|
|
||||||
const filePath = join(picturesPath, fileName);
|
|
||||||
|
|
||||||
// Escribe el archivo de imagen en el disco.
|
|
||||||
await writeFile(filePath, file.buffer);
|
|
||||||
});
|
|
||||||
// Devuelve la ruta de la imagen guardada.
|
|
||||||
// return [file[0].originalname]
|
|
||||||
return images;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
124
apps/api/src/features/training/dto/create-training.dto.ts
Normal file
124
apps/api/src/features/training/dto/create-training.dto.ts
Normal file
@@ -0,0 +1,124 @@
|
|||||||
|
import { ApiProperty } from '@nestjs/swagger';
|
||||||
|
import { IsInt, IsString, IsDateString, IsOptional } from 'class-validator';
|
||||||
|
|
||||||
|
export class CreateTrainingDto {
|
||||||
|
@ApiProperty()
|
||||||
|
@IsString()
|
||||||
|
firstname: string;
|
||||||
|
|
||||||
|
@ApiProperty()
|
||||||
|
@IsString()
|
||||||
|
lastname: string;
|
||||||
|
|
||||||
|
@ApiProperty()
|
||||||
|
@IsDateString()
|
||||||
|
visitDate: Date;
|
||||||
|
|
||||||
|
@ApiProperty()
|
||||||
|
@IsString()
|
||||||
|
productiveActivity: string;
|
||||||
|
|
||||||
|
@ApiProperty()
|
||||||
|
@IsString()
|
||||||
|
financialRequirementDescription: string;
|
||||||
|
|
||||||
|
@ApiProperty()
|
||||||
|
@IsString()
|
||||||
|
siturCodeCommune: string;
|
||||||
|
|
||||||
|
@ApiProperty()
|
||||||
|
@IsString()
|
||||||
|
communalCouncil: string;
|
||||||
|
|
||||||
|
@ApiProperty()
|
||||||
|
@IsString()
|
||||||
|
siturCodeCommunalCouncil: string;
|
||||||
|
|
||||||
|
@ApiProperty()
|
||||||
|
@IsString()
|
||||||
|
ospName: string;
|
||||||
|
|
||||||
|
@ApiProperty()
|
||||||
|
@IsString()
|
||||||
|
ospAddress: string;
|
||||||
|
|
||||||
|
@ApiProperty()
|
||||||
|
@IsString()
|
||||||
|
ospRif: string;
|
||||||
|
|
||||||
|
@ApiProperty()
|
||||||
|
@IsString()
|
||||||
|
ospType: string;
|
||||||
|
|
||||||
|
@ApiProperty()
|
||||||
|
@IsString()
|
||||||
|
currentStatus: string;
|
||||||
|
|
||||||
|
@ApiProperty()
|
||||||
|
@IsInt()
|
||||||
|
companyConstitutionYear: number;
|
||||||
|
|
||||||
|
@ApiProperty()
|
||||||
|
@IsInt()
|
||||||
|
producerCount: number;
|
||||||
|
|
||||||
|
@ApiProperty()
|
||||||
|
@IsString()
|
||||||
|
productDescription: string;
|
||||||
|
|
||||||
|
@ApiProperty()
|
||||||
|
@IsString()
|
||||||
|
installedCapacity: string;
|
||||||
|
|
||||||
|
@ApiProperty()
|
||||||
|
@IsString()
|
||||||
|
operationalCapacity: string;
|
||||||
|
|
||||||
|
@ApiProperty()
|
||||||
|
@IsString()
|
||||||
|
ospResponsibleFullname: string;
|
||||||
|
|
||||||
|
@ApiProperty()
|
||||||
|
@IsString()
|
||||||
|
ospResponsibleCedula: string;
|
||||||
|
|
||||||
|
@ApiProperty()
|
||||||
|
@IsString()
|
||||||
|
ospResponsibleRif: string;
|
||||||
|
|
||||||
|
@ApiProperty()
|
||||||
|
@IsString()
|
||||||
|
ospResponsiblePhone: string;
|
||||||
|
|
||||||
|
@ApiProperty()
|
||||||
|
@IsString()
|
||||||
|
civilState: string;
|
||||||
|
|
||||||
|
@ApiProperty()
|
||||||
|
@IsInt()
|
||||||
|
familyBurden: number;
|
||||||
|
|
||||||
|
@ApiProperty()
|
||||||
|
@IsInt()
|
||||||
|
numberOfChildren: number;
|
||||||
|
|
||||||
|
@ApiProperty()
|
||||||
|
@IsString()
|
||||||
|
generalObservations: string;
|
||||||
|
|
||||||
|
@ApiProperty()
|
||||||
|
@IsString()
|
||||||
|
photo1: string;
|
||||||
|
|
||||||
|
@ApiProperty()
|
||||||
|
@IsString()
|
||||||
|
photo2: string;
|
||||||
|
|
||||||
|
@ApiProperty()
|
||||||
|
@IsString()
|
||||||
|
photo3: string;
|
||||||
|
|
||||||
|
@ApiProperty()
|
||||||
|
@IsString()
|
||||||
|
paralysisReason: string;
|
||||||
|
}
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
import { PartialType } from '@nestjs/swagger';
|
||||||
|
import { CreateTrainingDto } from './create-training.dto';
|
||||||
|
|
||||||
|
export class UpdateTrainingDto extends PartialType(CreateTrainingDto) { }
|
||||||
58
apps/api/src/features/training/training.controller.ts
Normal file
58
apps/api/src/features/training/training.controller.ts
Normal file
@@ -0,0 +1,58 @@
|
|||||||
|
import { Controller, Get, Post, Body, Patch, Param, Delete, Query } from '@nestjs/common';
|
||||||
|
import { TrainingService } from './training.service';
|
||||||
|
import { CreateTrainingDto } from './dto/create-training.dto';
|
||||||
|
import { UpdateTrainingDto } from './dto/update-training.dto';
|
||||||
|
import { ApiOperation, ApiResponse, ApiTags } from '@nestjs/swagger';
|
||||||
|
import { PaginationDto } from '../../common/dto/pagination.dto';
|
||||||
|
|
||||||
|
@ApiTags('training')
|
||||||
|
@Controller('training')
|
||||||
|
export class TrainingController {
|
||||||
|
constructor(private readonly trainingService: TrainingService) { }
|
||||||
|
|
||||||
|
@Get()
|
||||||
|
@ApiOperation({ summary: 'Get all training records with pagination and filters' })
|
||||||
|
@ApiResponse({ status: 200, description: 'Return paginated training records.' })
|
||||||
|
async findAll(@Query() paginationDto: PaginationDto) {
|
||||||
|
const result = await this.trainingService.findAll(paginationDto);
|
||||||
|
return {
|
||||||
|
message: 'Training records fetched successfully',
|
||||||
|
data: result.data,
|
||||||
|
meta: result.meta
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
@Get(':id')
|
||||||
|
@ApiOperation({ summary: 'Get a training record by ID' })
|
||||||
|
@ApiResponse({ status: 200, description: 'Return the training record.' })
|
||||||
|
@ApiResponse({ status: 404, description: 'Training record not found.' })
|
||||||
|
async findOne(@Param('id') id: string) {
|
||||||
|
const data = await this.trainingService.findOne(+id);
|
||||||
|
return { message: 'Training record fetched successfully', data };
|
||||||
|
}
|
||||||
|
|
||||||
|
@Post()
|
||||||
|
@ApiOperation({ summary: 'Create a new training record' })
|
||||||
|
@ApiResponse({ status: 201, description: 'Training record created successfully.' })
|
||||||
|
async create(@Body() createTrainingDto: CreateTrainingDto) {
|
||||||
|
const data = await this.trainingService.create(createTrainingDto);
|
||||||
|
return { message: 'Training record created successfully', data };
|
||||||
|
}
|
||||||
|
|
||||||
|
@Patch(':id')
|
||||||
|
@ApiOperation({ summary: 'Update a training record' })
|
||||||
|
@ApiResponse({ status: 200, description: 'Training record updated successfully.' })
|
||||||
|
@ApiResponse({ status: 404, description: 'Training record not found.' })
|
||||||
|
async update(@Param('id') id: string, @Body() updateTrainingDto: UpdateTrainingDto) {
|
||||||
|
const data = await this.trainingService.update(+id, updateTrainingDto);
|
||||||
|
return { message: 'Training record updated successfully', data };
|
||||||
|
}
|
||||||
|
|
||||||
|
@Delete(':id')
|
||||||
|
@ApiOperation({ summary: 'Delete a training record' })
|
||||||
|
@ApiResponse({ status: 200, description: 'Training record deleted successfully.' })
|
||||||
|
@ApiResponse({ status: 404, description: 'Training record not found.' })
|
||||||
|
async remove(@Param('id') id: string) {
|
||||||
|
return await this.trainingService.remove(+id);
|
||||||
|
}
|
||||||
|
}
|
||||||
10
apps/api/src/features/training/training.module.ts
Normal file
10
apps/api/src/features/training/training.module.ts
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
import { Module } from '@nestjs/common';
|
||||||
|
import { TrainingService } from './training.service';
|
||||||
|
import { TrainingController } from './training.controller';
|
||||||
|
|
||||||
|
@Module({
|
||||||
|
controllers: [TrainingController],
|
||||||
|
providers: [TrainingService],
|
||||||
|
exports: [TrainingService],
|
||||||
|
})
|
||||||
|
export class TrainingModule { }
|
||||||
118
apps/api/src/features/training/training.service.ts
Normal file
118
apps/api/src/features/training/training.service.ts
Normal file
@@ -0,0 +1,118 @@
|
|||||||
|
import { DRIZZLE_PROVIDER } from 'src/database/drizzle-provider';
|
||||||
|
import { Inject, Injectable, HttpException, HttpStatus } from '@nestjs/common';
|
||||||
|
import { NodePgDatabase } from 'drizzle-orm/node-postgres';
|
||||||
|
import * as schema from 'src/database/index';
|
||||||
|
import { trainingSurveys } from 'src/database/index';
|
||||||
|
import { eq, like, or, SQL, sql } from 'drizzle-orm';
|
||||||
|
import { CreateTrainingDto } from './dto/create-training.dto';
|
||||||
|
import { UpdateTrainingDto } from './dto/update-training.dto';
|
||||||
|
import { PaginationDto } from '../../common/dto/pagination.dto';
|
||||||
|
|
||||||
|
@Injectable()
|
||||||
|
export class TrainingService {
|
||||||
|
constructor(
|
||||||
|
@Inject(DRIZZLE_PROVIDER) private drizzle: NodePgDatabase<typeof schema>,
|
||||||
|
) { }
|
||||||
|
|
||||||
|
async findAll(paginationDto?: PaginationDto) {
|
||||||
|
const { page = 1, limit = 10, search = '', sortBy = 'id', sortOrder = 'asc' } = paginationDto || {};
|
||||||
|
|
||||||
|
const offset = (page - 1) * limit;
|
||||||
|
|
||||||
|
let searchCondition: SQL<unknown> | undefined;
|
||||||
|
if (search) {
|
||||||
|
searchCondition = or(
|
||||||
|
like(trainingSurveys.firstname, `%${search}%`),
|
||||||
|
like(trainingSurveys.lastname, `%${search}%`),
|
||||||
|
like(trainingSurveys.ospName, `%${search}%`),
|
||||||
|
like(trainingSurveys.ospRif, `%${search}%`)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
const orderBy = sortOrder === 'asc'
|
||||||
|
? sql`${trainingSurveys[sortBy as keyof typeof trainingSurveys]} asc`
|
||||||
|
: sql`${trainingSurveys[sortBy as keyof typeof trainingSurveys]} desc`;
|
||||||
|
|
||||||
|
const totalCountResult = await this.drizzle
|
||||||
|
.select({ count: sql<number>`count(*)` })
|
||||||
|
.from(trainingSurveys)
|
||||||
|
.where(searchCondition);
|
||||||
|
|
||||||
|
const totalCount = Number(totalCountResult[0].count);
|
||||||
|
const totalPages = Math.ceil(totalCount / limit);
|
||||||
|
|
||||||
|
const data = await this.drizzle
|
||||||
|
.select()
|
||||||
|
.from(trainingSurveys)
|
||||||
|
.where(searchCondition)
|
||||||
|
.orderBy(orderBy)
|
||||||
|
.limit(limit)
|
||||||
|
.offset(offset);
|
||||||
|
|
||||||
|
const meta = {
|
||||||
|
page,
|
||||||
|
limit,
|
||||||
|
totalCount,
|
||||||
|
totalPages,
|
||||||
|
hasNextPage: page < totalPages,
|
||||||
|
hasPreviousPage: page > 1,
|
||||||
|
nextPage: page < totalPages ? page + 1 : null,
|
||||||
|
previousPage: page > 1 ? page - 1 : null,
|
||||||
|
};
|
||||||
|
|
||||||
|
return { data, meta };
|
||||||
|
}
|
||||||
|
|
||||||
|
async findOne(id: number) {
|
||||||
|
const find = await this.drizzle
|
||||||
|
.select()
|
||||||
|
.from(trainingSurveys)
|
||||||
|
.where(eq(trainingSurveys.id, id));
|
||||||
|
|
||||||
|
if (find.length === 0) {
|
||||||
|
throw new HttpException('Training record not found', HttpStatus.NOT_FOUND);
|
||||||
|
}
|
||||||
|
|
||||||
|
return find[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
async create(createTrainingDto: CreateTrainingDto) {
|
||||||
|
const [newRecord] = await this.drizzle
|
||||||
|
.insert(trainingSurveys)
|
||||||
|
.values({
|
||||||
|
...createTrainingDto,
|
||||||
|
visitDate: new Date(createTrainingDto.visitDate),
|
||||||
|
})
|
||||||
|
.returning();
|
||||||
|
|
||||||
|
return newRecord;
|
||||||
|
}
|
||||||
|
|
||||||
|
async update(id: number, updateTrainingDto: UpdateTrainingDto) {
|
||||||
|
await this.findOne(id);
|
||||||
|
|
||||||
|
const updateData: any = { ...updateTrainingDto };
|
||||||
|
if (updateTrainingDto.visitDate) {
|
||||||
|
updateData.visitDate = new Date(updateTrainingDto.visitDate);
|
||||||
|
}
|
||||||
|
|
||||||
|
const [updatedRecord] = await this.drizzle
|
||||||
|
.update(trainingSurveys)
|
||||||
|
.set(updateData)
|
||||||
|
.where(eq(trainingSurveys.id, id))
|
||||||
|
.returning();
|
||||||
|
|
||||||
|
return updatedRecord;
|
||||||
|
}
|
||||||
|
|
||||||
|
async remove(id: number) {
|
||||||
|
await this.findOne(id);
|
||||||
|
|
||||||
|
const [deletedRecord] = await this.drizzle
|
||||||
|
.delete(trainingSurveys)
|
||||||
|
.where(eq(trainingSurveys.id, id))
|
||||||
|
.returning();
|
||||||
|
|
||||||
|
return { message: 'Training record deleted successfully', data: deletedRecord };
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,19 +0,0 @@
|
|||||||
import PageContainer from '@/components/layout/page-container';
|
|
||||||
|
|
||||||
const Page = () => {
|
|
||||||
return (
|
|
||||||
<PageContainer>
|
|
||||||
<div className="flex flex-1 flex-col gap-4 p-4 pt-0">
|
|
||||||
En mantenimiento
|
|
||||||
</div>
|
|
||||||
|
|
||||||
</PageContainer>
|
|
||||||
// <div className="flex min-h-svh flex-col items-center justify-center gap-6 bg-muted p-6 md:p-10">
|
|
||||||
// <div className="flex w-full max-w-sm flex-col gap-6">
|
|
||||||
|
|
||||||
// </div>
|
|
||||||
// </div>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
export default Page;
|
|
||||||
15
apps/web/app/dashboard/formulario/page.tsx
Normal file
15
apps/web/app/dashboard/formulario/page.tsx
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
'use client';
|
||||||
|
|
||||||
|
import PageContainer from '@/components/layout/page-container';
|
||||||
|
import { CreateTrainingForm } from '@/feactures/training/components/form';
|
||||||
|
|
||||||
|
const Page = () => {
|
||||||
|
return (
|
||||||
|
|
||||||
|
<div className="flex flex-1 flex-col gap-4 p-4 pt-0">
|
||||||
|
<CreateTrainingForm />
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default Page;
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
'use client';
|
'use client';
|
||||||
|
|
||||||
import { NavMain as GeneralMain, NavMain as AdministrationMain, NavMain as StatisticsMain, } from '@/components/nav-main';
|
import { NavMain as GeneralMain, NavMain as AdministrationMain, NavMain as StatisticsMain, } from '@/components/nav-main';
|
||||||
import { GeneralItems, AdministrationItems, StatisticsItems } from '@/constants/data';
|
import { GeneralItems, AdministrationItems, StatisticsItems } from '@/constants/routes';
|
||||||
import {
|
import {
|
||||||
Sidebar,
|
Sidebar,
|
||||||
SidebarContent,
|
SidebarContent,
|
||||||
|
|||||||
@@ -18,6 +18,14 @@ export const GeneralItems: NavItem[] = [
|
|||||||
isActive: false,
|
isActive: false,
|
||||||
items: [], // No child items
|
items: [], // No child items
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
title: 'Formulario',
|
||||||
|
url: '/dashboard/formulario/',
|
||||||
|
icon: 'notepadText',
|
||||||
|
shortcut: ['p', 'p'],
|
||||||
|
isActive: false,
|
||||||
|
items: [], // No child items
|
||||||
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
||||||
148
apps/web/feactures/training/actions/actions.ts
Normal file
148
apps/web/feactures/training/actions/actions.ts
Normal file
@@ -0,0 +1,148 @@
|
|||||||
|
'use server';
|
||||||
|
import { safeFetchApi } from '@/lib/fetch.api';
|
||||||
|
import {
|
||||||
|
surveysApiResponseSchema,
|
||||||
|
CreateUser,
|
||||||
|
UsersMutate,
|
||||||
|
UpdateUser
|
||||||
|
} from '../schemas/users';
|
||||||
|
|
||||||
|
import { auth } from '@/lib/auth';
|
||||||
|
|
||||||
|
|
||||||
|
export const getProfileAction = async () => {
|
||||||
|
const session = await auth()
|
||||||
|
const id = session?.user?.id
|
||||||
|
|
||||||
|
const [error, response] = await safeFetchApi(
|
||||||
|
UsersMutate,
|
||||||
|
`/users/${id}`,
|
||||||
|
'GET'
|
||||||
|
);
|
||||||
|
if (error) throw new Error(error.message);
|
||||||
|
return response;
|
||||||
|
};
|
||||||
|
|
||||||
|
export const updateProfileAction = async (payload: UpdateUser) => {
|
||||||
|
const { id, ...payloadWithoutId } = payload;
|
||||||
|
|
||||||
|
const [error, data] = await safeFetchApi(
|
||||||
|
UsersMutate,
|
||||||
|
`/users/profile/${id}`,
|
||||||
|
'PATCH',
|
||||||
|
payloadWithoutId,
|
||||||
|
);
|
||||||
|
|
||||||
|
console.log(payload);
|
||||||
|
if (error) {
|
||||||
|
if (error.message === 'Email already exists') {
|
||||||
|
throw new Error('Ese correo ya está en uso');
|
||||||
|
}
|
||||||
|
// console.error('Error:', error);
|
||||||
|
throw new Error('Error al crear el usuario');
|
||||||
|
}
|
||||||
|
return data;
|
||||||
|
};
|
||||||
|
|
||||||
|
export const getUsersAction = async (params: {
|
||||||
|
page?: number;
|
||||||
|
limit?: number;
|
||||||
|
search?: string;
|
||||||
|
sortBy?: string;
|
||||||
|
sortOrder?: 'asc' | 'desc';
|
||||||
|
}) => {
|
||||||
|
|
||||||
|
const searchParams = new URLSearchParams({
|
||||||
|
page: (params.page || 1).toString(),
|
||||||
|
limit: (params.limit || 10).toString(),
|
||||||
|
...(params.search && { search: params.search }),
|
||||||
|
...(params.sortBy && { sortBy: params.sortBy }),
|
||||||
|
...(params.sortOrder && { sortOrder: params.sortOrder }),
|
||||||
|
});
|
||||||
|
|
||||||
|
const [error, response] = await safeFetchApi(
|
||||||
|
surveysApiResponseSchema,
|
||||||
|
`/users?${searchParams}`,
|
||||||
|
'GET',
|
||||||
|
);
|
||||||
|
|
||||||
|
if (error) throw new Error(error.message);
|
||||||
|
|
||||||
|
// const transformedData = response?.data ? transformSurvey(response?.data) : undefined;
|
||||||
|
|
||||||
|
return {
|
||||||
|
data: response?.data || [],
|
||||||
|
meta: response?.meta || {
|
||||||
|
page: 1,
|
||||||
|
limit: 10,
|
||||||
|
totalCount: 0,
|
||||||
|
totalPages: 1,
|
||||||
|
hasNextPage: false,
|
||||||
|
hasPreviousPage: false,
|
||||||
|
nextPage: null,
|
||||||
|
previousPage: null,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
export const createUserAction = async (payload: CreateUser) => {
|
||||||
|
const { id, confirmPassword, ...payloadWithoutId } = payload;
|
||||||
|
|
||||||
|
const [error, data] = await safeFetchApi(
|
||||||
|
UsersMutate,
|
||||||
|
'/users',
|
||||||
|
'POST',
|
||||||
|
payloadWithoutId,
|
||||||
|
);
|
||||||
|
|
||||||
|
if (error) {
|
||||||
|
if (error.message === 'Username already exists') {
|
||||||
|
throw new Error('Ese usuario ya existe');
|
||||||
|
}
|
||||||
|
if (error.message === 'Email already exists') {
|
||||||
|
throw new Error('Ese correo ya está en uso');
|
||||||
|
}
|
||||||
|
// console.error('Error:', error);
|
||||||
|
throw new Error('Error al crear el usuario');
|
||||||
|
}
|
||||||
|
|
||||||
|
return payloadWithoutId;
|
||||||
|
};
|
||||||
|
|
||||||
|
export const updateUserAction = async (payload: UpdateUser) => {
|
||||||
|
try {
|
||||||
|
const { id, ...payloadWithoutId } = payload;
|
||||||
|
|
||||||
|
const [error, data] = await safeFetchApi(
|
||||||
|
UsersMutate,
|
||||||
|
`/users/${id}`,
|
||||||
|
'PATCH',
|
||||||
|
payloadWithoutId,
|
||||||
|
);
|
||||||
|
|
||||||
|
// console.log(data);
|
||||||
|
if (error) {
|
||||||
|
console.error(error);
|
||||||
|
|
||||||
|
throw new Error(error?.message || 'Error al actualizar el usuario');
|
||||||
|
}
|
||||||
|
return data;
|
||||||
|
} catch (error) {
|
||||||
|
console.error(error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export const deleteUserAction = async (id: Number) => {
|
||||||
|
const [error] = await safeFetchApi(
|
||||||
|
UsersMutate,
|
||||||
|
`/users/${id}`,
|
||||||
|
'DELETE'
|
||||||
|
)
|
||||||
|
|
||||||
|
console.log(error);
|
||||||
|
|
||||||
|
|
||||||
|
// if (error) throw new Error(error.message || 'Error al eliminar el usuario')
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
94
apps/web/feactures/training/actions/training-actions.ts
Normal file
94
apps/web/feactures/training/actions/training-actions.ts
Normal file
@@ -0,0 +1,94 @@
|
|||||||
|
'use server';
|
||||||
|
import { safeFetchApi } from '@/lib/fetch.api';
|
||||||
|
import {
|
||||||
|
TrainingSchema,
|
||||||
|
TrainingMutate,
|
||||||
|
trainingApiResponseSchema
|
||||||
|
} from '../schemas/training';
|
||||||
|
|
||||||
|
export const getTrainingAction = async (params: {
|
||||||
|
page?: number;
|
||||||
|
limit?: number;
|
||||||
|
search?: string;
|
||||||
|
sortBy?: string;
|
||||||
|
sortOrder?: 'asc' | 'desc';
|
||||||
|
}) => {
|
||||||
|
|
||||||
|
const searchParams = new URLSearchParams({
|
||||||
|
page: (params.page || 1).toString(),
|
||||||
|
limit: (params.limit || 10).toString(),
|
||||||
|
...(params.search && { search: params.search }),
|
||||||
|
...(params.sortBy && { sortBy: params.sortBy }),
|
||||||
|
...(params.sortOrder && { sortOrder: params.sortOrder }),
|
||||||
|
});
|
||||||
|
|
||||||
|
const [error, response] = await safeFetchApi(
|
||||||
|
trainingApiResponseSchema,
|
||||||
|
`/training?${searchParams}`,
|
||||||
|
'GET',
|
||||||
|
);
|
||||||
|
|
||||||
|
if (error) throw new Error(error.message);
|
||||||
|
|
||||||
|
return {
|
||||||
|
data: response?.data || [],
|
||||||
|
meta: response?.meta || {
|
||||||
|
page: 1,
|
||||||
|
limit: 10,
|
||||||
|
totalCount: 0,
|
||||||
|
totalPages: 1,
|
||||||
|
hasNextPage: false,
|
||||||
|
hasPreviousPage: false,
|
||||||
|
nextPage: null,
|
||||||
|
previousPage: null,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
export const createTrainingAction = async (payload: TrainingSchema) => {
|
||||||
|
const { id, ...payloadWithoutId } = payload;
|
||||||
|
|
||||||
|
const [error, data] = await safeFetchApi(
|
||||||
|
TrainingMutate,
|
||||||
|
'/training',
|
||||||
|
'POST',
|
||||||
|
payloadWithoutId,
|
||||||
|
);
|
||||||
|
|
||||||
|
if (error) {
|
||||||
|
throw new Error(error.message || 'Error al crear el registro');
|
||||||
|
}
|
||||||
|
|
||||||
|
return data;
|
||||||
|
};
|
||||||
|
|
||||||
|
export const updateTrainingAction = async (payload: TrainingSchema) => {
|
||||||
|
const { id, ...payloadWithoutId } = payload;
|
||||||
|
|
||||||
|
if (!id) throw new Error('ID es requerido para actualizar');
|
||||||
|
|
||||||
|
const [error, data] = await safeFetchApi(
|
||||||
|
TrainingMutate,
|
||||||
|
`/training/${id}`,
|
||||||
|
'PATCH',
|
||||||
|
payloadWithoutId,
|
||||||
|
);
|
||||||
|
|
||||||
|
if (error) {
|
||||||
|
throw new Error(error.message || 'Error al actualizar el registro');
|
||||||
|
}
|
||||||
|
|
||||||
|
return data;
|
||||||
|
};
|
||||||
|
|
||||||
|
export const deleteTrainingAction = async (id: number) => {
|
||||||
|
const [error] = await safeFetchApi(
|
||||||
|
TrainingMutate,
|
||||||
|
`/training/${id}`,
|
||||||
|
'DELETE'
|
||||||
|
)
|
||||||
|
|
||||||
|
if (error) throw new Error(error.message || 'Error al eliminar el registro');
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
431
apps/web/feactures/training/components/form.tsx
Normal file
431
apps/web/feactures/training/components/form.tsx
Normal file
@@ -0,0 +1,431 @@
|
|||||||
|
'use client';
|
||||||
|
|
||||||
|
import { zodResolver } from '@hookform/resolvers/zod';
|
||||||
|
import { Button } from '@repo/shadcn/button';
|
||||||
|
import {
|
||||||
|
Form,
|
||||||
|
FormControl,
|
||||||
|
FormField,
|
||||||
|
FormItem,
|
||||||
|
FormLabel,
|
||||||
|
FormMessage,
|
||||||
|
} from '@repo/shadcn/form';
|
||||||
|
import { Input } from '@repo/shadcn/input';
|
||||||
|
import { Textarea } from '@repo/shadcn/textarea';
|
||||||
|
import {
|
||||||
|
Select,
|
||||||
|
SelectContent,
|
||||||
|
SelectItem,
|
||||||
|
SelectTrigger,
|
||||||
|
SelectValue,
|
||||||
|
} from '@repo/shadcn/select';
|
||||||
|
import { useForm } from 'react-hook-form';
|
||||||
|
import { useCreateTraining } from "../hooks/use-training";
|
||||||
|
import { TrainingSchema, trainingSchema } from '../schemas/training';
|
||||||
|
|
||||||
|
const PRODUCTIVE_ACTIVITIES = [
|
||||||
|
'Agricola',
|
||||||
|
'Textil',
|
||||||
|
'Bloquera',
|
||||||
|
'Carpinteria',
|
||||||
|
'Unidad de suministro'
|
||||||
|
];
|
||||||
|
|
||||||
|
interface CreateTrainingFormProps {
|
||||||
|
onSuccess?: () => void;
|
||||||
|
onCancel?: () => void;
|
||||||
|
defaultValues?: Partial<TrainingSchema>;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function CreateTrainingForm({
|
||||||
|
onSuccess,
|
||||||
|
onCancel,
|
||||||
|
defaultValues,
|
||||||
|
}: CreateTrainingFormProps) {
|
||||||
|
const {
|
||||||
|
mutate: saveTraining,
|
||||||
|
isPending: isSaving,
|
||||||
|
} = useCreateTraining();
|
||||||
|
|
||||||
|
const form = useForm<TrainingSchema>({
|
||||||
|
resolver: zodResolver(trainingSchema),
|
||||||
|
defaultValues: {
|
||||||
|
firstname: defaultValues?.firstname || '',
|
||||||
|
lastname: defaultValues?.lastname || '',
|
||||||
|
visitDate: defaultValues?.visitDate || new Date().toISOString().split('T')[0],
|
||||||
|
productiveActivity: defaultValues?.productiveActivity || '',
|
||||||
|
financialRequirementDescription: defaultValues?.financialRequirementDescription || '',
|
||||||
|
siturCodeCommune: defaultValues?.siturCodeCommune || '',
|
||||||
|
communalCouncil: defaultValues?.communalCouncil || '',
|
||||||
|
siturCodeCommunalCouncil: defaultValues?.siturCodeCommunalCouncil || '',
|
||||||
|
ospName: defaultValues?.ospName || '',
|
||||||
|
ospAddress: defaultValues?.ospAddress || '',
|
||||||
|
ospRif: defaultValues?.ospRif || '',
|
||||||
|
ospType: defaultValues?.ospType || '',
|
||||||
|
currentStatus: defaultValues?.currentStatus || '',
|
||||||
|
companyConstitutionYear: defaultValues?.companyConstitutionYear || new Date().getFullYear(),
|
||||||
|
producerCount: defaultValues?.producerCount || 0,
|
||||||
|
productDescription: defaultValues?.productDescription || '',
|
||||||
|
installedCapacity: defaultValues?.installedCapacity || '',
|
||||||
|
operationalCapacity: defaultValues?.operationalCapacity || '',
|
||||||
|
ospResponsibleFullname: defaultValues?.ospResponsibleFullname || '',
|
||||||
|
ospResponsibleCedula: defaultValues?.ospResponsibleCedula || '',
|
||||||
|
ospResponsibleRif: defaultValues?.ospResponsibleRif || '',
|
||||||
|
ospResponsiblePhone: defaultValues?.ospResponsiblePhone || '',
|
||||||
|
civilState: defaultValues?.civilState || '',
|
||||||
|
familyBurden: defaultValues?.familyBurden || 0,
|
||||||
|
numberOfChildren: defaultValues?.numberOfChildren || 0,
|
||||||
|
generalObservations: defaultValues?.generalObservations || '',
|
||||||
|
photo1: defaultValues?.photo1 || '',
|
||||||
|
photo2: defaultValues?.photo2 || '',
|
||||||
|
photo3: defaultValues?.photo3 || '',
|
||||||
|
paralysisReason: defaultValues?.paralysisReason || '',
|
||||||
|
state: defaultValues?.state || '',
|
||||||
|
municipality: defaultValues?.municipality || '',
|
||||||
|
parish: defaultValues?.parish || '',
|
||||||
|
},
|
||||||
|
mode: 'onChange',
|
||||||
|
});
|
||||||
|
|
||||||
|
const onSubmit = async (formData: TrainingSchema) => {
|
||||||
|
saveTraining(formData, {
|
||||||
|
onSuccess: () => {
|
||||||
|
form.reset();
|
||||||
|
onSuccess?.();
|
||||||
|
},
|
||||||
|
onError: (e) => {
|
||||||
|
console.error(e);
|
||||||
|
form.setError('root', {
|
||||||
|
type: 'manual',
|
||||||
|
message: 'Error al guardar el registro',
|
||||||
|
});
|
||||||
|
},
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Form {...form}>
|
||||||
|
<form onSubmit={form.handleSubmit(onSubmit)} className="space-y-4">
|
||||||
|
{form.formState.errors.root && (
|
||||||
|
<div className="text-destructive text-sm">
|
||||||
|
{form.formState.errors.root.message}
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
|
||||||
|
<div className="grid grid-cols-1 md:grid-cols-2 gap-4">
|
||||||
|
{/* Datos Personales */}
|
||||||
|
<div className="col-span-2">
|
||||||
|
<h3 className="text-lg font-medium mb-2">Datos Básicos</h3>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<FormField control={form.control} name="firstname" render={({ field }) => (
|
||||||
|
<FormItem>
|
||||||
|
<FormLabel>Nombre</FormLabel>
|
||||||
|
<FormControl><Input {...field} /></FormControl>
|
||||||
|
<FormMessage />
|
||||||
|
</FormItem>
|
||||||
|
)} />
|
||||||
|
|
||||||
|
<FormField control={form.control} name="lastname" render={({ field }) => (
|
||||||
|
<FormItem>
|
||||||
|
<FormLabel>Apellido</FormLabel>
|
||||||
|
<FormControl><Input {...field} /></FormControl>
|
||||||
|
<FormMessage />
|
||||||
|
</FormItem>
|
||||||
|
)} />
|
||||||
|
|
||||||
|
<FormField control={form.control} name="visitDate" render={({ field }) => (
|
||||||
|
<FormItem>
|
||||||
|
<FormLabel>Fecha de la visita</FormLabel>
|
||||||
|
<FormControl><Input type="date" {...field} value={field.value ? new Date(field.value).toISOString().split('T')[0] : ''} /></FormControl>
|
||||||
|
<FormMessage />
|
||||||
|
</FormItem>
|
||||||
|
)} />
|
||||||
|
|
||||||
|
{/* Ubicación */}
|
||||||
|
<div className="col-span-2">
|
||||||
|
<h3 className="text-lg font-medium mb-2 mt-4">Ubicación</h3>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<FormField control={form.control} name="state" render={({ field }) => (
|
||||||
|
<FormItem>
|
||||||
|
<FormLabel>Estado</FormLabel>
|
||||||
|
<FormControl><Input {...field} value={field.value || ''} /></FormControl>
|
||||||
|
<FormMessage />
|
||||||
|
</FormItem>
|
||||||
|
)} />
|
||||||
|
|
||||||
|
<FormField control={form.control} name="municipality" render={({ field }) => (
|
||||||
|
<FormItem>
|
||||||
|
<FormLabel>Municipio</FormLabel>
|
||||||
|
<FormControl><Input {...field} value={field.value || ''} /></FormControl>
|
||||||
|
<FormMessage />
|
||||||
|
</FormItem>
|
||||||
|
)} />
|
||||||
|
|
||||||
|
<FormField control={form.control} name="parish" render={({ field }) => (
|
||||||
|
<FormItem>
|
||||||
|
<FormLabel>Parroquia</FormLabel>
|
||||||
|
<FormControl><Input {...field} value={field.value || ''} /></FormControl>
|
||||||
|
<FormMessage />
|
||||||
|
</FormItem>
|
||||||
|
)} />
|
||||||
|
|
||||||
|
<FormField control={form.control} name="siturCodeCommune" render={({ field }) => (
|
||||||
|
<FormItem>
|
||||||
|
<FormLabel>Código SITUR Comuna</FormLabel>
|
||||||
|
<FormControl><Input {...field} /></FormControl>
|
||||||
|
<FormMessage />
|
||||||
|
</FormItem>
|
||||||
|
)} />
|
||||||
|
|
||||||
|
<FormField control={form.control} name="communalCouncil" render={({ field }) => (
|
||||||
|
<FormItem>
|
||||||
|
<FormLabel>Consejo Comunal</FormLabel>
|
||||||
|
<FormControl><Input {...field} /></FormControl>
|
||||||
|
<FormMessage />
|
||||||
|
</FormItem>
|
||||||
|
)} />
|
||||||
|
|
||||||
|
<FormField control={form.control} name="siturCodeCommunalCouncil" render={({ field }) => (
|
||||||
|
<FormItem>
|
||||||
|
<FormLabel>Código SITUR Consejo Comunal</FormLabel>
|
||||||
|
<FormControl><Input {...field} /></FormControl>
|
||||||
|
<FormMessage />
|
||||||
|
</FormItem>
|
||||||
|
)} />
|
||||||
|
|
||||||
|
{/* Datos de la OSP */}
|
||||||
|
<div className="col-span-2">
|
||||||
|
<h3 className="text-lg font-medium mb-2 mt-4">Datos de la Organización Socioproductiva (OSP)</h3>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<FormField control={form.control} name="ospName" render={({ field }) => (
|
||||||
|
<FormItem>
|
||||||
|
<FormLabel>Nombre de la Organización</FormLabel>
|
||||||
|
<FormControl><Input {...field} /></FormControl>
|
||||||
|
<FormMessage />
|
||||||
|
</FormItem>
|
||||||
|
)} />
|
||||||
|
|
||||||
|
<FormField control={form.control} name="ospAddress" render={({ field }) => (
|
||||||
|
<FormItem>
|
||||||
|
<FormLabel>Dirección</FormLabel>
|
||||||
|
<FormControl><Input {...field} /></FormControl>
|
||||||
|
<FormMessage />
|
||||||
|
</FormItem>
|
||||||
|
)} />
|
||||||
|
|
||||||
|
<FormField control={form.control} name="ospRif" render={({ field }) => (
|
||||||
|
<FormItem>
|
||||||
|
<FormLabel>RIF</FormLabel>
|
||||||
|
<FormControl><Input {...field} /></FormControl>
|
||||||
|
<FormMessage />
|
||||||
|
</FormItem>
|
||||||
|
)} />
|
||||||
|
|
||||||
|
<FormField control={form.control} name="ospType" render={({ field }) => (
|
||||||
|
<FormItem>
|
||||||
|
<FormLabel>Tipo de Organización</FormLabel>
|
||||||
|
<FormControl><Input {...field} /></FormControl>
|
||||||
|
<FormMessage />
|
||||||
|
</FormItem>
|
||||||
|
)} />
|
||||||
|
|
||||||
|
<FormField control={form.control} name="productiveActivity" render={({ field }) => (
|
||||||
|
<FormItem>
|
||||||
|
<FormLabel>Actividad Productiva</FormLabel>
|
||||||
|
<Select onValueChange={field.onChange} defaultValue={field.value}>
|
||||||
|
<FormControl>
|
||||||
|
<SelectTrigger>
|
||||||
|
<SelectValue placeholder="Seleccione actividad" />
|
||||||
|
</SelectTrigger>
|
||||||
|
</FormControl>
|
||||||
|
<SelectContent>
|
||||||
|
{PRODUCTIVE_ACTIVITIES.map((activity) => (
|
||||||
|
<SelectItem key={activity} value={activity}>
|
||||||
|
{activity}
|
||||||
|
</SelectItem>
|
||||||
|
))}
|
||||||
|
</SelectContent>
|
||||||
|
</Select>
|
||||||
|
<FormMessage />
|
||||||
|
</FormItem>
|
||||||
|
)} />
|
||||||
|
|
||||||
|
<FormField control={form.control} name="currentStatus" render={({ field }) => (
|
||||||
|
<FormItem>
|
||||||
|
<FormLabel>Estatus Actual</FormLabel>
|
||||||
|
<FormControl><Input {...field} /></FormControl>
|
||||||
|
<FormMessage />
|
||||||
|
</FormItem>
|
||||||
|
)} />
|
||||||
|
|
||||||
|
<FormField control={form.control} name="companyConstitutionYear" render={({ field }) => (
|
||||||
|
<FormItem>
|
||||||
|
<FormLabel>Año de Constitución</FormLabel>
|
||||||
|
<FormControl><Input type="number" {...field} /></FormControl>
|
||||||
|
<FormMessage />
|
||||||
|
</FormItem>
|
||||||
|
)} />
|
||||||
|
|
||||||
|
<FormField control={form.control} name="producerCount" render={({ field }) => (
|
||||||
|
<FormItem>
|
||||||
|
<FormLabel>Cantidad de Productores</FormLabel>
|
||||||
|
<FormControl><Input type="number" {...field} /></FormControl>
|
||||||
|
<FormMessage />
|
||||||
|
</FormItem>
|
||||||
|
)} />
|
||||||
|
|
||||||
|
<FormField control={form.control} name="productDescription" render={({ field }) => (
|
||||||
|
<FormItem className="col-span-2">
|
||||||
|
<FormLabel>Breve descripción del producto o servicio</FormLabel>
|
||||||
|
<FormControl><Textarea {...field} /></FormControl>
|
||||||
|
<FormMessage />
|
||||||
|
</FormItem>
|
||||||
|
)} />
|
||||||
|
|
||||||
|
<FormField control={form.control} name="installedCapacity" render={({ field }) => (
|
||||||
|
<FormItem>
|
||||||
|
<FormLabel>Capacidad Instalada</FormLabel>
|
||||||
|
<FormControl><Input {...field} /></FormControl>
|
||||||
|
<FormMessage />
|
||||||
|
</FormItem>
|
||||||
|
)} />
|
||||||
|
|
||||||
|
<FormField control={form.control} name="operationalCapacity" render={({ field }) => (
|
||||||
|
<FormItem>
|
||||||
|
<FormLabel>Capacidad Operativa</FormLabel>
|
||||||
|
<FormControl><Input {...field} /></FormControl>
|
||||||
|
<FormMessage />
|
||||||
|
</FormItem>
|
||||||
|
)} />
|
||||||
|
|
||||||
|
<FormField control={form.control} name="financialRequirementDescription" render={({ field }) => (
|
||||||
|
<FormItem className="col-span-2">
|
||||||
|
<FormLabel>Descripción del Requerimiento Financiero</FormLabel>
|
||||||
|
<FormControl><Textarea {...field} /></FormControl>
|
||||||
|
<FormMessage />
|
||||||
|
</FormItem>
|
||||||
|
)} />
|
||||||
|
|
||||||
|
<FormField control={form.control} name="paralysisReason" render={({ field }) => (
|
||||||
|
<FormItem className="col-span-2">
|
||||||
|
<FormLabel>Razones de paralización (si aplica)</FormLabel>
|
||||||
|
<FormControl><Textarea {...field} /></FormControl>
|
||||||
|
<FormMessage />
|
||||||
|
</FormItem>
|
||||||
|
)} />
|
||||||
|
|
||||||
|
{/* Responsable */}
|
||||||
|
<div className="col-span-2">
|
||||||
|
<h3 className="text-lg font-medium mb-2 mt-4">Datos del Responsable</h3>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<FormField control={form.control} name="ospResponsibleFullname" render={({ field }) => (
|
||||||
|
<FormItem>
|
||||||
|
<FormLabel>Nombre y Apellido</FormLabel>
|
||||||
|
<FormControl><Input {...field} /></FormControl>
|
||||||
|
<FormMessage />
|
||||||
|
</FormItem>
|
||||||
|
)} />
|
||||||
|
|
||||||
|
<FormField control={form.control} name="ospResponsibleCedula" render={({ field }) => (
|
||||||
|
<FormItem>
|
||||||
|
<FormLabel>Cédula (sin puntos)</FormLabel>
|
||||||
|
<FormControl><Input {...field} /></FormControl>
|
||||||
|
<FormMessage />
|
||||||
|
</FormItem>
|
||||||
|
)} />
|
||||||
|
|
||||||
|
<FormField control={form.control} name="ospResponsibleRif" render={({ field }) => (
|
||||||
|
<FormItem>
|
||||||
|
<FormLabel>RIF (sin puntos)</FormLabel>
|
||||||
|
<FormControl><Input {...field} /></FormControl>
|
||||||
|
<FormMessage />
|
||||||
|
</FormItem>
|
||||||
|
)} />
|
||||||
|
|
||||||
|
<FormField control={form.control} name="ospResponsiblePhone" render={({ field }) => (
|
||||||
|
<FormItem>
|
||||||
|
<FormLabel>Teléfonos (2 números)</FormLabel>
|
||||||
|
<FormControl><Input {...field} /></FormControl>
|
||||||
|
<FormMessage />
|
||||||
|
</FormItem>
|
||||||
|
)} />
|
||||||
|
|
||||||
|
<FormField control={form.control} name="civilState" render={({ field }) => (
|
||||||
|
<FormItem>
|
||||||
|
<FormLabel>Estado Civil</FormLabel>
|
||||||
|
<FormControl><Input {...field} /></FormControl>
|
||||||
|
<FormMessage />
|
||||||
|
</FormItem>
|
||||||
|
)} />
|
||||||
|
|
||||||
|
<FormField control={form.control} name="familyBurden" render={({ field }) => (
|
||||||
|
<FormItem>
|
||||||
|
<FormLabel>Carga Familiar</FormLabel>
|
||||||
|
<FormControl><Input type="number" {...field} /></FormControl>
|
||||||
|
<FormMessage />
|
||||||
|
</FormItem>
|
||||||
|
)} />
|
||||||
|
|
||||||
|
<FormField control={form.control} name="numberOfChildren" render={({ field }) => (
|
||||||
|
<FormItem>
|
||||||
|
<FormLabel>Número de Hijos</FormLabel>
|
||||||
|
<FormControl><Input type="number" {...field} /></FormControl>
|
||||||
|
<FormMessage />
|
||||||
|
</FormItem>
|
||||||
|
)} />
|
||||||
|
|
||||||
|
<FormField control={form.control} name="generalObservations" render={({ field }) => (
|
||||||
|
<FormItem className="col-span-2">
|
||||||
|
<FormLabel>Observaciones Generales</FormLabel>
|
||||||
|
<FormControl><Textarea {...field} /></FormControl>
|
||||||
|
<FormMessage />
|
||||||
|
</FormItem>
|
||||||
|
)} />
|
||||||
|
|
||||||
|
{/* Fotos */}
|
||||||
|
<div className="col-span-2">
|
||||||
|
<h3 className="text-lg font-medium mb-2 mt-4">Registro Fotográfico (URLs)</h3>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<FormField control={form.control} name="photo1" render={({ field }) => (
|
||||||
|
<FormItem>
|
||||||
|
<FormLabel>Foto 1</FormLabel>
|
||||||
|
<FormControl><Input {...field} placeholder="URL de la imagen" /></FormControl>
|
||||||
|
<FormMessage />
|
||||||
|
</FormItem>
|
||||||
|
)} />
|
||||||
|
|
||||||
|
<FormField control={form.control} name="photo2" render={({ field }) => (
|
||||||
|
<FormItem>
|
||||||
|
<FormLabel>Foto 2</FormLabel>
|
||||||
|
<FormControl><Input {...field} placeholder="URL de la imagen" /></FormControl>
|
||||||
|
<FormMessage />
|
||||||
|
</FormItem>
|
||||||
|
)} />
|
||||||
|
|
||||||
|
<FormField control={form.control} name="photo3" render={({ field }) => (
|
||||||
|
<FormItem>
|
||||||
|
<FormLabel>Foto 3</FormLabel>
|
||||||
|
<FormControl><Input {...field} placeholder="URL de la imagen" /></FormControl>
|
||||||
|
<FormMessage />
|
||||||
|
</FormItem>
|
||||||
|
)} />
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="flex justify-end gap-4 mt-6">
|
||||||
|
<Button variant="outline" type="button" onClick={onCancel}>
|
||||||
|
Cancelar
|
||||||
|
</Button>
|
||||||
|
<Button type="submit" disabled={isSaving}>
|
||||||
|
{isSaving ? 'Guardando...' : 'Guardar'}
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</Form>
|
||||||
|
);
|
||||||
|
}
|
||||||
45
apps/web/feactures/training/hooks/use-mutation-users.ts
Normal file
45
apps/web/feactures/training/hooks/use-mutation-users.ts
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
import { useMutation, useQueryClient } from "@tanstack/react-query";
|
||||||
|
import { CreateUser, UpdateUser } from "../schemas/users";
|
||||||
|
import { updateUserAction, createUserAction, deleteUserAction, updateProfileAction } from "../actions/actions";
|
||||||
|
|
||||||
|
// Create mutation
|
||||||
|
export function useCreateUser() {
|
||||||
|
const queryClient = useQueryClient();
|
||||||
|
const mutation = useMutation({
|
||||||
|
mutationFn: (data: CreateUser) => createUserAction(data),
|
||||||
|
onSuccess: () => queryClient.invalidateQueries({ queryKey: ['users'] }),
|
||||||
|
// onError: (e) => console.error('Error:', e),
|
||||||
|
})
|
||||||
|
return mutation
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update mutation
|
||||||
|
export function useUpdateUser() {
|
||||||
|
const queryClient = useQueryClient();
|
||||||
|
const mutation = useMutation({
|
||||||
|
mutationFn: (data: UpdateUser) => updateUserAction(data),
|
||||||
|
onSuccess: () => queryClient.invalidateQueries({ queryKey: ['users'] }),
|
||||||
|
onError: (e) => console.error('Error:', e)
|
||||||
|
})
|
||||||
|
return mutation;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function useUpdateProfile() {
|
||||||
|
const queryClient = useQueryClient();
|
||||||
|
const mutation = useMutation({
|
||||||
|
mutationFn: (data: UpdateUser) => updateProfileAction(data),
|
||||||
|
onSuccess: () => queryClient.invalidateQueries({ queryKey: ['users'] }),
|
||||||
|
// onError: (e) => console.error('Error:', e)
|
||||||
|
})
|
||||||
|
return mutation;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Delete mutation
|
||||||
|
export function useDeleteUser() {
|
||||||
|
const queryClient = useQueryClient();
|
||||||
|
return useMutation({
|
||||||
|
mutationFn: (id: number) => deleteUserAction(id),
|
||||||
|
onSuccess: () => queryClient.invalidateQueries({ queryKey: ['users'] }),
|
||||||
|
onError: (e) => console.error('Error:', e)
|
||||||
|
})
|
||||||
|
}
|
||||||
29
apps/web/feactures/training/hooks/use-training.ts
Normal file
29
apps/web/feactures/training/hooks/use-training.ts
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
import { useMutation, useQueryClient } from "@tanstack/react-query";
|
||||||
|
import { TrainingSchema } from "../schemas/training";
|
||||||
|
import { createTrainingAction, updateTrainingAction, deleteTrainingAction } from "../actions/training-actions";
|
||||||
|
|
||||||
|
export function useCreateTraining() {
|
||||||
|
const queryClient = useQueryClient();
|
||||||
|
const mutation = useMutation({
|
||||||
|
mutationFn: (data: TrainingSchema) => createTrainingAction(data),
|
||||||
|
onSuccess: () => queryClient.invalidateQueries({ queryKey: ['training'] }),
|
||||||
|
})
|
||||||
|
return mutation
|
||||||
|
}
|
||||||
|
|
||||||
|
export function useUpdateTraining() {
|
||||||
|
const queryClient = useQueryClient();
|
||||||
|
const mutation = useMutation({
|
||||||
|
mutationFn: (data: TrainingSchema) => updateTrainingAction(data),
|
||||||
|
onSuccess: () => queryClient.invalidateQueries({ queryKey: ['training'] }),
|
||||||
|
})
|
||||||
|
return mutation;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function useDeleteTraining() {
|
||||||
|
const queryClient = useQueryClient();
|
||||||
|
return useMutation({
|
||||||
|
mutationFn: (id: number) => deleteTrainingAction(id),
|
||||||
|
onSuccess: () => queryClient.invalidateQueries({ queryKey: ['training'] }),
|
||||||
|
})
|
||||||
|
}
|
||||||
60
apps/web/feactures/training/schemas/training.ts
Normal file
60
apps/web/feactures/training/schemas/training.ts
Normal file
@@ -0,0 +1,60 @@
|
|||||||
|
import { z } from 'zod';
|
||||||
|
|
||||||
|
export const trainingSchema = z.object({
|
||||||
|
id: z.number().optional(),
|
||||||
|
firstname: z.string().min(1, { message: "Nombre es requerido" }),
|
||||||
|
lastname: z.string().min(1, { message: "Apellido es requerido" }),
|
||||||
|
visitDate: z.string().or(z.date()).transform((val) => new Date(val).toISOString()),
|
||||||
|
productiveActivity: z.string().min(1, { message: "Actividad productiva es requerida" }),
|
||||||
|
financialRequirementDescription: z.string().min(1, { message: "Descripción es requerida" }),
|
||||||
|
siturCodeCommune: z.string().min(1, { message: "Código SITUR Comuna es requerido" }),
|
||||||
|
communalCouncil: z.string().min(1, { message: "Consejo Comunal es requerido" }),
|
||||||
|
siturCodeCommunalCouncil: z.string().min(1, { message: "Código SITUR Consejo Comunal es requerido" }),
|
||||||
|
ospName: z.string().min(1, { message: "Nombre de la OSP es requerido" }),
|
||||||
|
ospAddress: z.string().min(1, { message: "Dirección de la OSP es requerida" }),
|
||||||
|
ospRif: z.string().min(1, { message: "RIF de la OSP es requerido" }),
|
||||||
|
ospType: z.string().min(1, { message: "Tipo de OSP es requerido" }),
|
||||||
|
currentStatus: z.string().min(1, { message: "Estatus actual es requerido" }),
|
||||||
|
companyConstitutionYear: z.coerce.number().min(1900, { message: "Año inválido" }),
|
||||||
|
producerCount: z.coerce.number().min(1, { message: "Cantidad de productores requerida" }),
|
||||||
|
productDescription: z.string().min(1, { message: "Descripción del producto es requerida" }),
|
||||||
|
installedCapacity: z.string().min(1, { message: "Capacidad instalada es requerida" }),
|
||||||
|
operationalCapacity: z.string().min(1, { message: "Capacidad operativa es requerida" }),
|
||||||
|
ospResponsibleFullname: z.string().min(1, { message: "Nombre del responsable es requerido" }),
|
||||||
|
ospResponsibleCedula: z.string().min(1, { message: "Cédula del responsable es requerida" }),
|
||||||
|
ospResponsibleRif: z.string().min(1, { message: "RIF del responsable es requerido" }),
|
||||||
|
ospResponsiblePhone: z.string().min(1, { message: "Teléfono del responsable es requerido" }),
|
||||||
|
civilState: z.string().min(1, { message: "Estado civil es requerido" }),
|
||||||
|
familyBurden: z.coerce.number().min(0, { message: "Carga familiar requerida" }),
|
||||||
|
numberOfChildren: z.coerce.number().min(0, { message: "Número de hijos requerido" }),
|
||||||
|
generalObservations: z.string().optional().default(''),
|
||||||
|
photo1: z.string().optional().default(''),
|
||||||
|
photo2: z.string().optional().default(''),
|
||||||
|
photo3: z.string().optional().default(''),
|
||||||
|
paralysisReason: z.string().optional().default(''),
|
||||||
|
state: z.string().optional().nullable(),
|
||||||
|
municipality: z.string().optional().nullable(),
|
||||||
|
parish: z.string().optional().nullable(),
|
||||||
|
});
|
||||||
|
|
||||||
|
export type TrainingSchema = z.infer<typeof trainingSchema>;
|
||||||
|
|
||||||
|
export const trainingApiResponseSchema = z.object({
|
||||||
|
message: z.string(),
|
||||||
|
data: z.array(trainingSchema),
|
||||||
|
meta: z.object({
|
||||||
|
page: z.number(),
|
||||||
|
limit: z.number(),
|
||||||
|
totalCount: z.number(),
|
||||||
|
totalPages: z.number(),
|
||||||
|
hasNextPage: z.boolean(),
|
||||||
|
hasPreviousPage: z.boolean(),
|
||||||
|
nextPage: z.number().nullable(),
|
||||||
|
previousPage: z.number().nullable(),
|
||||||
|
}),
|
||||||
|
});
|
||||||
|
|
||||||
|
export const TrainingMutate = z.object({
|
||||||
|
message: z.string(),
|
||||||
|
data: trainingSchema,
|
||||||
|
});
|
||||||
67
apps/web/feactures/training/schemas/users.ts
Normal file
67
apps/web/feactures/training/schemas/users.ts
Normal file
@@ -0,0 +1,67 @@
|
|||||||
|
import { z } from 'zod';
|
||||||
|
|
||||||
|
export type SurveyTable = z.infer<typeof user>;
|
||||||
|
export type CreateUser = z.infer<typeof createUser>;
|
||||||
|
export type UpdateUser = z.infer<typeof updateUser>;
|
||||||
|
|
||||||
|
export const user = z.object({
|
||||||
|
id: z.number().optional(),
|
||||||
|
username: z.string(),
|
||||||
|
email: z.string(),
|
||||||
|
fullname: z.string(),
|
||||||
|
phone: z.string().nullable(),
|
||||||
|
isActive: z.boolean(),
|
||||||
|
role: z.string(),
|
||||||
|
state: z.string().optional().nullable(),
|
||||||
|
municipality: z.string().optional().nullable(),
|
||||||
|
parish: z.string().optional().nullable(),
|
||||||
|
});
|
||||||
|
|
||||||
|
export const createUser = z.object({
|
||||||
|
id: z.number().optional(),
|
||||||
|
username: z.string().min(5, { message: "Debe de tener 5 o más caracteres" }),
|
||||||
|
password: z.string().min(8, { message: "Debe de tener 8 o más caracteres" }),
|
||||||
|
email: z.string().email({ message: "Correo no válido" }),
|
||||||
|
fullname: z.string(),
|
||||||
|
phone: z.string(),
|
||||||
|
confirmPassword: z.string(),
|
||||||
|
role: z.number()
|
||||||
|
})
|
||||||
|
.refine((data) => data.password === data.confirmPassword, {
|
||||||
|
message: 'La contraseña no coincide',
|
||||||
|
path: ['confirmPassword'],
|
||||||
|
})
|
||||||
|
|
||||||
|
export const updateUser = z.object({
|
||||||
|
id: z.number(),
|
||||||
|
username: z.string().min(5, { message: "Debe de tener 5 o más caracteres" }).or(z.literal('')),
|
||||||
|
password: z.string().min(6, { message: "Debe de tener 6 o más caracteres" }).or(z.literal('')),
|
||||||
|
email: z.string().email({ message: "Correo no válido" }).or(z.literal('')),
|
||||||
|
fullname: z.string().optional(),
|
||||||
|
phone: z.string().optional(),
|
||||||
|
role: z.number().optional(),
|
||||||
|
isActive: z.boolean().optional(),
|
||||||
|
state: z.number().optional().nullable(),
|
||||||
|
municipality: z.number().optional().nullable(),
|
||||||
|
parish: z.number().optional().nullable(),
|
||||||
|
})
|
||||||
|
|
||||||
|
export const surveysApiResponseSchema = z.object({
|
||||||
|
message: z.string(),
|
||||||
|
data: z.array(user),
|
||||||
|
meta: z.object({
|
||||||
|
page: z.number(),
|
||||||
|
limit: z.number(),
|
||||||
|
totalCount: z.number(),
|
||||||
|
totalPages: z.number(),
|
||||||
|
hasNextPage: z.boolean(),
|
||||||
|
hasPreviousPage: z.boolean(),
|
||||||
|
nextPage: z.number().nullable(),
|
||||||
|
previousPage: z.number().nullable(),
|
||||||
|
}),
|
||||||
|
})
|
||||||
|
|
||||||
|
export const UsersMutate = z.object({
|
||||||
|
message: z.string(),
|
||||||
|
data: user,
|
||||||
|
})
|
||||||
Reference in New Issue
Block a user