-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0c45965
commit b395ced
Showing
14 changed files
with
221 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
apps/back-end/src/form-question/form-question.controller.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { Test, TestingModule } from '@nestjs/testing'; | ||
import { FormQuestionController } from './form-question.controller'; | ||
|
||
describe('FormQuestionController', () => { | ||
let controller: FormQuestionController; | ||
|
||
beforeEach(async () => { | ||
const module: TestingModule = await Test.createTestingModule({ | ||
controllers: [FormQuestionController], | ||
}).compile(); | ||
|
||
controller = module.get<FormQuestionController>(FormQuestionController); | ||
}); | ||
|
||
it('should be defined', () => { | ||
expect(controller).toBeDefined(); | ||
}); | ||
}); |
22 changes: 22 additions & 0 deletions
22
apps/back-end/src/form-question/form-question.controller.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { Controller, Get, Param, Query, UseGuards } from '@nestjs/common'; | ||
import { JwtAuthGuard } from '../auth/guards/jwt-auth.guard'; | ||
import { FormService } from '../form/form.service'; | ||
import { FormQuestionService } from './form-question.service'; | ||
|
||
@UseGuards(JwtAuthGuard) | ||
@Controller('form-question') | ||
export class FormQuestionController { | ||
constructor( | ||
private formQuestionService: FormQuestionService, | ||
private formService: FormService | ||
) {} | ||
@Get() | ||
findMany() { | ||
return this.formQuestionService.findMany(); | ||
} | ||
@Get(':formUuid') | ||
findFormQuestions(@Query() formUuid: string) { | ||
console.log('formUuid', formUuid); | ||
return this.formService.findFormQuestionsByUuid(formUuid); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { Module } from '@nestjs/common'; | ||
import { PrismaService } from '../app/prisma/prisma.service'; | ||
import { FormService } from '../form/form.service'; | ||
import { FormQuestionController } from './form-question.controller'; | ||
import { FormQuestionService } from './form-question.service'; | ||
|
||
@Module({ | ||
controllers: [FormQuestionController], | ||
providers: [FormQuestionService, PrismaService, FormService], | ||
}) | ||
export class FormQuestionModule {} |
18 changes: 18 additions & 0 deletions
18
apps/back-end/src/form-question/form-question.service.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { Test, TestingModule } from '@nestjs/testing'; | ||
import { FormQuestionService } from './form-question.service'; | ||
|
||
describe('FormQuestionService', () => { | ||
let service: FormQuestionService; | ||
|
||
beforeEach(async () => { | ||
const module: TestingModule = await Test.createTestingModule({ | ||
providers: [FormQuestionService], | ||
}).compile(); | ||
|
||
service = module.get<FormQuestionService>(FormQuestionService); | ||
}); | ||
|
||
it('should be defined', () => { | ||
expect(service).toBeDefined(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { Injectable } from '@nestjs/common'; | ||
import { PrismaService } from '../app/prisma/prisma.service'; | ||
|
||
@Injectable() | ||
export class FormQuestionService { | ||
constructor(private prismaService: PrismaService) {} | ||
findMany() { | ||
return this.prismaService.formQuestion.findMany({ | ||
select: { | ||
uuid: true, | ||
form: { | ||
select: { | ||
uuid: true, | ||
name: true, | ||
}, | ||
}, | ||
question: { | ||
select: { | ||
uuid: true, | ||
question: true, | ||
}, | ||
}, | ||
}, | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
apps/front-end/src/app/components/forms/form-builder/form-builder.module.css
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
/* | ||
* Replace this with your own classes | ||
* | ||
* e.g. | ||
* .container { | ||
* } | ||
*/ |
10 changes: 10 additions & 0 deletions
10
apps/front-end/src/app/components/forms/form-builder/form-builder.spec.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { render } from '@testing-library/react'; | ||
|
||
import FormBuilder from './form-builder'; | ||
|
||
describe('FormBuilder', () => { | ||
it('should render successfully', () => { | ||
const { baseElement } = render(<FormBuilder />); | ||
expect(baseElement).toBeTruthy(); | ||
}); | ||
}); |
15 changes: 15 additions & 0 deletions
15
apps/front-end/src/app/components/forms/form-builder/form-builder.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { useLoaderData } from 'react-router-dom'; | ||
|
||
/* eslint-disable-next-line */ | ||
export interface FormBuilderProps {} | ||
|
||
export function FormBuilder(props: FormBuilderProps) { | ||
const data = useLoaderData() as { formUuid: string }; | ||
return ( | ||
<div> | ||
<h1>Welcome to FormBuilder!</h1> | ||
</div> | ||
); | ||
} | ||
|
||
export default FormBuilder; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
prisma/migrations/20230719153331_added_form_question_table/migration.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
-- CreateTable | ||
CREATE TABLE "FormQuestion" ( | ||
"id" SERIAL NOT NULL, | ||
"formId" INTEGER NOT NULL, | ||
"questionId" INTEGER NOT NULL, | ||
"uuid" TEXT NOT NULL, | ||
"voided" BOOLEAN NOT NULL DEFAULT false, | ||
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, | ||
"updatedAt" TIMESTAMP(3) NOT NULL, | ||
|
||
CONSTRAINT "FormQuestion_pkey" PRIMARY KEY ("id") | ||
); | ||
|
||
-- AddForeignKey | ||
ALTER TABLE "FormQuestion" ADD CONSTRAINT "FormQuestion_formId_fkey" FOREIGN KEY ("formId") REFERENCES "Form"("id") ON DELETE RESTRICT ON UPDATE CASCADE; | ||
|
||
-- AddForeignKey | ||
ALTER TABLE "FormQuestion" ADD CONSTRAINT "FormQuestion_questionId_fkey" FOREIGN KEY ("questionId") REFERENCES "Question"("id") ON DELETE RESTRICT ON UPDATE CASCADE; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters