From 26f5374a42af6f77a95847f28ac483513a4dfb2d Mon Sep 17 00:00:00 2001 From: Lauren Brissette <168485735+laurenbrissette@users.noreply.github.com> Date: Thu, 13 Feb 2025 23:05:12 -0500 Subject: [PATCH] make description optional --- .../migration.sql | 5 ----- .../migration.sql | 5 +++++ apps/server/prisma/schema.prisma | 4 ++-- apps/server/prisma/seed.types.ts | 4 ++-- .../dto/create-form-instance.dto.ts | 2 +- .../entities/form-instance.entity.ts | 8 ++++---- .../dto/create-form-template.dto.ts | 3 +-- .../entities/form-template.entity.ts | 2 +- apps/web/openapi-ts-error-1739504125051.log | 11 +++++++++++ apps/web/openapi-ts-error-1739504146115.log | 11 +++++++++++ apps/web/openapi-ts-error-1739504908576.log | 11 +++++++++++ apps/web/src/client/schemas.gen.ts | 17 ++++++++--------- apps/web/src/client/types.gen.ts | 14 +++++++------- .../CreateFormInstanceModal.tsx | 2 +- 14 files changed, 65 insertions(+), 34 deletions(-) delete mode 100644 apps/server/prisma/migrations/20250209213228_add_description_forminstance_and_formtemplate/migration.sql create mode 100644 apps/server/prisma/migrations/20250214033458_add_template_instance_description_field/migration.sql create mode 100644 apps/web/openapi-ts-error-1739504125051.log create mode 100644 apps/web/openapi-ts-error-1739504146115.log create mode 100644 apps/web/openapi-ts-error-1739504908576.log diff --git a/apps/server/prisma/migrations/20250209213228_add_description_forminstance_and_formtemplate/migration.sql b/apps/server/prisma/migrations/20250209213228_add_description_forminstance_and_formtemplate/migration.sql deleted file mode 100644 index d58adaa1..00000000 --- a/apps/server/prisma/migrations/20250209213228_add_description_forminstance_and_formtemplate/migration.sql +++ /dev/null @@ -1,5 +0,0 @@ --- AlterTable -ALTER TABLE "FormInstance" ADD COLUMN "description" VARCHAR(255) NOT NULL DEFAULT 'No description'; - --- AlterTable -ALTER TABLE "FormTemplate" ADD COLUMN "description" VARCHAR(255) NOT NULL DEFAULT 'No description'; diff --git a/apps/server/prisma/migrations/20250214033458_add_template_instance_description_field/migration.sql b/apps/server/prisma/migrations/20250214033458_add_template_instance_description_field/migration.sql new file mode 100644 index 00000000..0abed20b --- /dev/null +++ b/apps/server/prisma/migrations/20250214033458_add_template_instance_description_field/migration.sql @@ -0,0 +1,5 @@ +-- AlterTable +ALTER TABLE "FormInstance" ADD COLUMN "description" TEXT; + +-- AlterTable +ALTER TABLE "FormTemplate" ADD COLUMN "description" TEXT; diff --git a/apps/server/prisma/schema.prisma b/apps/server/prisma/schema.prisma index 723fb449..451032f1 100644 --- a/apps/server/prisma/schema.prisma +++ b/apps/server/prisma/schema.prisma @@ -88,9 +88,9 @@ model FormTemplate { id String @id @default(uuid()) @db.Uuid name String @db.VarChar(255) formDocLink String @db.VarChar(255) - description String @db.VarChar(255) @default("No description") createdAt DateTime @default(now()) updatedAt DateTime @updatedAt + description String? @db.Text() fieldGroups FieldGroup[] formInstances FormInstance[] @@ -141,11 +141,11 @@ model FormInstance { id String @id @default(uuid()) @db.Uuid name String @db.VarChar(255) formDocLink String @db.VarChar(255) - description String @db.VarChar(255) @default("No description") completed Boolean @default(false) markedCompleted Boolean @default(false) createdAt DateTime @default(now()) updatedAt DateTime @updatedAt + description String? @db.Text() completedAt DateTime? markedCompletedAt DateTime? diff --git a/apps/server/prisma/seed.types.ts b/apps/server/prisma/seed.types.ts index 5cb1aacc..291060f6 100644 --- a/apps/server/prisma/seed.types.ts +++ b/apps/server/prisma/seed.types.ts @@ -45,7 +45,7 @@ export type FormTemplateData = { name: string; formDocLink: string; fieldGroups: FieldGroupData[]; - description: string; + description?: string; }; export type AssignedGroupData = { @@ -66,5 +66,5 @@ export type FormInstanceData = { originatorId: string; formTemplateId: string; assignedGroups: AssignedGroupData[]; - description: string; + description?: string; }; diff --git a/apps/server/src/form-instances/dto/create-form-instance.dto.ts b/apps/server/src/form-instances/dto/create-form-instance.dto.ts index c2124f63..fa399cb6 100644 --- a/apps/server/src/form-instances/dto/create-form-instance.dto.ts +++ b/apps/server/src/form-instances/dto/create-form-instance.dto.ts @@ -10,7 +10,7 @@ export class CreateFormInstanceDto { @IsString() @ApiProperty() - description: string; + description: string | null; @IsArray() @ArrayMinSize(1) diff --git a/apps/server/src/form-instances/entities/form-instance.entity.ts b/apps/server/src/form-instances/entities/form-instance.entity.ts index 8eeb670a..25187c79 100644 --- a/apps/server/src/form-instances/entities/form-instance.entity.ts +++ b/apps/server/src/form-instances/entities/form-instance.entity.ts @@ -12,6 +12,9 @@ export class FormInstanceBaseEntity implements FormInstance { @ApiProperty() name: string; + @ApiProperty() + description: string | null; + @Exclude() formDocLink: string; @@ -51,9 +54,6 @@ export class FormInstanceBaseEntity implements FormInstance { constructor(partial: Partial) { Object.assign(this, partial); } - - @ApiProperty() - description: string; } export class FormInstanceEntity implements FormInstance { @@ -64,7 +64,7 @@ export class FormInstanceEntity implements FormInstance { name: string; @ApiProperty() - description: string; + description: string | null; @ApiProperty() formDocLink: string; diff --git a/apps/server/src/form-templates/dto/create-form-template.dto.ts b/apps/server/src/form-templates/dto/create-form-template.dto.ts index 693aae32..2a288a9d 100644 --- a/apps/server/src/form-templates/dto/create-form-template.dto.ts +++ b/apps/server/src/form-templates/dto/create-form-template.dto.ts @@ -14,9 +14,8 @@ export class CreateFormTemplateDto { formDocLink: string; @IsString() - @IsNotEmpty() @ApiProperty() - description: string; + description: string | null; @IsArray() @ArrayMinSize(1) diff --git a/apps/server/src/form-templates/entities/form-template.entity.ts b/apps/server/src/form-templates/entities/form-template.entity.ts index 4cc808e3..dcc266d4 100644 --- a/apps/server/src/form-templates/entities/form-template.entity.ts +++ b/apps/server/src/form-templates/entities/form-template.entity.ts @@ -15,7 +15,7 @@ export class FormTemplateBaseEntity implements FormTemplate { formDocLink: string; @ApiProperty() - description: string; + description: string | null; @Exclude() createdAt: Date; diff --git a/apps/web/openapi-ts-error-1739504125051.log b/apps/web/openapi-ts-error-1739504125051.log new file mode 100644 index 00000000..642e813c --- /dev/null +++ b/apps/web/openapi-ts-error-1739504125051.log @@ -0,0 +1,11 @@ +Error requesting http://localhost:8080/api-json +fetch failed +ResolverError: Error requesting http://localhost:8080/api-json +fetch failed + at Object.sendRequest (/Users/laurenbrissette/Documents/GitHub (laurenbrissette)/mfa-form-automator/node_modules/@hey-api/json-schema-ref-parser/dist/lib/resolvers/url.js:44:15) + at process.processTicksAndRejections (node:internal/process/task_queues:105:5) + at async Gs (/Users/laurenbrissette/Documents/GitHub (laurenbrissette)/mfa-form-automator/apps/web/node_modules/@hey-api/openapi-ts/dist/index.cjs:12:908) + at async mo (/Users/laurenbrissette/Documents/GitHub (laurenbrissette)/mfa-form-automator/apps/web/node_modules/@hey-api/openapi-ts/dist/index.cjs:14:88219) + at async Promise.all (index 0) + at async Uv (/Users/laurenbrissette/Documents/GitHub (laurenbrissette)/mfa-form-automator/apps/web/node_modules/@hey-api/openapi-ts/dist/index.cjs:1311:4468) + at async start (/Users/laurenbrissette/Documents/GitHub (laurenbrissette)/mfa-form-automator/apps/web/node_modules/@hey-api/openapi-ts/bin/index.cjs:120:21) \ No newline at end of file diff --git a/apps/web/openapi-ts-error-1739504146115.log b/apps/web/openapi-ts-error-1739504146115.log new file mode 100644 index 00000000..642e813c --- /dev/null +++ b/apps/web/openapi-ts-error-1739504146115.log @@ -0,0 +1,11 @@ +Error requesting http://localhost:8080/api-json +fetch failed +ResolverError: Error requesting http://localhost:8080/api-json +fetch failed + at Object.sendRequest (/Users/laurenbrissette/Documents/GitHub (laurenbrissette)/mfa-form-automator/node_modules/@hey-api/json-schema-ref-parser/dist/lib/resolvers/url.js:44:15) + at process.processTicksAndRejections (node:internal/process/task_queues:105:5) + at async Gs (/Users/laurenbrissette/Documents/GitHub (laurenbrissette)/mfa-form-automator/apps/web/node_modules/@hey-api/openapi-ts/dist/index.cjs:12:908) + at async mo (/Users/laurenbrissette/Documents/GitHub (laurenbrissette)/mfa-form-automator/apps/web/node_modules/@hey-api/openapi-ts/dist/index.cjs:14:88219) + at async Promise.all (index 0) + at async Uv (/Users/laurenbrissette/Documents/GitHub (laurenbrissette)/mfa-form-automator/apps/web/node_modules/@hey-api/openapi-ts/dist/index.cjs:1311:4468) + at async start (/Users/laurenbrissette/Documents/GitHub (laurenbrissette)/mfa-form-automator/apps/web/node_modules/@hey-api/openapi-ts/bin/index.cjs:120:21) \ No newline at end of file diff --git a/apps/web/openapi-ts-error-1739504908576.log b/apps/web/openapi-ts-error-1739504908576.log new file mode 100644 index 00000000..642e813c --- /dev/null +++ b/apps/web/openapi-ts-error-1739504908576.log @@ -0,0 +1,11 @@ +Error requesting http://localhost:8080/api-json +fetch failed +ResolverError: Error requesting http://localhost:8080/api-json +fetch failed + at Object.sendRequest (/Users/laurenbrissette/Documents/GitHub (laurenbrissette)/mfa-form-automator/node_modules/@hey-api/json-schema-ref-parser/dist/lib/resolvers/url.js:44:15) + at process.processTicksAndRejections (node:internal/process/task_queues:105:5) + at async Gs (/Users/laurenbrissette/Documents/GitHub (laurenbrissette)/mfa-form-automator/apps/web/node_modules/@hey-api/openapi-ts/dist/index.cjs:12:908) + at async mo (/Users/laurenbrissette/Documents/GitHub (laurenbrissette)/mfa-form-automator/apps/web/node_modules/@hey-api/openapi-ts/dist/index.cjs:14:88219) + at async Promise.all (index 0) + at async Uv (/Users/laurenbrissette/Documents/GitHub (laurenbrissette)/mfa-form-automator/apps/web/node_modules/@hey-api/openapi-ts/dist/index.cjs:1311:4468) + at async start (/Users/laurenbrissette/Documents/GitHub (laurenbrissette)/mfa-form-automator/apps/web/node_modules/@hey-api/openapi-ts/bin/index.cjs:120:21) \ No newline at end of file diff --git a/apps/web/src/client/schemas.gen.ts b/apps/web/src/client/schemas.gen.ts index 147847e9..9fc89e42 100644 --- a/apps/web/src/client/schemas.gen.ts +++ b/apps/web/src/client/schemas.gen.ts @@ -450,6 +450,7 @@ export const CreateFormTemplateDtoSchema = { }, description: { type: 'string', + nullable: true, }, fieldGroups: { type: 'array', @@ -555,6 +556,7 @@ export const FormTemplateBaseEntitySchema = { }, description: { type: 'string', + nullable: true, }, createdAt: { format: 'date-time', @@ -565,14 +567,7 @@ export const FormTemplateBaseEntitySchema = { type: 'string', }, }, - required: [ - 'id', - 'name', - 'formDocLink', - 'description', - 'createdAt', - 'updatedAt', - ], + required: ['id', 'name', 'formDocLink', 'createdAt', 'updatedAt'], } as const; export const AssignedGroupEntitySchema = { @@ -692,6 +687,7 @@ export const FormInstanceEntitySchema = { }, description: { type: 'string', + nullable: true, }, formDocLink: { type: 'string', @@ -770,6 +766,7 @@ export const FormTemplateEntitySchema = { }, description: { type: 'string', + nullable: true, }, fieldGroups: { type: 'array', @@ -796,7 +793,6 @@ export const FormTemplateEntitySchema = { 'id', 'name', 'formDocLink', - 'description', 'fieldGroups', 'formInstances', 'createdAt', @@ -815,6 +811,7 @@ export const UpdateFormTemplateDtoSchema = { }, description: { type: 'string', + nullable: true, }, }, } as const; @@ -878,6 +875,7 @@ export const CreateFormInstanceDtoSchema = { }, description: { type: 'string', + nullable: true, }, assignedGroups: { type: 'array', @@ -913,6 +911,7 @@ export const UpdateFormInstanceDtoSchema = { }, description: { type: 'string', + nullable: true, }, formDocLink: { type: 'string', diff --git a/apps/web/src/client/types.gen.ts b/apps/web/src/client/types.gen.ts index 214ad740..e287a8e6 100644 --- a/apps/web/src/client/types.gen.ts +++ b/apps/web/src/client/types.gen.ts @@ -147,7 +147,7 @@ export type CreateFieldGroupDto = { export type CreateFormTemplateDto = { name: string; formDocLink: string; - description: string; + description: string | null; fieldGroups: Array; }; @@ -175,7 +175,7 @@ export type FormTemplateBaseEntity = { id: string; name: string; formDocLink: string; - description: string; + description?: string | null; createdAt: string; updatedAt: string; }; @@ -205,7 +205,7 @@ export type AssignedGroupEntity = { export type FormInstanceEntity = { id: string; name: string; - description: string; + description: string | null; formDocLink: string; completed: boolean; markedCompleted: boolean; @@ -224,7 +224,7 @@ export type FormTemplateEntity = { id: string; name: string; formDocLink: string; - description: string; + description?: string | null; fieldGroups: Array; formInstances: Array; createdAt: string; @@ -234,7 +234,7 @@ export type FormTemplateEntity = { export type UpdateFormTemplateDto = { name?: string; formDocLink?: string; - description?: string; + description?: string | null; }; export type CreateDepartmentDto = { @@ -257,7 +257,7 @@ export type CreateAssignedGroupDto = { export type CreateFormInstanceDto = { name: string; - description: string; + description: string | null; assignedGroups: Array; originatorId: string; formTemplateId: string; @@ -266,7 +266,7 @@ export type CreateFormInstanceDto = { export type UpdateFormInstanceDto = { name?: string; - description?: string; + description?: string | null; formDocLink?: string; }; diff --git a/apps/web/src/components/createFormInstance/CreateFormInstanceModal.tsx b/apps/web/src/components/createFormInstance/CreateFormInstanceModal.tsx index 9ba9441d..42fb28bb 100644 --- a/apps/web/src/components/createFormInstance/CreateFormInstanceModal.tsx +++ b/apps/web/src/components/createFormInstance/CreateFormInstanceModal.tsx @@ -112,7 +112,7 @@ const CreateFormInstanceModal: React.FC = ({ originatorId: user?.id!, formTemplateId: selectedFormTemplate?.id!, formDocLink: selectedFormTemplate?.formDocLink!, - description: selectedFormTemplate?.description!, + description: selectedFormTemplate?.description ? selectedFormTemplate?.description : null, }, }) .then((response) => {