mirror of
https://github.com/aljazceru/landscape-template.git
synced 2026-02-01 04:34:38 +01:00
feat: add recruit_roles to project DB modal/api
This commit is contained in:
@@ -436,6 +436,7 @@ export interface NexusGenFieldTypes {
|
||||
id: number; // Int!
|
||||
lightning_address: string | null; // String
|
||||
lnurl_callback_url: string | null; // String
|
||||
recruit_roles: NexusGenRootTypes['MakerRole'][]; // [MakerRole!]!
|
||||
screenshots: string[]; // [String!]!
|
||||
tags: NexusGenRootTypes['Tag'][]; // [Tag!]!
|
||||
thumbnail_image: string; // String!
|
||||
@@ -728,6 +729,7 @@ export interface NexusGenFieldTypeNames {
|
||||
id: 'Int'
|
||||
lightning_address: 'String'
|
||||
lnurl_callback_url: 'String'
|
||||
recruit_roles: 'MakerRole'
|
||||
screenshots: 'String'
|
||||
tags: 'Tag'
|
||||
thumbnail_image: 'String'
|
||||
|
||||
@@ -234,6 +234,7 @@ type Project {
|
||||
id: Int!
|
||||
lightning_address: String
|
||||
lnurl_callback_url: String
|
||||
recruit_roles: [MakerRole!]!
|
||||
screenshots: [String!]!
|
||||
tags: [Tag!]!
|
||||
thumbnail_image: String!
|
||||
|
||||
@@ -8,6 +8,7 @@ const {
|
||||
const { prisma } = require('../../../prisma');
|
||||
|
||||
const { paginationArgs, getLnurlDetails, lightningAddressToLnurl } = require('./helpers');
|
||||
const { MakerRole } = require('./users');
|
||||
|
||||
|
||||
const Project = objectType({
|
||||
@@ -44,6 +45,28 @@ const Project = objectType({
|
||||
return prisma.project.findUnique({ where: { id: parent.id } }).tags();
|
||||
}
|
||||
})
|
||||
|
||||
t.nonNull.list.nonNull.field('recruit_roles', {
|
||||
type: MakerRole,
|
||||
resolve: async (parent) => {
|
||||
const data = await prisma.project.findUnique({
|
||||
where: {
|
||||
id: parent.id
|
||||
},
|
||||
select: {
|
||||
recruit_roles: {
|
||||
select: {
|
||||
role: true,
|
||||
level: true
|
||||
}
|
||||
},
|
||||
}
|
||||
})
|
||||
return data.recruit_roles.map(data => {
|
||||
return ({ ...data.role, level: data.level })
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
@@ -451,6 +451,7 @@ module.exports = {
|
||||
User,
|
||||
MyProfile,
|
||||
WalletKey,
|
||||
MakerRole,
|
||||
// Queries
|
||||
me,
|
||||
profile,
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
-- CreateTable
|
||||
CREATE TABLE "ProjectRecruitRoles" (
|
||||
"projectId" INTEGER NOT NULL,
|
||||
"roleId" INTEGER NOT NULL,
|
||||
"level" INTEGER NOT NULL,
|
||||
|
||||
CONSTRAINT "ProjectRecruitRoles_pkey" PRIMARY KEY ("projectId","roleId")
|
||||
);
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "ProjectRecruitRoles" ADD CONSTRAINT "ProjectRecruitRoles_roleId_fkey" FOREIGN KEY ("roleId") REFERENCES "WorkRole"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "ProjectRecruitRoles" ADD CONSTRAINT "ProjectRecruitRoles_projectId_fkey" FOREIGN KEY ("projectId") REFERENCES "Project"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
@@ -89,10 +89,11 @@ model UsersOnWorkRoles {
|
||||
}
|
||||
|
||||
model WorkRole {
|
||||
id Int @id @default(autoincrement())
|
||||
title String @unique
|
||||
icon String
|
||||
users UsersOnWorkRoles[]
|
||||
id Int @id @default(autoincrement())
|
||||
title String @unique
|
||||
icon String
|
||||
users UsersOnWorkRoles[]
|
||||
projects ProjectRecruitRoles[]
|
||||
}
|
||||
|
||||
model Skill {
|
||||
@@ -133,6 +134,19 @@ model Project {
|
||||
|
||||
awards Award[]
|
||||
tags Tag[]
|
||||
|
||||
recruit_roles ProjectRecruitRoles[]
|
||||
}
|
||||
|
||||
model ProjectRecruitRoles {
|
||||
project Project @relation(fields: [projectId], references: [id])
|
||||
projectId Int
|
||||
role WorkRole @relation(fields: [roleId], references: [id])
|
||||
roleId Int
|
||||
|
||||
level Int
|
||||
|
||||
@@id([projectId, roleId])
|
||||
}
|
||||
|
||||
model Award {
|
||||
|
||||
Reference in New Issue
Block a user