diff --git a/app/src/db/migrations/20240327000000_001-bring-forward.ts b/app/src/db/migrations/20240327000000_001-bring-forward.ts new file mode 100644 index 00000000..047d994c --- /dev/null +++ b/app/src/db/migrations/20240327000000_001-bring-forward.ts @@ -0,0 +1,31 @@ +import type { Knex } from 'knex'; + +export async function up(knex: Knex): Promise { + return Promise.resolve() + .then(() => + knex.schema.alterTable('submission', function (table) { + table.dropColumn('bring_forward_date'); + }) + ) + .then(() => + knex.schema.alterTable('note', function (table) { + table.timestamp('bring_forward_date', { useTz: true }); + table.text('bring_forward_state').nullable(); + }) + ); +} + +export async function down(knex: Knex): Promise { + return Promise.resolve() + .then(() => + knex.schema.alterTable('submission', function (table) { + table.timestamp('bring_forward_date', { useTz: true }); + }) + ) + .then(() => + knex.schema.alterTable('note', function (table) { + table.dropColumn('bring_forward_date'); + table.dropColumn('bring_forward_state'); + }) + ); +} diff --git a/app/src/db/models/note.ts b/app/src/db/models/note.ts index 55111bf8..7d0c2dd6 100644 --- a/app/src/db/models/note.ts +++ b/app/src/db/models/note.ts @@ -14,6 +14,8 @@ export default { return { note_id: input.noteId, activity_id: input.activityId, + bring_forward_date: input.bringForwardDate ? new Date(input.bringForwardDate) : null, + bring_forward_state: input.bringForwardState, note: input.note, note_type: input.noteType, title: input.title, @@ -30,6 +32,8 @@ export default { return { noteId: input.note_id, activityId: input.activity_id, + bringForwardDate: input.bring_forward_date?.toISOString() ?? null, + bringForwardState: input.bring_forward_state ?? null, note: input.note || '', noteType: input.note_type || '', title: input.title || '', diff --git a/app/src/db/models/submission.ts b/app/src/db/models/submission.ts index 47294f45..ffda2b07 100644 --- a/app/src/db/models/submission.ts +++ b/app/src/db/models/submission.ts @@ -48,7 +48,6 @@ export default { financially_supported_housing_coop: input.financiallySupportedHousingCoop, aai_updated: input.aaiUpdated, waiting_on: input.waitingOn, - bring_forward_date: input.bringForwardDate ? new Date(input.bringForwardDate) : null, intake_status: input.intakeStatus, application_status: input.applicationStatus, guidance: input.guidance, @@ -94,7 +93,6 @@ export default { financiallySupportedHousingCoop: input.financially_supported_housing_coop, aaiUpdated: input.aai_updated, waitingOn: input.waiting_on, - bringForwardDate: input.bring_forward_date?.toISOString() ?? null, intakeStatus: input.intake_status, applicationStatus: input.application_status, guidance: input.guidance, diff --git a/app/src/db/prisma/schema.prisma b/app/src/db/prisma/schema.prisma index ba3cc922..8a5f4ffe 100644 --- a/app/src/db/prisma/schema.prisma +++ b/app/src/db/prisma/schema.prisma @@ -70,16 +70,18 @@ model initiative { } model note { - note_id String @id @db.Uuid - activity_id String - note String @default("") - note_type String @default("") - title String @default("") - created_by String? @default("00000000-0000-0000-0000-000000000000") - created_at DateTime? @default(now()) @db.Timestamptz(6) - updated_by String? - updated_at DateTime? @db.Timestamptz(6) - activity activity @relation(fields: [activity_id], references: [activity_id], onDelete: Cascade, map: "note_activity_id_foreign") + note_id String @id @db.Uuid + activity_id String + note String @default("") + note_type String @default("") + title String @default("") + created_by String? @default("00000000-0000-0000-0000-000000000000") + created_at DateTime? @default(now()) @db.Timestamptz(6) + updated_by String? + updated_at DateTime? @db.Timestamptz(6) + bring_forward_date DateTime? @db.Timestamptz(6) + bring_forward_state String? + activity activity @relation(fields: [activity_id], references: [activity_id], onDelete: Cascade, map: "note_activity_id_foreign") } model permit { @@ -156,7 +158,6 @@ model submission { financially_supported_housing_coop Boolean @default(false) aai_updated Boolean @default(false) waiting_on String? - bring_forward_date DateTime? @db.Timestamptz(6) intake_status String? application_status String? guidance Boolean @default(false) diff --git a/app/src/types/Note.ts b/app/src/types/Note.ts index 183c0c89..53192d4b 100644 --- a/app/src/types/Note.ts +++ b/app/src/types/Note.ts @@ -3,6 +3,8 @@ import { IStamps } from '../interfaces/IStamps'; export type Note = { noteId: string; // Primary Key activityId: string; + bringForwardDate: string | null; + bringForwardState: string | null; note: string; noteType: string; title: string; diff --git a/app/src/types/Submission.ts b/app/src/types/Submission.ts index f7c1bd90..24195012 100644 --- a/app/src/types/Submission.ts +++ b/app/src/types/Submission.ts @@ -34,7 +34,6 @@ export type Submission = { financiallySupportedHousingCoop: boolean; aaiUpdated: boolean; waitingOn: string | null; - bringForwardDate: string | null; intakeStatus: string | null; applicationStatus: string | null; guidance: boolean; diff --git a/app/src/validators/note.ts b/app/src/validators/note.ts index 31dee803..53ac3d1c 100644 --- a/app/src/validators/note.ts +++ b/app/src/validators/note.ts @@ -8,6 +8,8 @@ const schema = { body: Joi.object({ createdAt: Joi.date().required(), activityId: activityId, + bringForwardDate: Joi.date().iso().allow(null), + bringForwardState: Joi.string().min(1).allow(null), note: Joi.string(), noteType: Joi.string().max(255).required(), title: Joi.string().max(255) diff --git a/app/tests/unit/controllers/note.spec.ts b/app/tests/unit/controllers/note.spec.ts index 9c50a0d6..90be9e9f 100644 --- a/app/tests/unit/controllers/note.spec.ts +++ b/app/tests/unit/controllers/note.spec.ts @@ -39,6 +39,8 @@ describe('createNote', () => { body: { noteId: '123-123', activityId: '123', + bringForwardDate: null, + bringForwardState: null, note: 'Some not text', noteType: 'GENERAL', title: 'Note title' @@ -52,6 +54,8 @@ describe('createNote', () => { const created = { noteId: '123-123', activityId: '123', + bringForwardDate: null, + bringForwardState: null, note: 'Some not text', noteType: 'GENERAL', title: 'Note title' @@ -79,6 +83,8 @@ describe('createNote', () => { body: { noteId: '123-123', activityId: '123', + bringForwardDate: null, + bringForwardState: null, note: 'Some not text', noteType: 'GENERAL', title: 'Note title' @@ -120,6 +126,8 @@ describe('listNotes', () => { { noteId: '123-123', activityId: '123', + bringForwardDate: null, + bringForwardState: null, note: 'Some not text', noteType: 'GENERAL', title: 'Note title' diff --git a/frontend/src/components/note/NoteCard.vue b/frontend/src/components/note/NoteCard.vue index 819cb1d4..b04847a8 100644 --- a/frontend/src/components/note/NoteCard.vue +++ b/frontend/src/components/note/NoteCard.vue @@ -3,7 +3,7 @@ import { onMounted, ref } from 'vue'; import { Card, Divider } from '@/lib/primevue'; import { userService } from '@/services'; -import { formatDateShort } from '@/utils/formatters'; +import { formatDate, formatDateShort } from '@/utils/formatters'; import type { Ref } from 'vue'; import type { Note } from '@/types'; @@ -30,13 +30,21 @@ onMounted(() => {