Skip to content

Commit

Permalink
feat(highlight-field): new highlight field added to Team and Project …
Browse files Browse the repository at this point in the history
…table
  • Loading branch information
NivedhaSV authored and madan-ideas2it committed Jan 8, 2025
1 parent e5940ef commit c2b445b
Show file tree
Hide file tree
Showing 8 changed files with 30 additions and 6 deletions.
7 changes: 7 additions & 0 deletions apps/web-api/prisma/fixtures/project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,13 @@ const ProjectFactory = Factory.define<Omit<Project, 'id'>>(
createdBy: '',
maintainingTeamUid: '',
isFeatured: faker.datatype.boolean(),
highlightContent: [
{
text: faker.lorem.words(4),
link: faker.internet.url(),
showInCardView: faker.datatype.boolean()
}
],
projectLinks: [{
name: faker.company.name(),
url: faker.internet.url()
Expand Down
9 changes: 8 additions & 1 deletion apps/web-api/prisma/fixtures/teams.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,14 @@ const teamsFactory = Factory.define<Omit<Team, 'id'>>(
createdAt: faker.date.past(),
updatedAt: faker.date.recent(),
fundingStageUid: null,
lastModifiedBy: null
lastModifiedBy: null,
highlightContent: [
{
text: faker.lorem.words(4),
link: faker.internet.url(),
showInCardView: faker.datatype.boolean()
}
],
};
}
);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
-- AlterTable
ALTER TABLE "Project" ADD COLUMN "highlightContent" JSONB;

-- AlterTable
ALTER TABLE "Team" ADD COLUMN "highlightContent" JSONB;
2 changes: 2 additions & 0 deletions apps/web-api/prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ model Team {
teamFocusAreas TeamFocusArea[]
teamFocusAreasVersionHistory TeamFocusAreaVersionHistory[]
relatedQuestions DiscoveryQuestion[] @relation("TeamRelatedDiscoveryQuestions")
highlightContent Json?
}

model Member {
Expand Down Expand Up @@ -349,6 +350,7 @@ model Project {
projectFocusAreas ProjectFocusArea[]
contributions ProjectContribution[]
relatedQuestions DiscoveryQuestion[] @relation("ProjectRelatedDiscoveryQuestions")
highlightContent Json?
}

model PLEventLocation {
Expand Down
9 changes: 5 additions & 4 deletions apps/web-api/src/teams/__mocks__/teams.mocks.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { faker } from '@faker-js/faker';
import { FundingStage, Team } from '@prisma/client';
import { FundingStage, Prisma, Team } from '@prisma/client';
import { Factory } from 'fishery';
import { prisma } from '../../../prisma/__mocks__/index';
import { TestFactorySeederParams } from '../../utils/factory-interfaces';
Expand All @@ -23,7 +23,7 @@ async function createFundingStage() {
export async function createTeam({ amount }: TestFactorySeederParams) {
const fundingStage = await createFundingStage();

const teamFactory = Factory.define<Omit<Team, 'id'>>(({ sequence }) => {
const teamFactory = Factory.define<Omit<Prisma.TeamCreateManyInput, 'id'>>(({ sequence }) => {
const team = {
uid: `uid-${sequence}`,
name: `Team ${sequence}`,
Expand All @@ -44,8 +44,9 @@ export async function createTeam({ amount }: TestFactorySeederParams) {
createdAt: new Date(),
updatedAt: new Date(),
fundingStageUid: fundingStage.uid,
lastModifiedBy: null
};
lastModifiedBy: null,
highlightContent: {},
} as Prisma.TeamCreateManyInput;

return team;
});
Expand Down
2 changes: 1 addition & 1 deletion apps/web-api/src/teams/teams.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ export class TeamsService {
'name', 'blog', 'contactMethod', 'twitterHandler',
'linkedinHandler', 'telegramHandler', 'officeHours',
'shortDescription', 'website', 'airtableRecId',
'longDescription', 'moreDetails'
'longDescription', 'moreDetails', 'highlightContent'
];
copyObj(teamData, team, directFields);
// Handle one-to-one or one-to-many mappings
Expand Down
1 change: 1 addition & 0 deletions libs/contracts/src/schema/project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ const ProjectSchema = z.object({
name: z.string(),
url: z.string()
}).array().optional(),
highlightContent: z.object({text: z.string(),link:z.string(),showInCardView:z.boolean()}).array().optional(),
kpis: z.object({
key: z.string(),
value: z.string()
Expand Down
1 change: 1 addition & 0 deletions libs/contracts/src/schema/team.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ export const TeamSchema = z.object({
fundingStageUid: z.string().nullish(),
linkedinHandler: z.string().nullish(),
officeHours: z.string().nullish(),
highlightContent: z.object({text: z.string(),link:z.string(),showInCardView:z.boolean()}).array().optional()
});

export const CreateTeamSchema = TeamSchema.pick({
Expand Down

0 comments on commit c2b445b

Please sign in to comment.