From f910aea3ccdb1210239f8afdb5756a13bd15410e Mon Sep 17 00:00:00 2001 From: Sergio Ramirez Date: Wed, 25 Feb 2026 12:17:33 -0400 Subject: [PATCH] nuevas correciones al formulario y esquema base de datos para osp --- apps/api/src/common/minio/minio.service.ts | 15 +- .../migrations/0022_nervous_dragon_lord.sql | 9 + .../migrations/0023_sticky_slayback.sql | 5 + .../migrations/meta/0022_snapshot.json | 2098 +++++++++++++++++ .../migrations/meta/0023_snapshot.json | 2092 ++++++++++++++++ .../database/migrations/meta/_journal.json | 14 + apps/api/src/database/schema/surveys.ts | 19 +- .../training/dto/create-training.dto.ts | 68 +- .../src/features/training/training.service.ts | 54 +- apps/web/constants/countries.ts | 389 ++- .../training/actions/training-actions.ts | 4 +- .../feactures/training/components/form.tsx | 273 ++- .../components/product-activity-list.tsx | 357 +-- .../components/training-view-modal.tsx | 158 +- .../feactures/training/schemas/training.ts | 65 +- 15 files changed, 4889 insertions(+), 731 deletions(-) create mode 100644 apps/api/src/database/migrations/0022_nervous_dragon_lord.sql create mode 100644 apps/api/src/database/migrations/0023_sticky_slayback.sql create mode 100644 apps/api/src/database/migrations/meta/0022_snapshot.json create mode 100644 apps/api/src/database/migrations/meta/0023_snapshot.json diff --git a/apps/api/src/common/minio/minio.service.ts b/apps/api/src/common/minio/minio.service.ts index 8204c02..29116a3 100644 --- a/apps/api/src/common/minio/minio.service.ts +++ b/apps/api/src/common/minio/minio.service.ts @@ -108,10 +108,19 @@ export class MinioService implements OnModuleInit { async delete(objectName: string): Promise { try { - await this.minioClient.removeObject(this.bucketName, objectName); - this.logger.log(`Object "${objectName}" deleted successfully.`); + // Ensure we don't have a leading slash which can cause issues with removeObject + const cleanedName = objectName.startsWith('/') + ? objectName.slice(1) + : objectName; + + await this.minioClient.removeObject(this.bucketName, cleanedName); + this.logger.log( + `Object "${cleanedName}" deleted successfully from bucket "${this.bucketName}".`, + ); } catch (error: any) { - this.logger.error(`Error deleting file: ${error.message}`); + this.logger.error( + `Error deleting file "${objectName}": ${error.message}`, + ); // We don't necessarily want to throw if the file is already gone } } diff --git a/apps/api/src/database/migrations/0022_nervous_dragon_lord.sql b/apps/api/src/database/migrations/0022_nervous_dragon_lord.sql new file mode 100644 index 0000000..3f5982b --- /dev/null +++ b/apps/api/src/database/migrations/0022_nervous_dragon_lord.sql @@ -0,0 +1,9 @@ +ALTER TABLE "training_surveys" ADD COLUMN "internal_distribution_zone" text;--> statement-breakpoint +ALTER TABLE "training_surveys" ADD COLUMN "is_exporting" boolean DEFAULT false NOT NULL;--> statement-breakpoint +ALTER TABLE "training_surveys" ADD COLUMN "external_country" text;--> statement-breakpoint +ALTER TABLE "training_surveys" ADD COLUMN "external_city" text;--> statement-breakpoint +ALTER TABLE "training_surveys" ADD COLUMN "external_description" text;--> statement-breakpoint +ALTER TABLE "training_surveys" ADD COLUMN "external_quantity" text;--> statement-breakpoint +ALTER TABLE "training_surveys" ADD COLUMN "external_unit" text;--> statement-breakpoint +ALTER TABLE "training_surveys" ADD COLUMN "women_count" integer DEFAULT 0 NOT NULL;--> statement-breakpoint +ALTER TABLE "training_surveys" ADD COLUMN "men_count" integer DEFAULT 0 NOT NULL; \ No newline at end of file diff --git a/apps/api/src/database/migrations/0023_sticky_slayback.sql b/apps/api/src/database/migrations/0023_sticky_slayback.sql new file mode 100644 index 0000000..79efbae --- /dev/null +++ b/apps/api/src/database/migrations/0023_sticky_slayback.sql @@ -0,0 +1,5 @@ +DROP INDEX "training_surveys_index_00";--> statement-breakpoint +ALTER TABLE "training_surveys" ADD COLUMN "coor_full_name" text NOT NULL;--> statement-breakpoint +CREATE INDEX "training_surveys_index_00" ON "training_surveys" USING btree ("coor_full_name");--> statement-breakpoint +ALTER TABLE "training_surveys" DROP COLUMN "firstname";--> statement-breakpoint +ALTER TABLE "training_surveys" DROP COLUMN "lastname"; \ No newline at end of file diff --git a/apps/api/src/database/migrations/meta/0022_snapshot.json b/apps/api/src/database/migrations/meta/0022_snapshot.json new file mode 100644 index 0000000..83ddc4d --- /dev/null +++ b/apps/api/src/database/migrations/meta/0022_snapshot.json @@ -0,0 +1,2098 @@ +{ + "id": "c31c2369-1cbe-4013-babf-ef495c9f2a55", + "prevId": "3d048773-e7a8-4ba5-920a-fa2656b7f6da", + "version": "7", + "dialect": "postgresql", + "tables": { + "public.activity_logs": { + "name": "activity_logs", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "type": { + "name": "type", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "timestamp": { + "name": "timestamp", + "type": "timestamp", + "primaryKey": false, + "notNull": false, + "default": "now()" + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp (3)", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "activityLogs_idx": { + "name": "activityLogs_idx", + "columns": [ + { + "expression": "type", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "activity_logs_user_id_users_id_fk": { + "name": "activity_logs_user_id_users_id_fk", + "tableFrom": "activity_logs", + "tableTo": "users", + "schemaTo": "auth", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "auth.roles": { + "name": "roles", + "schema": "auth", + "columns": { + "id": { + "name": "id", + "type": "serial", + "primaryKey": true, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp (3)", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "roles_idx": { + "name": "roles_idx", + "columns": [ + { + "expression": "name", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "auth.sessions": { + "name": "sessions", + "schema": "auth", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "session_token": { + "name": "session_token", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "expires_at": { + "name": "expires_at", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "previous_session_token": { + "name": "previous_session_token", + "type": "varchar", + "primaryKey": false, + "notNull": false + }, + "last_rotated_at": { + "name": "last_rotated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp (3)", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "sessions_idx": { + "name": "sessions_idx", + "columns": [ + { + "expression": "session_token", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "sessions_user_id_users_id_fk": { + "name": "sessions_user_id_users_id_fk", + "tableFrom": "sessions", + "tableTo": "users", + "schemaTo": "auth", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "auth.users": { + "name": "users", + "schema": "auth", + "columns": { + "id": { + "name": "id", + "type": "serial", + "primaryKey": true, + "notNull": true + }, + "username": { + "name": "username", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "email": { + "name": "email", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "fullname": { + "name": "fullname", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "phone": { + "name": "phone", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "password": { + "name": "password", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "state": { + "name": "state", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "municipality": { + "name": "municipality", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "parish": { + "name": "parish", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "is_two_factor_enabled": { + "name": "is_two_factor_enabled", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "two_factor_secret": { + "name": "two_factor_secret", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "is_email_verified": { + "name": "is_email_verified", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "is_active": { + "name": "is_active", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp (3)", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "users_idx": { + "name": "users_idx", + "columns": [ + { + "expression": "username", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "users_state_states_id_fk": { + "name": "users_state_states_id_fk", + "tableFrom": "users", + "tableTo": "states", + "columnsFrom": [ + "state" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "users_municipality_municipalities_id_fk": { + "name": "users_municipality_municipalities_id_fk", + "tableFrom": "users", + "tableTo": "municipalities", + "columnsFrom": [ + "municipality" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "users_parish_parishes_id_fk": { + "name": "users_parish_parishes_id_fk", + "tableFrom": "users", + "tableTo": "parishes", + "columnsFrom": [ + "parish" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "users_username_unique": { + "name": "users_username_unique", + "nullsNotDistinct": false, + "columns": [ + "username" + ] + }, + "users_email_unique": { + "name": "users_email_unique", + "nullsNotDistinct": false, + "columns": [ + "email" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "auth.user_role": { + "name": "user_role", + "schema": "auth", + "columns": { + "id": { + "name": "id", + "type": "serial", + "primaryKey": true, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "role_id": { + "name": "role_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp (3)", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "user_role_idx": { + "name": "user_role_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "user_role_user_id_users_id_fk": { + "name": "user_role_user_id_users_id_fk", + "tableFrom": "user_role", + "tableTo": "users", + "schemaTo": "auth", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "user_role_role_id_roles_id_fk": { + "name": "user_role_role_id_roles_id_fk", + "tableFrom": "user_role", + "tableTo": "roles", + "schemaTo": "auth", + "columnsFrom": [ + "role_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "auth.verificationToken": { + "name": "verificationToken", + "schema": "auth", + "columns": { + "identifier": { + "name": "identifier", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "token": { + "name": "token", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "code": { + "name": "code", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "expires": { + "name": "expires", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "ip_address": { + "name": "ip_address", + "type": "text", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.category_type": { + "name": "category_type", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "serial", + "primaryKey": true, + "notNull": true + }, + "group": { + "name": "group", + "type": "varchar(100)", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp (3)", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "category_typeIx0": { + "name": "category_typeIx0", + "columns": [ + { + "expression": "group", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "category_typeIx1": { + "name": "category_typeIx1", + "columns": [ + { + "expression": "description", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.localities": { + "name": "localities", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "serial", + "primaryKey": true, + "notNull": true + }, + "state_id": { + "name": "state_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "municipality_id": { + "name": "municipality_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "parish_id": { + "name": "parish_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp (3)", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "localities_index_03": { + "name": "localities_index_03", + "columns": [ + { + "expression": "state_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "municipality_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "parish_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "localities_index_00": { + "name": "localities_index_00", + "columns": [ + { + "expression": "state_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "localities_index_01": { + "name": "localities_index_01", + "columns": [ + { + "expression": "municipality_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "localities_index_02": { + "name": "localities_index_02", + "columns": [ + { + "expression": "parish_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "localities_state_id_states_id_fk": { + "name": "localities_state_id_states_id_fk", + "tableFrom": "localities", + "tableTo": "states", + "columnsFrom": [ + "state_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "localities_municipality_id_municipalities_id_fk": { + "name": "localities_municipality_id_municipalities_id_fk", + "tableFrom": "localities", + "tableTo": "municipalities", + "columnsFrom": [ + "municipality_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "localities_parish_id_parishes_id_fk": { + "name": "localities_parish_id_parishes_id_fk", + "tableFrom": "localities", + "tableTo": "parishes", + "columnsFrom": [ + "parish_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "localities_name_unique": { + "name": "localities_name_unique", + "nullsNotDistinct": false, + "columns": [ + "name" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.municipalities": { + "name": "municipalities", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "serial", + "primaryKey": true, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "state_id": { + "name": "state_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp (3)", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "municipalities_index_00": { + "name": "municipalities_index_00", + "columns": [ + { + "expression": "id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "name", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "state_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "municipalities_state_id_states_id_fk": { + "name": "municipalities_state_id_states_id_fk", + "tableFrom": "municipalities", + "tableTo": "states", + "columnsFrom": [ + "state_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.parishes": { + "name": "parishes", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "serial", + "primaryKey": true, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "municipality_id": { + "name": "municipality_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp (3)", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "parishes_index_00": { + "name": "parishes_index_00", + "columns": [ + { + "expression": "id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "name", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "municipality_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "parishes_municipality_id_municipalities_id_fk": { + "name": "parishes_municipality_id_municipalities_id_fk", + "tableFrom": "parishes", + "tableTo": "municipalities", + "columnsFrom": [ + "municipality_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.states": { + "name": "states", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "serial", + "primaryKey": true, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp (3)", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "states_index_00": { + "name": "states_index_00", + "columns": [ + { + "expression": "id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "name", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.products": { + "name": "products", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "serial", + "primaryKey": true, + "notNull": true + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "price": { + "name": "price", + "type": "numeric", + "primaryKey": false, + "notNull": true, + "default": "'0'" + }, + "stock": { + "name": "stock", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "address": { + "name": "address", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "url_img": { + "name": "url_img", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "gallery": { + "name": "gallery", + "type": "text[]", + "primaryKey": false, + "notNull": true, + "default": "'{}'::text[]" + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'BORRADOR'" + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp (3)", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "products_user_id_users_id_fk": { + "name": "products_user_id_users_id_fk", + "tableFrom": "products", + "tableTo": "users", + "schemaTo": "auth", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.answers_surveys": { + "name": "answers_surveys", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "serial", + "primaryKey": true, + "notNull": true + }, + "survey_id": { + "name": "survey_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "answers": { + "name": "answers", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp (3)", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "answers_index_00": { + "name": "answers_index_00", + "columns": [ + { + "expression": "answers", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "answers_index_01": { + "name": "answers_index_01", + "columns": [ + { + "expression": "survey_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "answers_index_02": { + "name": "answers_index_02", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "answers_surveys_survey_id_surveys_id_fk": { + "name": "answers_surveys_survey_id_surveys_id_fk", + "tableFrom": "answers_surveys", + "tableTo": "surveys", + "columnsFrom": [ + "survey_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "answers_surveys_user_id_users_id_fk": { + "name": "answers_surveys_user_id_users_id_fk", + "tableFrom": "answers_surveys", + "tableTo": "users", + "schemaTo": "auth", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.surveys": { + "name": "surveys", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "serial", + "primaryKey": true, + "notNull": true + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "target_audience": { + "name": "target_audience", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "closing_date": { + "name": "closing_date", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "published": { + "name": "published", + "type": "boolean", + "primaryKey": false, + "notNull": true + }, + "questions": { + "name": "questions", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp (3)", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "surveys_index_00": { + "name": "surveys_index_00", + "columns": [ + { + "expression": "title", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.training_surveys": { + "name": "training_surveys", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "serial", + "primaryKey": true, + "notNull": true + }, + "firstname": { + "name": "firstname", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "lastname": { + "name": "lastname", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "visit_date": { + "name": "visit_date", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "coor_phone": { + "name": "coor_phone", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "state": { + "name": "state", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "municipality": { + "name": "municipality", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "parish": { + "name": "parish", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "osp_type": { + "name": "osp_type", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "eco_sector": { + "name": "eco_sector", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "''" + }, + "productive_sector": { + "name": "productive_sector", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "''" + }, + "central_productive_activity": { + "name": "central_productive_activity", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "''" + }, + "main_productive_activity": { + "name": "main_productive_activity", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "''" + }, + "productive_activity": { + "name": "productive_activity", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "osp_rif": { + "name": "osp_rif", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "osp_name": { + "name": "osp_name", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "company_constitution_year": { + "name": "company_constitution_year", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "current_status": { + "name": "current_status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'ACTIVA'" + }, + "infrastructure_mt2": { + "name": "infrastructure_mt2", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "''" + }, + "has_transport": { + "name": "has_transport", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "structure_type": { + "name": "structure_type", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "''" + }, + "is_open_space": { + "name": "is_open_space", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "paralysis_reason": { + "name": "paralysis_reason", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "equipment_list": { + "name": "equipment_list", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[]'::jsonb" + }, + "production_list": { + "name": "production_list", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[]'::jsonb" + }, + "product_list": { + "name": "product_list", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[]'::jsonb" + }, + "osp_address": { + "name": "osp_address", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "osp_google_maps_link": { + "name": "osp_google_maps_link", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "''" + }, + "commune_name": { + "name": "commune_name", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "''" + }, + "situr_code_commune": { + "name": "situr_code_commune", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "commune_rif": { + "name": "commune_rif", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "''" + }, + "commune_spokesperson_name": { + "name": "commune_spokesperson_name", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "''" + }, + "commune_spokesperson_cedula": { + "name": "commune_spokesperson_cedula", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "commune_spokesperson_rif": { + "name": "commune_spokesperson_rif", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "commune_spokesperson_phone": { + "name": "commune_spokesperson_phone", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "''" + }, + "commune_email": { + "name": "commune_email", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "communal_council": { + "name": "communal_council", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "situr_code_communal_council": { + "name": "situr_code_communal_council", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "communal_council_rif": { + "name": "communal_council_rif", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "''" + }, + "communal_council_spokesperson_name": { + "name": "communal_council_spokesperson_name", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "''" + }, + "communal_council_spokesperson_cedula": { + "name": "communal_council_spokesperson_cedula", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "communal_council_spokesperson_rif": { + "name": "communal_council_spokesperson_rif", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "communal_council_spokesperson_phone": { + "name": "communal_council_spokesperson_phone", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "''" + }, + "communal_council_email": { + "name": "communal_council_email", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "''" + }, + "osp_responsible_fullname": { + "name": "osp_responsible_fullname", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "osp_responsible_cedula": { + "name": "osp_responsible_cedula", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "osp_responsible_rif": { + "name": "osp_responsible_rif", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "civil_state": { + "name": "civil_state", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "osp_responsible_phone": { + "name": "osp_responsible_phone", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "osp_responsible_email": { + "name": "osp_responsible_email", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "family_burden": { + "name": "family_burden", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "number_of_children": { + "name": "number_of_children", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "general_observations": { + "name": "general_observations", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "internal_distribution_zone": { + "name": "internal_distribution_zone", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "is_exporting": { + "name": "is_exporting", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "external_country": { + "name": "external_country", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "external_city": { + "name": "external_city", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "external_description": { + "name": "external_description", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "external_quantity": { + "name": "external_quantity", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "external_unit": { + "name": "external_unit", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "women_count": { + "name": "women_count", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "men_count": { + "name": "men_count", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "photo1": { + "name": "photo1", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "photo2": { + "name": "photo2", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "photo3": { + "name": "photo3", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "updated_by": { + "name": "updated_by", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp (3)", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "training_surveys_index_00": { + "name": "training_surveys_index_00", + "columns": [ + { + "expression": "firstname", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "training_surveys_state_states_id_fk": { + "name": "training_surveys_state_states_id_fk", + "tableFrom": "training_surveys", + "tableTo": "states", + "columnsFrom": [ + "state" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "training_surveys_municipality_municipalities_id_fk": { + "name": "training_surveys_municipality_municipalities_id_fk", + "tableFrom": "training_surveys", + "tableTo": "municipalities", + "columnsFrom": [ + "municipality" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "training_surveys_parish_parishes_id_fk": { + "name": "training_surveys_parish_parishes_id_fk", + "tableFrom": "training_surveys", + "tableTo": "parishes", + "columnsFrom": [ + "parish" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "training_surveys_created_by_users_id_fk": { + "name": "training_surveys_created_by_users_id_fk", + "tableFrom": "training_surveys", + "tableTo": "users", + "schemaTo": "auth", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "training_surveys_updated_by_users_id_fk": { + "name": "training_surveys_updated_by_users_id_fk", + "tableFrom": "training_surveys", + "tableTo": "users", + "schemaTo": "auth", + "columnsFrom": [ + "updated_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + } + }, + "enums": { + "auth.gender": { + "name": "gender", + "schema": "auth", + "values": [ + "FEMENINO", + "MASCULINO" + ] + }, + "public.nationality": { + "name": "nationality", + "schema": "public", + "values": [ + "VENEZOLANO", + "EXTRANJERO" + ] + }, + "auth.status": { + "name": "status", + "schema": "auth", + "values": [ + "ACTIVE", + "INACTIVE" + ] + } + }, + "schemas": { + "auth": "auth" + }, + "sequences": {}, + "roles": {}, + "policies": {}, + "views": { + "auth.user_access_view": { + "columns": { + "userId": { + "name": "userId", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "username": { + "name": "username", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "email": { + "name": "email", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "role_id": { + "name": "role_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "role_name": { + "name": "role_name", + "type": "text", + "primaryKey": false, + "notNull": false + } + }, + "definition": "\n SELECT\n u.id AS user_id,\n u.username,\n u.email,\n u.fullname,\n r.id AS role_id,\n r.name AS role_name\nFROM\n auth.users u\nLEFT JOIN\n auth.user_role ur ON u.id = ur.user_id \nLEFT JOIN\n auth.roles r ON ur.role_id = r.id", + "name": "user_access_view", + "schema": "auth", + "isExisting": false, + "materialized": false + }, + "public.v_product_store": { + "columns": { + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "price": { + "name": "price", + "type": "numeric", + "primaryKey": false, + "notNull": false + }, + "stock": { + "name": "stock", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "url_img": { + "name": "url_img", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "gallery": { + "name": "gallery", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "address": { + "name": "address", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "fullname": { + "name": "fullname", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "email": { + "name": "email", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "phone": { + "name": "phone", + "type": "text", + "primaryKey": false, + "notNull": false + } + }, + "definition": "\n select p.id as product_id, p.title, p.description, p.price, p.stock, p.url_img, p.gallery, p.address, p.status, p.user_id, u.fullname, u.email, u.phone\n from products p\n left join auth.users as u on u.id = p.user_id", + "name": "v_product_store", + "schema": "public", + "isExisting": false, + "materialized": false + }, + "public.v_surveys": { + "columns": { + "survey_id": { + "name": "survey_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "closing_date": { + "name": "closing_date", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "target_audience": { + "name": "target_audience", + "type": "varchar", + "primaryKey": false, + "notNull": false + } + }, + "definition": "select id as survey_id, title, description, created_at, closing_date, target_audience from surveys\nwhere published = true", + "name": "v_surveys", + "schema": "public", + "isExisting": false, + "materialized": false + } + }, + "_meta": { + "columns": {}, + "schemas": {}, + "tables": {} + } +} \ No newline at end of file diff --git a/apps/api/src/database/migrations/meta/0023_snapshot.json b/apps/api/src/database/migrations/meta/0023_snapshot.json new file mode 100644 index 0000000..bc0f004 --- /dev/null +++ b/apps/api/src/database/migrations/meta/0023_snapshot.json @@ -0,0 +1,2092 @@ +{ + "id": "1c612105-c259-49e5-9d37-e2eb458de6d8", + "prevId": "c31c2369-1cbe-4013-babf-ef495c9f2a55", + "version": "7", + "dialect": "postgresql", + "tables": { + "public.activity_logs": { + "name": "activity_logs", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "type": { + "name": "type", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "timestamp": { + "name": "timestamp", + "type": "timestamp", + "primaryKey": false, + "notNull": false, + "default": "now()" + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp (3)", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "activityLogs_idx": { + "name": "activityLogs_idx", + "columns": [ + { + "expression": "type", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "activity_logs_user_id_users_id_fk": { + "name": "activity_logs_user_id_users_id_fk", + "tableFrom": "activity_logs", + "tableTo": "users", + "schemaTo": "auth", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "auth.roles": { + "name": "roles", + "schema": "auth", + "columns": { + "id": { + "name": "id", + "type": "serial", + "primaryKey": true, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp (3)", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "roles_idx": { + "name": "roles_idx", + "columns": [ + { + "expression": "name", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "auth.sessions": { + "name": "sessions", + "schema": "auth", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "session_token": { + "name": "session_token", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "expires_at": { + "name": "expires_at", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "previous_session_token": { + "name": "previous_session_token", + "type": "varchar", + "primaryKey": false, + "notNull": false + }, + "last_rotated_at": { + "name": "last_rotated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp (3)", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "sessions_idx": { + "name": "sessions_idx", + "columns": [ + { + "expression": "session_token", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "sessions_user_id_users_id_fk": { + "name": "sessions_user_id_users_id_fk", + "tableFrom": "sessions", + "tableTo": "users", + "schemaTo": "auth", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "auth.users": { + "name": "users", + "schema": "auth", + "columns": { + "id": { + "name": "id", + "type": "serial", + "primaryKey": true, + "notNull": true + }, + "username": { + "name": "username", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "email": { + "name": "email", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "fullname": { + "name": "fullname", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "phone": { + "name": "phone", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "password": { + "name": "password", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "state": { + "name": "state", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "municipality": { + "name": "municipality", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "parish": { + "name": "parish", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "is_two_factor_enabled": { + "name": "is_two_factor_enabled", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "two_factor_secret": { + "name": "two_factor_secret", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "is_email_verified": { + "name": "is_email_verified", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "is_active": { + "name": "is_active", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp (3)", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "users_idx": { + "name": "users_idx", + "columns": [ + { + "expression": "username", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "users_state_states_id_fk": { + "name": "users_state_states_id_fk", + "tableFrom": "users", + "tableTo": "states", + "columnsFrom": [ + "state" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "users_municipality_municipalities_id_fk": { + "name": "users_municipality_municipalities_id_fk", + "tableFrom": "users", + "tableTo": "municipalities", + "columnsFrom": [ + "municipality" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "users_parish_parishes_id_fk": { + "name": "users_parish_parishes_id_fk", + "tableFrom": "users", + "tableTo": "parishes", + "columnsFrom": [ + "parish" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "users_username_unique": { + "name": "users_username_unique", + "nullsNotDistinct": false, + "columns": [ + "username" + ] + }, + "users_email_unique": { + "name": "users_email_unique", + "nullsNotDistinct": false, + "columns": [ + "email" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "auth.user_role": { + "name": "user_role", + "schema": "auth", + "columns": { + "id": { + "name": "id", + "type": "serial", + "primaryKey": true, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "role_id": { + "name": "role_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp (3)", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "user_role_idx": { + "name": "user_role_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "user_role_user_id_users_id_fk": { + "name": "user_role_user_id_users_id_fk", + "tableFrom": "user_role", + "tableTo": "users", + "schemaTo": "auth", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "user_role_role_id_roles_id_fk": { + "name": "user_role_role_id_roles_id_fk", + "tableFrom": "user_role", + "tableTo": "roles", + "schemaTo": "auth", + "columnsFrom": [ + "role_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "auth.verificationToken": { + "name": "verificationToken", + "schema": "auth", + "columns": { + "identifier": { + "name": "identifier", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "token": { + "name": "token", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "code": { + "name": "code", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "expires": { + "name": "expires", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "ip_address": { + "name": "ip_address", + "type": "text", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.category_type": { + "name": "category_type", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "serial", + "primaryKey": true, + "notNull": true + }, + "group": { + "name": "group", + "type": "varchar(100)", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp (3)", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "category_typeIx0": { + "name": "category_typeIx0", + "columns": [ + { + "expression": "group", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "category_typeIx1": { + "name": "category_typeIx1", + "columns": [ + { + "expression": "description", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.localities": { + "name": "localities", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "serial", + "primaryKey": true, + "notNull": true + }, + "state_id": { + "name": "state_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "municipality_id": { + "name": "municipality_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "parish_id": { + "name": "parish_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp (3)", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "localities_index_03": { + "name": "localities_index_03", + "columns": [ + { + "expression": "state_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "municipality_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "parish_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "localities_index_00": { + "name": "localities_index_00", + "columns": [ + { + "expression": "state_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "localities_index_01": { + "name": "localities_index_01", + "columns": [ + { + "expression": "municipality_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "localities_index_02": { + "name": "localities_index_02", + "columns": [ + { + "expression": "parish_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "localities_state_id_states_id_fk": { + "name": "localities_state_id_states_id_fk", + "tableFrom": "localities", + "tableTo": "states", + "columnsFrom": [ + "state_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "localities_municipality_id_municipalities_id_fk": { + "name": "localities_municipality_id_municipalities_id_fk", + "tableFrom": "localities", + "tableTo": "municipalities", + "columnsFrom": [ + "municipality_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "localities_parish_id_parishes_id_fk": { + "name": "localities_parish_id_parishes_id_fk", + "tableFrom": "localities", + "tableTo": "parishes", + "columnsFrom": [ + "parish_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "localities_name_unique": { + "name": "localities_name_unique", + "nullsNotDistinct": false, + "columns": [ + "name" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.municipalities": { + "name": "municipalities", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "serial", + "primaryKey": true, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "state_id": { + "name": "state_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp (3)", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "municipalities_index_00": { + "name": "municipalities_index_00", + "columns": [ + { + "expression": "id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "name", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "state_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "municipalities_state_id_states_id_fk": { + "name": "municipalities_state_id_states_id_fk", + "tableFrom": "municipalities", + "tableTo": "states", + "columnsFrom": [ + "state_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.parishes": { + "name": "parishes", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "serial", + "primaryKey": true, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "municipality_id": { + "name": "municipality_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp (3)", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "parishes_index_00": { + "name": "parishes_index_00", + "columns": [ + { + "expression": "id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "name", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "municipality_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "parishes_municipality_id_municipalities_id_fk": { + "name": "parishes_municipality_id_municipalities_id_fk", + "tableFrom": "parishes", + "tableTo": "municipalities", + "columnsFrom": [ + "municipality_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.states": { + "name": "states", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "serial", + "primaryKey": true, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp (3)", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "states_index_00": { + "name": "states_index_00", + "columns": [ + { + "expression": "id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "name", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.products": { + "name": "products", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "serial", + "primaryKey": true, + "notNull": true + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "price": { + "name": "price", + "type": "numeric", + "primaryKey": false, + "notNull": true, + "default": "'0'" + }, + "stock": { + "name": "stock", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "address": { + "name": "address", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "url_img": { + "name": "url_img", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "gallery": { + "name": "gallery", + "type": "text[]", + "primaryKey": false, + "notNull": true, + "default": "'{}'::text[]" + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'BORRADOR'" + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp (3)", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "products_user_id_users_id_fk": { + "name": "products_user_id_users_id_fk", + "tableFrom": "products", + "tableTo": "users", + "schemaTo": "auth", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.answers_surveys": { + "name": "answers_surveys", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "serial", + "primaryKey": true, + "notNull": true + }, + "survey_id": { + "name": "survey_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "answers": { + "name": "answers", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp (3)", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "answers_index_00": { + "name": "answers_index_00", + "columns": [ + { + "expression": "answers", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "answers_index_01": { + "name": "answers_index_01", + "columns": [ + { + "expression": "survey_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "answers_index_02": { + "name": "answers_index_02", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "answers_surveys_survey_id_surveys_id_fk": { + "name": "answers_surveys_survey_id_surveys_id_fk", + "tableFrom": "answers_surveys", + "tableTo": "surveys", + "columnsFrom": [ + "survey_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "answers_surveys_user_id_users_id_fk": { + "name": "answers_surveys_user_id_users_id_fk", + "tableFrom": "answers_surveys", + "tableTo": "users", + "schemaTo": "auth", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.surveys": { + "name": "surveys", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "serial", + "primaryKey": true, + "notNull": true + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "target_audience": { + "name": "target_audience", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "closing_date": { + "name": "closing_date", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "published": { + "name": "published", + "type": "boolean", + "primaryKey": false, + "notNull": true + }, + "questions": { + "name": "questions", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp (3)", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "surveys_index_00": { + "name": "surveys_index_00", + "columns": [ + { + "expression": "title", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.training_surveys": { + "name": "training_surveys", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "serial", + "primaryKey": true, + "notNull": true + }, + "coor_full_name": { + "name": "coor_full_name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "visit_date": { + "name": "visit_date", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "coor_phone": { + "name": "coor_phone", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "state": { + "name": "state", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "municipality": { + "name": "municipality", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "parish": { + "name": "parish", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "osp_type": { + "name": "osp_type", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "eco_sector": { + "name": "eco_sector", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "''" + }, + "productive_sector": { + "name": "productive_sector", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "''" + }, + "central_productive_activity": { + "name": "central_productive_activity", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "''" + }, + "main_productive_activity": { + "name": "main_productive_activity", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "''" + }, + "productive_activity": { + "name": "productive_activity", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "osp_rif": { + "name": "osp_rif", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "osp_name": { + "name": "osp_name", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "company_constitution_year": { + "name": "company_constitution_year", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "current_status": { + "name": "current_status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'ACTIVA'" + }, + "infrastructure_mt2": { + "name": "infrastructure_mt2", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "''" + }, + "has_transport": { + "name": "has_transport", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "structure_type": { + "name": "structure_type", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "''" + }, + "is_open_space": { + "name": "is_open_space", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "paralysis_reason": { + "name": "paralysis_reason", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "equipment_list": { + "name": "equipment_list", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[]'::jsonb" + }, + "production_list": { + "name": "production_list", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[]'::jsonb" + }, + "product_list": { + "name": "product_list", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[]'::jsonb" + }, + "osp_address": { + "name": "osp_address", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "osp_google_maps_link": { + "name": "osp_google_maps_link", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "''" + }, + "commune_name": { + "name": "commune_name", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "''" + }, + "situr_code_commune": { + "name": "situr_code_commune", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "commune_rif": { + "name": "commune_rif", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "''" + }, + "commune_spokesperson_name": { + "name": "commune_spokesperson_name", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "''" + }, + "commune_spokesperson_cedula": { + "name": "commune_spokesperson_cedula", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "commune_spokesperson_rif": { + "name": "commune_spokesperson_rif", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "commune_spokesperson_phone": { + "name": "commune_spokesperson_phone", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "''" + }, + "commune_email": { + "name": "commune_email", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "communal_council": { + "name": "communal_council", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "situr_code_communal_council": { + "name": "situr_code_communal_council", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "communal_council_rif": { + "name": "communal_council_rif", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "''" + }, + "communal_council_spokesperson_name": { + "name": "communal_council_spokesperson_name", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "''" + }, + "communal_council_spokesperson_cedula": { + "name": "communal_council_spokesperson_cedula", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "communal_council_spokesperson_rif": { + "name": "communal_council_spokesperson_rif", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "communal_council_spokesperson_phone": { + "name": "communal_council_spokesperson_phone", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "''" + }, + "communal_council_email": { + "name": "communal_council_email", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "''" + }, + "osp_responsible_fullname": { + "name": "osp_responsible_fullname", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "osp_responsible_cedula": { + "name": "osp_responsible_cedula", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "osp_responsible_rif": { + "name": "osp_responsible_rif", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "civil_state": { + "name": "civil_state", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "osp_responsible_phone": { + "name": "osp_responsible_phone", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "osp_responsible_email": { + "name": "osp_responsible_email", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "family_burden": { + "name": "family_burden", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "number_of_children": { + "name": "number_of_children", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "general_observations": { + "name": "general_observations", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "internal_distribution_zone": { + "name": "internal_distribution_zone", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "is_exporting": { + "name": "is_exporting", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "external_country": { + "name": "external_country", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "external_city": { + "name": "external_city", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "external_description": { + "name": "external_description", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "external_quantity": { + "name": "external_quantity", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "external_unit": { + "name": "external_unit", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "women_count": { + "name": "women_count", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "men_count": { + "name": "men_count", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "photo1": { + "name": "photo1", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "photo2": { + "name": "photo2", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "photo3": { + "name": "photo3", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "updated_by": { + "name": "updated_by", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp (3)", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "training_surveys_index_00": { + "name": "training_surveys_index_00", + "columns": [ + { + "expression": "coor_full_name", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "training_surveys_state_states_id_fk": { + "name": "training_surveys_state_states_id_fk", + "tableFrom": "training_surveys", + "tableTo": "states", + "columnsFrom": [ + "state" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "training_surveys_municipality_municipalities_id_fk": { + "name": "training_surveys_municipality_municipalities_id_fk", + "tableFrom": "training_surveys", + "tableTo": "municipalities", + "columnsFrom": [ + "municipality" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "training_surveys_parish_parishes_id_fk": { + "name": "training_surveys_parish_parishes_id_fk", + "tableFrom": "training_surveys", + "tableTo": "parishes", + "columnsFrom": [ + "parish" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "training_surveys_created_by_users_id_fk": { + "name": "training_surveys_created_by_users_id_fk", + "tableFrom": "training_surveys", + "tableTo": "users", + "schemaTo": "auth", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "training_surveys_updated_by_users_id_fk": { + "name": "training_surveys_updated_by_users_id_fk", + "tableFrom": "training_surveys", + "tableTo": "users", + "schemaTo": "auth", + "columnsFrom": [ + "updated_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + } + }, + "enums": { + "auth.gender": { + "name": "gender", + "schema": "auth", + "values": [ + "FEMENINO", + "MASCULINO" + ] + }, + "public.nationality": { + "name": "nationality", + "schema": "public", + "values": [ + "VENEZOLANO", + "EXTRANJERO" + ] + }, + "auth.status": { + "name": "status", + "schema": "auth", + "values": [ + "ACTIVE", + "INACTIVE" + ] + } + }, + "schemas": { + "auth": "auth" + }, + "sequences": {}, + "roles": {}, + "policies": {}, + "views": { + "auth.user_access_view": { + "columns": { + "userId": { + "name": "userId", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "username": { + "name": "username", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "email": { + "name": "email", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "role_id": { + "name": "role_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "role_name": { + "name": "role_name", + "type": "text", + "primaryKey": false, + "notNull": false + } + }, + "definition": "\n SELECT\n u.id AS user_id,\n u.username,\n u.email,\n u.fullname,\n r.id AS role_id,\n r.name AS role_name\nFROM\n auth.users u\nLEFT JOIN\n auth.user_role ur ON u.id = ur.user_id \nLEFT JOIN\n auth.roles r ON ur.role_id = r.id", + "name": "user_access_view", + "schema": "auth", + "isExisting": false, + "materialized": false + }, + "public.v_product_store": { + "columns": { + "product_id": { + "name": "product_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "price": { + "name": "price", + "type": "numeric", + "primaryKey": false, + "notNull": false + }, + "stock": { + "name": "stock", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "url_img": { + "name": "url_img", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "gallery": { + "name": "gallery", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "address": { + "name": "address", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "fullname": { + "name": "fullname", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "email": { + "name": "email", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "phone": { + "name": "phone", + "type": "text", + "primaryKey": false, + "notNull": false + } + }, + "definition": "\n select p.id as product_id, p.title, p.description, p.price, p.stock, p.url_img, p.gallery, p.address, p.status, p.user_id, u.fullname, u.email, u.phone\n from products p\n left join auth.users as u on u.id = p.user_id", + "name": "v_product_store", + "schema": "public", + "isExisting": false, + "materialized": false + }, + "public.v_surveys": { + "columns": { + "survey_id": { + "name": "survey_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "closing_date": { + "name": "closing_date", + "type": "date", + "primaryKey": false, + "notNull": false + }, + "target_audience": { + "name": "target_audience", + "type": "varchar", + "primaryKey": false, + "notNull": false + } + }, + "definition": "select id as survey_id, title, description, created_at, closing_date, target_audience from surveys\nwhere published = true", + "name": "v_surveys", + "schema": "public", + "isExisting": false, + "materialized": false + } + }, + "_meta": { + "columns": {}, + "schemas": {}, + "tables": {} + } +} \ No newline at end of file diff --git a/apps/api/src/database/migrations/meta/_journal.json b/apps/api/src/database/migrations/meta/_journal.json index bdb2b61..50b1aa3 100644 --- a/apps/api/src/database/migrations/meta/_journal.json +++ b/apps/api/src/database/migrations/meta/_journal.json @@ -155,6 +155,20 @@ "when": 1771901546945, "tag": "0021_warm_machine_man", "breakpoints": true + }, + { + "idx": 22, + "version": "7", + "when": 1772031518006, + "tag": "0022_nervous_dragon_lord", + "breakpoints": true + }, + { + "idx": 23, + "version": "7", + "when": 1772032122473, + "tag": "0023_sticky_slayback", + "breakpoints": true } ] } \ No newline at end of file diff --git a/apps/api/src/database/schema/surveys.ts b/apps/api/src/database/schema/surveys.ts index 905b6f5..5cebdc4 100644 --- a/apps/api/src/database/schema/surveys.ts +++ b/apps/api/src/database/schema/surveys.ts @@ -48,8 +48,7 @@ export const trainingSurveys = t.pgTable( { // === 1. IDENTIFICADORES Y DATOS DE VISITA === id: t.serial('id').primaryKey(), - firstname: t.text('firstname').notNull(), - lastname: t.text('lastname').notNull(), + coorFullName: t.text('coor_full_name').notNull(), visitDate: t.timestamp('visit_date').notNull(), coorPhone: t.text('coor_phone'), @@ -133,6 +132,20 @@ export const trainingSurveys = t.pgTable( familyBurden: t.integer('family_burden'), numberOfChildren: t.integer('number_of_children'), generalObservations: t.text('general_observations'), + + // === 4. DATOS DE DISTRIBUCIÓN Y EXPORTACIÓN === + internalDistributionZone: t.text('internal_distribution_zone'), + isExporting: t.boolean('is_exporting').notNull().default(false), + externalCountry: t.text('external_country'), + externalCity: t.text('external_city'), + externalDescription: t.text('external_description'), + externalQuantity: t.text('external_quantity'), + externalUnit: t.text('external_unit'), + + // === 5. MANO DE OBRA === + womenCount: t.integer('women_count').notNull().default(0), + menCount: t.integer('men_count').notNull().default(0), + // Fotos photo1: t.text('photo1'), photo2: t.text('photo2'), @@ -149,7 +162,7 @@ export const trainingSurveys = t.pgTable( (trainingSurveys) => ({ trainingSurveysIndex: t .index('training_surveys_index_00') - .on(trainingSurveys.firstname), + .on(trainingSurveys.coorFullName), }), ); diff --git a/apps/api/src/features/training/dto/create-training.dto.ts b/apps/api/src/features/training/dto/create-training.dto.ts index 14af375..9a607ac 100644 --- a/apps/api/src/features/training/dto/create-training.dto.ts +++ b/apps/api/src/features/training/dto/create-training.dto.ts @@ -2,7 +2,6 @@ import { ApiProperty } from '@nestjs/swagger'; import { Transform, Type } from 'class-transformer'; import { IsArray, - IsBoolean, IsDateString, IsEmail, IsInt, @@ -15,11 +14,7 @@ export class CreateTrainingDto { // === 1. DATOS BÁSICOS === @ApiProperty() @IsString() - firstname: string; - - @ApiProperty() - @IsString() - lastname: string; + coorFullName: string; @ApiProperty() @IsDateString() @@ -77,16 +72,14 @@ export class CreateTrainingDto { structureType?: string; @ApiProperty() - @IsBoolean() + @IsString() @IsOptional() - @Transform(({ value }) => value === 'true' || value === true) // Convierte "false" -> false - hasTransport?: boolean; + hasTransport?: string; @ApiProperty() - @IsBoolean() + @IsString() @IsOptional() - @Transform(({ value }) => value === 'true' || value === true) - isOpenSpace?: boolean; + isOpenSpace?: string; @ApiProperty() @IsString() @@ -209,7 +202,56 @@ export class CreateTrainingDto { @IsEmail() communalCouncilEmail?: string; - // === 6. LISTAS (Arrays JSON) === + // === 6. DISTRIBUCIÓN Y EXPORTACIÓN === + @ApiProperty() + @IsString() + @IsOptional() + internalDistributionZone?: string; + + @ApiProperty() + @IsString() + @IsOptional() + isExporting?: string; + + @ApiProperty() + @IsString() + @IsOptional() + externalCountry?: string; + + @ApiProperty() + @IsString() + @IsOptional() + externalCity?: string; + + @ApiProperty() + @IsString() + @IsOptional() + externalDescription?: string; + + @ApiProperty() + @IsString() + @IsOptional() + externalQuantity?: string; + + @ApiProperty() + @IsString() + @IsOptional() + externalUnit?: string; + + // === 7. MANO DE OBRA === + @ApiProperty() + @IsInt() + @IsOptional() + @Type(() => Number) + womenCount?: number; + + @ApiProperty() + @IsInt() + @IsOptional() + @Type(() => Number) + menCount?: number; + + // === 8. LISTAS (Arrays JSON) === // Reciben un string JSON '[{...}]' y lo convierten a Objeto JS real @ApiProperty() diff --git a/apps/api/src/features/training/training.service.ts b/apps/api/src/features/training/training.service.ts index dc73df8..d3bc097 100644 --- a/apps/api/src/features/training/training.service.ts +++ b/apps/api/src/features/training/training.service.ts @@ -107,17 +107,7 @@ export class TrainingService { // 2. Total Productores (Columna plana que mantuviste) this.drizzle .select({ - sum: sql` - SUM( - ( - SELECT SUM( - COALESCE((item->>'menCount')::int, 0) + - COALESCE((item->>'womenCount')::int, 0) - ) - FROM jsonb_array_elements(${trainingSurveys.productList}) as item - ) - ) - `, + sum: sql`SUM(${trainingSurveys.womenCount} + ${trainingSurveys.menCount})`, }) .from(trainingSurveys) .where(whereCondition), @@ -244,20 +234,25 @@ export class TrainingService { private async deleteFile(fileUrl: string) { if (!fileUrl) return; - // Extract object name from URL - // URL format: http://endpoint:port/bucket/folder/filename - // Or it could be just the path if we decided that. - // Assuming fileUrl is the full public URL from getPublicUrl try { - const url = new URL(fileUrl); - const pathname = url.pathname; // /bucket/folder/filename - const parts = pathname.split('/'); - // parts[0] is '', parts[1] is bucket, parts[2..] is objectName - const objectName = parts.slice(2).join('/'); + // If it's a full URL, we need to extract the part after the bucket name + if (fileUrl.startsWith('http')) { + const url = new URL(fileUrl); + const pathname = url.pathname; // /bucket/folder/filename + const parts = pathname.split('/').filter(Boolean); // ['bucket', 'folder', 'filename'] - await this.minioService.delete(objectName); + // The first part is the bucket name, the rest is the object name + if (parts.length >= 2) { + const objectName = parts.slice(1).join('/'); + await this.minioService.delete(objectName); + return; + } + } + + // If it's not a URL or doesn't match the expected format, pass it as is + await this.minioService.delete(fileUrl); } catch (error) { - // If it's not a valid URL, maybe it's just the object name stored from before + // Fallback if URL parsing fails await this.minioService.delete(fileUrl); } } @@ -292,6 +287,9 @@ export class TrainingService { state: Number(state) ?? null, municipality: Number(municipality) ?? null, parish: Number(parish) ?? null, + hasTransport: rest.hasTransport === 'true' ? true : false, + isOpenSpace: rest.isOpenSpace === 'true' ? true : false, + isExporting: rest.isExporting === 'true' ? true : false, createdBy: userId, updatedBy: userId, }) @@ -359,6 +357,12 @@ export class TrainingService { // actualizamos el id del usuario que actualizo el registro updateData.updatedBy = userId; + updateData.hasTransport = + updateTrainingDto.hasTransport === 'true' ? true : false; + updateData.isOpenSpace = + updateTrainingDto.isOpenSpace === 'true' ? true : false; + updateData.isExporting = + updateTrainingDto.isExporting === 'true' ? true : false; const [updatedRecord] = await this.drizzle .update(trainingSurveys) @@ -402,8 +406,7 @@ export class TrainingService { // const records = await this.drizzle // .select({ - // firstname: trainingSurveys.firstname, - // lastname: trainingSurveys.lastname, + // coorFullName: trainingSurveys.coorFullName, // visitDate: trainingSurveys.visitDate, // stateName: states.name, // municipalityName: municipalities.name, @@ -451,8 +454,7 @@ export class TrainingService { // const dateStr = date.toLocaleDateString('es-VE'); // const timeStr = date.toLocaleTimeString('es-VE'); - // sheet.cell(`A${currentRow}`).value(record.firstname); - // sheet.cell(`B${currentRow}`).value(record.lastname); + // sheet.cell(`A${currentRow}`).value(record.coorFullName); // sheet.cell(`C${currentRow}`).value(dateStr); // sheet.cell(`D${currentRow}`).value(timeStr); // sheet.cell(`E${currentRow}`).value(record.stateName || ''); diff --git a/apps/web/constants/countries.ts b/apps/web/constants/countries.ts index 9b66d4d..ba31610 100644 --- a/apps/web/constants/countries.ts +++ b/apps/web/constants/countries.ts @@ -1,196 +1,195 @@ export const COUNTRY_OPTIONS = [ - 'Afganistán', - 'Albania', - 'Alemania', - 'Andorra', - 'Angola', - 'Antigua y Barbuda', - 'Arabia Saudita', - 'Argelia', - 'Argentina', - 'Armenia', - 'Australia', - 'Austria', - 'Azerbaiyán', - 'Bahamas', - 'Bangladés', - 'Barbados', - 'Baréin', - 'Bélgica', - 'Belice', - 'Benín', - 'Bielorrusia', - 'Birmania', - 'Bolivia', - 'Bosnia y Herzegovina', - 'Botsuana', - 'Brasil', - 'Brunéi', - 'Bulgaria', - 'Burkina Faso', - 'Burundi', - 'Bután', - 'Cabo Verde', - 'Camboya', - 'Camerún', - 'Canadá', - 'Catar', - 'Chad', - 'Chile', - 'China', - 'Chipre', - 'Ciudad del Vaticano', - 'Colombia', - 'Comoras', - 'Corea del Norte', - 'Corea del Sur', - 'Costa de Marfil', - 'Costa Rica', - 'Croacia', - 'Cuba', - 'Dinamarca', - 'Dominica', - 'Ecuador', - 'Egipto', - 'El Salvador', - 'Emiratos Árabes Unidos', - 'Eritrea', - 'Eslovaquia', - 'Eslovenia', - 'España', - 'Estados Unidos', - 'Estonia', - 'Etiopía', - 'Filipinas', - 'Finlandia', - 'Fiyi', - 'Francia', - 'Gabón', - 'Gambia', - 'Georgia', - 'Ghana', - 'Granada', - 'Grecia', - 'Guatemala', - 'Guyana', - 'Guinea', - 'Guinea Ecuatorial', - 'Guinea-Bisáu', - 'Haití', - 'Honduras', - 'Hungría', - 'India', - 'Indonesia', - 'Irak', - 'Irán', - 'Irlanda', - 'Islandia', - 'Islas Marshall', - 'Islas Salomón', - 'Israel', - 'Italia', - 'Jamaica', - 'Japón', - 'Jordania', - 'Kazajistán', - 'Kenia', - 'Kirguistán', - 'Kiribati', - 'Kuwait', - 'Laos', - 'Lesoto', - 'Letonia', - 'Líbano', - 'Liberia', - 'Libia', - 'Liechtenstein', - 'Lituania', - 'Luxemburgo', - 'Madagascar', - 'Malasia', - 'Malaui', - 'Maldivas', - 'Malí', - 'Malta', - 'Marruecos', - 'Mauricio', - 'Mauritania', - 'México', - 'Micronesia', - 'Moldavia', - 'Mónaco', - 'Mongolia', - 'Montenegro', - 'Mozambique', - 'Namibia', - 'Nauru', - 'Nepal', - 'Nicaragua', - 'Níger', - 'Nigeria', - 'Noruega', - 'Nueva Zelanda', - 'Omán', - 'Países Bajos', - 'Pakistán', - 'Palaos', - 'Panamá', - 'Papúa Nueva Guinea', - 'Paraguay', - 'Perú', - 'Polonia', - 'Portugal', - 'Reino Unido', - 'República Centroafricana', - 'República Checa', - 'República de Macedonia', - 'República del Congo', - 'República Democrática del Congo', - 'República Dominicana', - 'República Sudafricana', - 'Ruanda', - 'Rumanía', - 'Rusia', - 'Samoa', - 'San Cristóbal y Nieves', - 'San Marino', - 'San Vicente y las Granadinas', - 'Santa Lucía', - 'Santo Tomé y Príncipe', - 'Senegal', - 'Serbia', - 'Seychelles', - 'Sierra Leona', - 'Singapur', - 'Siria', - 'Somalia', - 'Sri Lanka', - 'Suazilandia', - 'Sudán', - 'Sudán del Sur', - 'Suecia', - 'Suiza', - 'Surinam', - 'Tailandia', - 'Tanzania', - 'Tayikistán', - 'Timor Oriental', - 'Togo', - 'Tonga', - 'Trinidad y Tobago', - 'Túnez', - 'Turkmenistán', - 'Turquía', - 'Tuvalu', - 'Ucrania', - 'Uganda', - 'Uruguay', - 'Uzbekistán', - 'Vanuatu', - 'Venezuela', - 'Vietnam', - 'Yemen', - 'Yibuti', - 'Zambia', - 'Zimbabue' -]; \ No newline at end of file + 'Afganistán', + 'Albania', + 'Alemania', + 'Andorra', + 'Angola', + 'Antigua y Barbuda', + 'Arabia Saudita', + 'Argelia', + 'Argentina', + 'Armenia', + 'Australia', + 'Austria', + 'Azerbaiyán', + 'Bahamas', + 'Bangladés', + 'Barbados', + 'Baréin', + 'Bélgica', + 'Belice', + 'Benín', + 'Bielorrusia', + 'Birmania', + 'Bolivia', + 'Bosnia y Herzegovina', + 'Botsuana', + 'Brasil', + 'Brunéi', + 'Bulgaria', + 'Burkina Faso', + 'Burundi', + 'Bután', + 'Cabo Verde', + 'Camboya', + 'Camerún', + 'Canadá', + 'Catar', + 'Chad', + 'Chile', + 'China', + 'Chipre', + 'Ciudad del Vaticano', + 'Colombia', + 'Comoras', + 'Corea del Norte', + 'Corea del Sur', + 'Costa de Marfil', + 'Costa Rica', + 'Croacia', + 'Cuba', + 'Dinamarca', + 'Dominica', + 'Ecuador', + 'Egipto', + 'El Salvador', + 'Emiratos Árabes Unidos', + 'Eritrea', + 'Eslovaquia', + 'Eslovenia', + 'España', + 'Estados Unidos', + 'Estonia', + 'Etiopía', + 'Filipinas', + 'Finlandia', + 'Fiyi', + 'Francia', + 'Gabón', + 'Gambia', + 'Georgia', + 'Ghana', + 'Granada', + 'Grecia', + 'Guatemala', + 'Guyana', + 'Guinea', + 'Guinea Ecuatorial', + 'Guinea-Bisáu', + 'Haití', + 'Honduras', + 'Hungría', + 'India', + 'Indonesia', + 'Irak', + 'Irán', + 'Irlanda', + 'Islandia', + 'Islas Marshall', + 'Islas Salomón', + 'Israel', + 'Italia', + 'Jamaica', + 'Japón', + 'Jordania', + 'Kazajistán', + 'Kenia', + 'Kirguistán', + 'Kiribati', + 'Kuwait', + 'Laos', + 'Lesoto', + 'Letonia', + 'Líbano', + 'Liberia', + 'Libia', + 'Liechtenstein', + 'Lituania', + 'Luxemburgo', + 'Madagascar', + 'Malasia', + 'Malaui', + 'Maldivas', + 'Malí', + 'Malta', + 'Marruecos', + 'Mauricio', + 'Mauritania', + 'México', + 'Micronesia', + 'Moldavia', + 'Mónaco', + 'Mongolia', + 'Montenegro', + 'Mozambique', + 'Namibia', + 'Nauru', + 'Nepal', + 'Nicaragua', + 'Níger', + 'Nigeria', + 'Noruega', + 'Nueva Zelanda', + 'Omán', + 'Países Bajos', + 'Pakistán', + 'Palaos', + 'Panamá', + 'Papúa Nueva Guinea', + 'Paraguay', + 'Perú', + 'Polonia', + 'Portugal', + 'Reino Unido', + 'República Centroafricana', + 'República Checa', + 'República de Macedonia', + 'República del Congo', + 'República Democrática del Congo', + 'República Dominicana', + 'República Sudafricana', + 'Ruanda', + 'Rumanía', + 'Rusia', + 'Samoa', + 'San Cristóbal y Nieves', + 'San Marino', + 'San Vicente y las Granadinas', + 'Santa Lucía', + 'Santo Tomé y Príncipe', + 'Senegal', + 'Serbia', + 'Seychelles', + 'Sierra Leona', + 'Singapur', + 'Siria', + 'Somalia', + 'Sri Lanka', + 'Suazilandia', + 'Sudán', + 'Sudán del Sur', + 'Suecia', + 'Suiza', + 'Surinam', + 'Tailandia', + 'Tanzania', + 'Tayikistán', + 'Timor Oriental', + 'Togo', + 'Tonga', + 'Trinidad y Tobago', + 'Túnez', + 'Turkmenistán', + 'Turquía', + 'Tuvalu', + 'Ucrania', + 'Uganda', + 'Uruguay', + 'Uzbekistán', + 'Vanuatu', + 'Vietnam', + 'Yemen', + 'Yibuti', + 'Zambia', + 'Zimbabue', +]; diff --git a/apps/web/feactures/training/actions/training-actions.ts b/apps/web/feactures/training/actions/training-actions.ts index 39980b1..524018e 100644 --- a/apps/web/feactures/training/actions/training-actions.ts +++ b/apps/web/feactures/training/actions/training-actions.ts @@ -90,7 +90,7 @@ export const createTrainingAction = async ( payloadToSend = rest as any; } - // console.log(payloadToSend); + console.log(payloadToSend); const [error, data] = await safeFetchApi( TrainingMutate, @@ -124,6 +124,8 @@ export const updateTrainingAction = async ( if (!id) throw new Error('ID es requerido para actualizar'); + console.log(payloadToSend); + const [error, data] = await safeFetchApi( TrainingMutate, `/training/${id}`, diff --git a/apps/web/feactures/training/components/form.tsx b/apps/web/feactures/training/components/form.tsx index 00c379f..5bad7be 100644 --- a/apps/web/feactures/training/components/form.tsx +++ b/apps/web/feactures/training/components/form.tsx @@ -1,7 +1,9 @@ 'use client'; +import { COUNTRY_OPTIONS } from '@/constants/countries'; import { zodResolver } from '@hookform/resolvers/zod'; import { Button } from '@repo/shadcn/button'; +import { Separator } from '@repo/shadcn/components/ui/separator'; import { Form, FormControl, @@ -18,6 +20,7 @@ import { SelectTrigger, SelectValue, } from '@repo/shadcn/select'; +import { Switch } from '@repo/shadcn/switch'; import { Textarea } from '@repo/shadcn/textarea'; import { useForm, useWatch } from 'react-hook-form'; import { @@ -98,8 +101,7 @@ export function CreateTrainingForm({ const form = useForm({ resolver: zodResolver(trainingSchema), defaultValues: { - firstname: defaultValues?.firstname || '', - lastname: defaultValues?.lastname || '', + coorFullName: defaultValues?.coorFullName || '', coorState: defaultValues?.coorState || undefined, coorMunicipality: defaultValues?.coorMunicipality || undefined, coorParish: defaultValues?.coorParish || undefined, @@ -157,6 +159,17 @@ export function CreateTrainingForm({ state: defaultValues?.state || undefined, municipality: defaultValues?.municipality || undefined, parish: defaultValues?.parish || undefined, + + internalDistributionZone: defaultValues?.internalDistributionZone || '', + isExporting: defaultValues?.isExporting || false, + externalCountry: defaultValues?.externalCountry || '', + externalCity: defaultValues?.externalCity || '', + externalDescription: defaultValues?.externalDescription || '', + externalQuantity: defaultValues?.externalQuantity || '', + externalUnit: defaultValues?.externalUnit || '', + + womenCount: defaultValues?.womenCount || 0, + menCount: defaultValues?.menCount || 0, }, mode: 'onChange', }); @@ -213,23 +226,6 @@ export function CreateTrainingForm({ mainProductiveActivity, ]); - const { data: dataCoorState } = useStateQuery(); - const { data: dataCoorMunicipality } = useMunicipalityQuery(coorState); - const { data: dataCoorParish } = useParishQuery(coorMunicipality); - - const coorStateOptions = dataCoorState?.data || [ - { id: 0, name: 'Sin estados' }, - ]; - - const coorMunicipalityOptions = dataCoorMunicipality?.data?.length - ? dataCoorMunicipality.data - : [{ id: 0, stateId: 0, name: 'Sin Municipios' }]; - - const coorParishOptions = - Array.isArray(dataCoorParish?.data) && dataCoorParish?.data?.length - ? dataCoorParish.data - : [{ id: 0, stateId: 0, name: 'Sin Parroquias' }]; - const stateOptions = dataState?.data || [{ id: 0, name: 'Sin estados' }]; const municipalityOptions = dataMunicipality?.data?.length @@ -313,6 +309,7 @@ export function CreateTrainingForm({ selectedFiles.forEach((file) => { data.append('files', file); }); + const mutation = defaultValues?.id ? updateTraining : createTraining; mutation(data as any, { @@ -359,26 +356,14 @@ export function CreateTrainingForm({ ( - Nombre del Coordinador Estadal + + Nombre y Apellido del Coordinador Estadal + - - - - - )} - /> - - ( - - Apellido del Coordinador Estadal - - + @@ -825,7 +810,7 @@ export function CreateTrainingForm({ field.onChange(val === 'true')} - defaultValue={field.value ? 'true' : 'false'} + value={field.value ? 'true' : 'false'} > @@ -936,6 +921,212 @@ export function CreateTrainingForm({ + {/* Distribución y Exportación */} + + + Zona de Distribución y Exportación + + + ( + + + Breve Descripción de la Zona de Distribución + + + + + + + )} + /> + + + + ( + +
+ + ¿El producto es para exportación? + +
+ + + +
+ )} + /> + + {form.watch('isExporting') && ( +
+

+ Datos de Exportación +

+
+ ( + + País + + + + )} + /> + + ( + + Ciudad + + + + + + )} + /> +
+ +
+ ( + + Breve Descripción + + + + + + )} + /> +
+ ( + + Cantidad + + + + + + )} + /> + ( + + Unidad + + + + )} + /> +
+
+
+ )} +
+
+ + {/* Mano de Obra */} + + + Mano de Obra + + + ( + + Mujeres (cantidad) + + + + + + )} + /> + ( + + Hombres (cantidad) + + + + + + )} + /> + + + {/* 3. Detalles de la ubicación */} @@ -963,12 +1154,14 @@ export function CreateTrainingForm({ name="ospGoogleMapsLink" render={({ field }) => ( - Dirección Link Google Maps + + Coordenadas de la Ubicación (Google Maps) + diff --git a/apps/web/feactures/training/components/product-activity-list.tsx b/apps/web/feactures/training/components/product-activity-list.tsx index ca13878..0de4413 100644 --- a/apps/web/feactures/training/components/product-activity-list.tsx +++ b/apps/web/feactures/training/components/product-activity-list.tsx @@ -1,9 +1,3 @@ -import { COUNTRY_OPTIONS } from '@/constants/countries'; -import { - useMunicipalityQuery, - useParishQuery, - useStateQuery, -} from '@/feactures/location/hooks/use-query-location'; import { Button } from '@repo/shadcn/button'; import { Dialog, @@ -23,15 +17,6 @@ import { } from '@repo/shadcn/components/ui/table'; import { Input } from '@repo/shadcn/input'; import { Label } from '@repo/shadcn/label'; -import { - Select, - SelectContent, - SelectItem, - SelectTrigger, - SelectValue, -} from '@repo/shadcn/select'; -import { SelectSearchable } from '@repo/shadcn/select-searchable'; -import { Switch } from '@repo/shadcn/switch'; import { Trash2 } from 'lucide-react'; import { useState } from 'react'; import { useFieldArray, useFormContext } from 'react-hook-form'; @@ -58,48 +43,8 @@ export function ProductActivityList() { dailyCount: '', weeklyCount: '', monthlyCount: '', - internalDistributionZone: '', - - // Internal dist - internalState: null, - internalMunicipality: null, - internalParish: null, - internalDescription: '', - internalQuantity: '', - internalUnit: '', - - // External dist - externalCountry: '', - externalState: null, - externalMunicipality: null, - externalParish: null, - externalCity: '', - externalDescription: '', - externalQuantity: '', - externalUnit: '', - - // Workforce - womenCount: '', - menCount: '', - isExporting: false, }); - // Location logic for Internal Validation - const [internalStateId, setInternalStateId] = useState(0); - const [internalMuniId, setInternalMuniId] = useState(0); - - const { data: statesData } = useStateQuery(); - const { data: internalMuniData } = useMunicipalityQuery(internalStateId); - const { data: internalParishData } = useParishQuery(internalMuniId); - - // Location logic for External Validation - const [externalStateId, setExternalStateId] = useState(0); - const [externalMuniId, setExternalMuniId] = useState(0); - const { data: externalMuniData } = useMunicipalityQuery(externalStateId); - const { data: externalParishData } = useParishQuery(externalMuniId); - - const isVenezuela = newItem.externalCountry === 'Venezuela'; - const handleAdd = () => { if (newItem.description) { append(newItem); @@ -108,39 +53,11 @@ export function ProductActivityList() { dailyCount: '', weeklyCount: '', monthlyCount: '', - internalDistributionZone: '', - internalState: null, - internalMunicipality: null, - internalParish: null, - internalDescription: '', - internalQuantity: '', - internalUnit: '', - externalCountry: '', - externalState: null, - externalMunicipality: null, - externalParish: null, - externalCity: '', - externalDescription: '', - externalQuantity: '', - externalUnit: '', - womenCount: '', - menCount: '', - isExporting: false, }); - setInternalStateId(0); - setInternalMuniId(0); - setExternalStateId(0); - setExternalMuniId(0); setIsOpen(false); } }; - const stateOptions = statesData?.data || []; - const internalMuniOptions = internalMuniData?.data || []; - const internalParishOptions = internalParishData?.data || []; - const externalMuniOptions = externalMuniData?.data || []; - const externalParishOptions = externalParishData?.data || []; - return (
@@ -203,209 +120,6 @@ export function ProductActivityList() {
-
-

Zona de Distribucción

-
-
- - - setNewItem({ - ...newItem, - internalDistributionZone: e.target.value, - }) - } - /> -
-
- -
-
- - setNewItem({ ...newItem, isExporting: val }) - } - /> - -
- - {newItem.isExporting && ( - <> -

- Datos de Exportación -

-
-
- - -
- {!isVenezuela && ( -
- - - setNewItem({ - ...newItem, - externalCity: e.target.value, - }) - } - /> -
- )} -
- - {isVenezuela && ( -
-
- - ({ - value: String(s.id), - label: s.name, - }))} - onValueChange={(val) => { - const id = Number(val); - setExternalStateId(id); - setNewItem({ ...newItem, externalState: id }); - }} - placeholder="Estado" - /> -
-
- - ({ - value: String(s.id), - label: s.name, - }))} - onValueChange={(val) => { - const id = Number(val); - setExternalMuniId(id); - setNewItem({ - ...newItem, - externalMunicipality: id, - }); - }} - placeholder="Municipio" - disabled={!externalStateId} - /> -
-
- - ({ - value: String(s.id), - label: s.name, - }))} - onValueChange={(val) => - setNewItem({ - ...newItem, - externalParish: Number(val), - }) - } - placeholder="Parroquia" - disabled={!externalMuniId} - /> -
-
- )} - -
-
- - - setNewItem({ - ...newItem, - externalDescription: e.target.value, - }) - } - /> -
-
- -
- - setNewItem({ - ...newItem, - externalQuantity: e.target.value, - }) - } - /> - -
-
-
- - )} - -
-

Mano de Obra

-
-
- - - setNewItem({ ...newItem, womenCount: e.target.value }) - } - /> -
-
- - - setNewItem({ ...newItem, menCount: e.target.value }) - } - /> -
-