diff --git a/README.md b/README.md index 390913f5..07c8a384 100644 --- a/README.md +++ b/README.md @@ -28,7 +28,7 @@ RT_SECRET= MJ_APIKEY_PRIVATE= MJ_APIKEY_PUBLIC= NODE_ENV=development -FRONTEND_URL=https://chingu-dashboard.vercel.app +FRONTEND_URL=https://chingu-dashboard-git-dev-chingu-dashboard.vercel.app/ BCRYPT_HASHING_ROUNDS=10 # .env.test diff --git a/prisma/migrations/20240121062627_add_status_to_voyage/migration.sql b/prisma/migrations/20240121062627_add_status_to_voyage/migration.sql new file mode 100644 index 00000000..7ef63937 --- /dev/null +++ b/prisma/migrations/20240121062627_add_status_to_voyage/migration.sql @@ -0,0 +1,5 @@ +-- AlterTable +ALTER TABLE "Voyage" ADD COLUMN "statusId" INTEGER; + +-- AddForeignKey +ALTER TABLE "Voyage" ADD CONSTRAINT "Voyage_statusId_fkey" FOREIGN KEY ("statusId") REFERENCES "VoyageStatus"("id") ON DELETE SET NULL ON UPDATE CASCADE; diff --git a/prisma/schema.prisma b/prisma/schema.prisma index 246ab6c6..367118c3 100644 --- a/prisma/schema.prisma +++ b/prisma/schema.prisma @@ -85,13 +85,15 @@ model EmailVerificationToken { // === Voyage - Schedule, sprint dates and Teams === model Voyage { - id Int @id @default(autoincrement()) - number String @unique - startDate DateTime @db.Timestamptz() - endDate DateTime @db.Timestamptz() - soloProjectDeadline DateTime @db.Timestamptz() - certificateIssueDate DateTime @db.Timestamptz() - showcasePublishDate DateTime? @db.Timestamptz() + id Int @id @default(autoincrement()) + number String @unique + status VoyageStatus? @relation(fields: [statusId], references: [id], onDelete: SetNull) + statusId Int? + startDate DateTime @db.Timestamptz() + endDate DateTime @db.Timestamptz() + soloProjectDeadline DateTime @db.Timestamptz() + certificateIssueDate DateTime @db.Timestamptz() + showcasePublishDate DateTime? @db.Timestamptz() createdAt DateTime @default(now()) @db.Timestamptz() updatedAt DateTime @updatedAt @@ -127,6 +129,7 @@ model VoyageStatus { voyageTeams VoyageTeam[] voyageTeamMembers VoyageTeamMember[] + Voyage Voyage[] } model Tier { diff --git a/prisma/seed/data/voyage-status.ts b/prisma/seed/data/voyage-status.ts index 7a636068..075a059c 100644 --- a/prisma/seed/data/voyage-status.ts +++ b/prisma/seed/data/voyage-status.ts @@ -8,4 +8,18 @@ export default [ description: "member has dropped from the voyage or the team has disbanded", }, + { + name: "Inactive", + description: + "member is inactive or the team is inactive. " + + "If a voyage status is inactive, member will still be able to access it", + }, + { + name: "Upcoming", + description: "Upcoming voyage", + }, + { + name: "Locked", + description: "Voyage is locked, read only mode", + }, ]; diff --git a/prisma/seed/data/voyages.ts b/prisma/seed/data/voyages.ts deleted file mode 100644 index dbd812ab..00000000 --- a/prisma/seed/data/voyages.ts +++ /dev/null @@ -1,23 +0,0 @@ -export default [ - { - number: "47", - startDate: new Date("2024-01-08"), - endDate: new Date("2024-02-18"), - soloProjectDeadline: new Date("2023-12-31"), - certificateIssueDate: new Date("2024-02-25"), - }, - { - number: "48", - startDate: new Date("2024-03-05"), - endDate: new Date("2024-04-14"), - soloProjectDeadline: new Date("2024-02-25"), - certificateIssueDate: new Date("2024-04-21"), - }, - { - number: "49", - startDate: new Date("2024-05-06"), - endDate: new Date("2024-06-16"), - soloProjectDeadline: new Date("2024-04-28"), - certificateIssueDate: new Date("2024-06-23"), - }, -]; diff --git a/prisma/seed/index.ts b/prisma/seed/index.ts index 760e79c0..9f52ed3d 100644 --- a/prisma/seed/index.ts +++ b/prisma/seed/index.ts @@ -3,13 +3,14 @@ import * as process from "process"; import { populateTeamResourcesAndProjectIdeas } from "./resources-project-ideas"; import { populateTables } from "./tables"; import { populateFormsAndResponses } from "./forms"; -import { populateVoyageTeams } from "./voyageTeams"; +import { populateVoyageTeams } from "./voyage-teams"; import { populateUsers } from "./users"; import { populateSprints } from "./sprints"; import { populateMeetings } from "./meetings"; import { populateSoloProjects } from "./solo-project"; import { populateVoyageApplications } from "./voyage-app"; import { populateChecklists } from "./checklist"; +import { populateVoyages } from "./voyage"; const prisma = new PrismaClient(); @@ -38,6 +39,7 @@ const deleteAllTables = async () => { try { await deleteAllTables(); await populateTables(); // tables with no relations + await populateVoyages(); await populateUsers(); await populateSprints(); await populateVoyageTeams(); diff --git a/prisma/seed/tables.ts b/prisma/seed/tables.ts index 890132d9..39afea0e 100644 --- a/prisma/seed/tables.ts +++ b/prisma/seed/tables.ts @@ -7,7 +7,6 @@ import VoyageRoles from "./data/voyage-roles"; import VoyageStatus from "./data/voyage-status"; import TechStackCategories from "./data/tech-stack-categories"; -import Voyages from "./data/voyages"; import FeatureCategories from "./data/feature-categories"; import FormTypes from "./data/form-types"; @@ -27,7 +26,6 @@ export const populateTables = async () => { await populateTable("voyageRole", VoyageRoles); await populateTable("voyageStatus", VoyageStatus); await populateTable("techStackCategory", TechStackCategories); - await populateTable("voyage", Voyages); await populateTable("featureCategory", FeatureCategories); await populateTable("formType", FormTypes); await populateTable("inputType", InputTypes); diff --git a/prisma/seed/voyageTeams.ts b/prisma/seed/voyage-teams.ts similarity index 100% rename from prisma/seed/voyageTeams.ts rename to prisma/seed/voyage-teams.ts diff --git a/prisma/seed/voyage.ts b/prisma/seed/voyage.ts new file mode 100644 index 00000000..0185b347 --- /dev/null +++ b/prisma/seed/voyage.ts @@ -0,0 +1,48 @@ +import { PrismaClient } from "@prisma/client"; + +const prisma = new PrismaClient(); + +export const populateVoyages = async () => { + await prisma.voyage.create({ + data: { + number: "47", + status: { + connect: { + name: "Active", + }, + }, + startDate: new Date("2024-01-08"), + endDate: new Date("2024-02-18"), + soloProjectDeadline: new Date("2023-12-31"), + certificateIssueDate: new Date("2024-02-25"), + }, + }); + await prisma.voyage.create({ + data: { + number: "48", + status: { + connect: { + name: "Upcoming", + }, + }, + startDate: new Date("2024-03-05"), + endDate: new Date("2024-04-14"), + soloProjectDeadline: new Date("2024-02-25"), + certificateIssueDate: new Date("2024-04-21"), + }, + }); + await prisma.voyage.create({ + data: { + number: "49", + status: { + connect: { + name: "Upcoming", + }, + }, + startDate: new Date("2024-05-06"), + endDate: new Date("2024-06-16"), + soloProjectDeadline: new Date("2024-04-28"), + certificateIssueDate: new Date("2024-06-23"), + }, + }); +}; diff --git a/src/users/users.response.ts b/src/users/users.response.ts index 3eac7c45..558e54ef 100644 --- a/src/users/users.response.ts +++ b/src/users/users.response.ts @@ -41,9 +41,17 @@ class VoyageTeamWithoutMember { updatedAt: Date; } +class Voyage { + @ApiProperty() + status: VoyageStatus; +} + class VoyageTeam { @ApiProperty({ example: "v47-tier2-team-4" }) name: string; + + @ApiProperty() + voyage: Voyage; } class UserVoyageTeam { diff --git a/src/users/users.service.ts b/src/users/users.service.ts index 695e0b37..ef20bf56 100644 --- a/src/users/users.service.ts +++ b/src/users/users.service.ts @@ -50,6 +50,7 @@ export class UsersService { }); } + // /me endpoint, user's own profile/data getPrivateUserProfile(userId: string) { return this.prisma.user.findUnique({ where: { @@ -68,12 +69,24 @@ export class UsersService { countryCode: true, timezone: true, voyageTeamMembers: { + orderBy: { + voyageTeamId: "desc", + }, select: { id: true, voyageTeamId: true, voyageTeam: { select: { name: true, + voyage: { + select: { + status: { + select: { + name: true, + }, + }, + }, + }, }, }, voyageRole: {