Skip to content
This repository was archived by the owner on Jun 13, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
e398d5f
feat: confetti firework
beambeambeam Mar 16, 2025
78342eb
feat: page setup
beambeambeam Mar 16, 2025
11c7cdc
feat: confirmation backend
SupeemAFK Mar 21, 2025
72cdcc6
feat: add fetch confirm front and fix backend dto
SupeemAFK Mar 21, 2025
d304a1b
Confirmation components (#185)
beambeambeam Mar 22, 2025
fec6dbb
fix: faqs
beambeambeam Mar 22, 2025
0ce4d6a
feat: add question form
thrxpt Mar 22, 2025
be2b23e
refactor: cooler interface
thrxpt Mar 22, 2025
739cb05
Confirmation form (#187)
beambeambeam Mar 22, 2025
ccfb8f2
chore: move question
beambeambeam Mar 22, 2025
7cb0be1
feat: register page update
beambeambeam Mar 23, 2025
b5fc22e
feat: retry 1
beambeambeam Mar 23, 2025
fbbb811
feat: cool ass bg
beambeambeam Mar 23, 2025
7707c50
feat: button gradient on main
beambeambeam Mar 23, 2025
7f88511
feat: add upload file and add mutation and fix ineligible page
SupeemAFK Mar 23, 2025
cb56750
fix: resolve conflict
SupeemAFK Mar 23, 2025
7c0e995
fix: error message mutation
SupeemAFK Mar 23, 2025
29e59b3
feat: add mutation complete and fix input type
SupeemAFK Mar 23, 2025
1ce0108
fix: improve text
thrxpt Mar 23, 2025
087e047
feat: add infodone to db and change flow of confirmation
SupeemAFK Mar 23, 2025
6a03e1c
fix: resolve conflict
SupeemAFK Mar 23, 2025
8d8cab1
feat: add confirmation system and fix minor back
SupeemAFK Mar 23, 2025
df431c0
feat: support image
thrxpt Mar 23, 2025
bac48e4
feat: add caption support for image questions and choices
thrxpt Mar 23, 2025
8eba2b9
Confirm question (#188)
beambeambeam Mar 23, 2025
9b74bbc
feat: add code block formatting support
thrxpt Mar 23, 2025
e8d07a4
feat: update question formatting to use code block syntax
thrxpt Mar 23, 2025
87c456e
fix: fix datetime
SupeemAFK Mar 23, 2025
83c293b
fix: correct syntax and wording in question.json
thrxpt Mar 23, 2025
030888b
fix: space
thrxpt Mar 23, 2025
c15c8cb
feat: add arrow down
SupeemAFK Mar 23, 2025
3932e13
fix: fix gradient
SupeemAFK Mar 23, 2025
994f895
fix: spelling API
thrxpt Mar 23, 2025
685bd8d
fix: add more space between text and arrow
thrxpt Mar 23, 2025
f13ce22
fix: change db schema index to int and add gender
SupeemAFK Mar 23, 2025
39fffb3
Merge branch 'confirmation-page' of https://github.com/kmutt-cpe-stud…
SupeemAFK Mar 23, 2025
51d4610
fix: typo and wording in confirmation
gxjakkap Mar 23, 2025
0b3a0ec
fix: typo in confirmation consent
gxjakkap Mar 23, 2025
cd8c7c3
fix: spelling of notebook
thrxpt Mar 23, 2025
9cecaeb
chore: format code
thrxpt Mar 23, 2025
f0d785c
fix: visibility for example in confirmation form
gxjakkap Mar 24, 2025
320974e
feat: refetch after done question
beambeambeam Mar 24, 2025
6e7312f
feat: files update
beambeambeam Mar 24, 2025
9639ba9
feat: inview
beambeambeam Mar 24, 2025
729d5cd
feat: wait
beambeambeam Mar 24, 2025
5c0f08f
feat: button show what left
beambeambeam Mar 24, 2025
cc52b94
feat: backward button
beambeambeam Mar 24, 2025
3e83fea
feat: comment check result button
beambeambeam Mar 24, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
453 changes: 1 addition & 452 deletions apps/server/openapi.json

Large diffs are not rendered by default.

57 changes: 57 additions & 0 deletions apps/server/prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ model User {
answer_academic AnswerAcademic?
answer_regis AnswerRegis?
file File?
confirmation Confirmation?
answerConfirmation AnswerConfirm?
}

model File {
Expand Down Expand Up @@ -93,3 +95,58 @@ model Session {
user_id String
expire DateTime @db.Timestamptz(6)
}

model Confirmation {
user_id String @id @unique
index Int
gender String
fullname String
nickname String?
request_food String?
haveIpad Boolean?
haveMouse Boolean?
os_notebook String?
travel String?
receipt_path String?
receipt_datetime DateTime? @db.Timestamptz(6)
confirmation_status String
isInfoDone DateTime? @db.Timestamptz(6)
isAnswerDone DateTime? @db.Timestamptz(6)
isConfirmDone DateTime? @db.Timestamptz(6)
user User @relation(fields: [user_id], references: [id])
}

model AnswerConfirm {
user_id String @id @unique
question1 Int?
question2 Int?
question3 Int?
question4 Int?
question5 Int?
question6 Int?
question7 Int?
question8 Int?
question9 Int?
question10 Int?
question11 Int?
question12 Int?
question13 Int?
question14 Int?
question15 Int?
question16 Int?
question17 Int?
question18 Int?
question19 Int?
question20 Int?
question21 Int?
question22 Int?
question23 Int?
question24 Int?
question25 Int?
question26 Int?
question27 Int?
question28 Int?
question29 Int?
question30 Int?
user User @relation(fields: [user_id], references: [id])
}
2 changes: 2 additions & 0 deletions apps/server/src/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { AnswerModule } from './answer/answer.module';
import { AuthModule } from './auth/auth.module';
import { SessionModule } from './session/session.module';
import { AuthMiddleware } from './auth/auth.middleware';
import { ConfirmationModule } from './confirmation/confirmation.module';

@Module({
imports: [
Expand Down Expand Up @@ -38,6 +39,7 @@ import { AuthMiddleware } from './auth/auth.middleware';
UsersModule,
FilesModule,
AnswerModule,
ConfirmationModule,
],
controllers: [AppController],
providers: [AppService],
Expand Down
20 changes: 20 additions & 0 deletions apps/server/src/confirmation/confirmation.controller.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { Test, TestingModule } from '@nestjs/testing';
import { ConfirmationController } from './confirmation.controller';
import { ConfirmationService } from './confirmation.service';

describe('ConfirmationController', () => {
let controller: ConfirmationController;

beforeEach(async () => {
const module: TestingModule = await Test.createTestingModule({
controllers: [ConfirmationController],
providers: [ConfirmationService],
}).compile();

controller = module.get<ConfirmationController>(ConfirmationController);
});

it('should be defined', () => {
expect(controller).toBeDefined();
});
});
105 changes: 105 additions & 0 deletions apps/server/src/confirmation/confirmation.controller.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
import {
Body,
Controller,
Get,
HttpException,
HttpStatus,
Post,
Req,
UseGuards,
} from '@nestjs/common';
import { ConfirmationService } from './confirmation.service';
import { AuthGuard } from 'src/auth/auth.guard';
import { UpdateConfirmInfoDto } from './dto/UpdateConfirmInfo.dto';
import { CreateAnswerConfirmDto } from './dto/CreateAnswerConfirm.dto';
import { ApiResponse } from '@nestjs/swagger';
import { Confirm, ConfirmResponseDto } from './dto/ConfirmResponse.dto';
import { AnswerConfirmResponseDto } from './dto/AnswerConfirmResponse.dto';
import { UpdateConfirmDto } from './dto/UpdateConfirm.dto';

@Controller('confirmation')
@UseGuards(AuthGuard)
export class ConfirmationController {
constructor(private readonly confirmationService: ConfirmationService) {}

@Get('user-confirmation')
@ApiResponse({ status: 200, type: ConfirmResponseDto })
async getUserConfirmation(@Req() req: Request) {
if (!req['user_id']) {
throw new HttpException('UNAUTHORIZED', HttpStatus.UNAUTHORIZED);
}
const confirm = await this.confirmationService.findConfirm(req['user_id']);
if (!confirm) {
return { isPassed: false, confirm: null };
}
return { isPassed: true, confirm };
}

@Post('user-confirmation-info')
@ApiResponse({ status: 200, type: Confirm })
async updateUserConfirmationInfo(
@Req() req: Request,
@Body() updateConfirmDto: UpdateConfirmInfoDto,
) {
if (!req['user_id']) {
throw new HttpException('UNAUTHORIZED', HttpStatus.UNAUTHORIZED);
}
const confirm = await this.confirmationService.findConfirm(req['user_id']);
if (!confirm || confirm.confirmation_status == 'reserved') {
throw new HttpException('UNAUTHORIZED', HttpStatus.UNAUTHORIZED);
}
return this.confirmationService.updateConfirmInfo(
req['user_id'],
updateConfirmDto,
);
}

@Post('user-confirmation')
@ApiResponse({ status: 200, type: Confirm })
async updateUserConfirmation(
@Req() req: Request,
@Body() updateConfirmDto: UpdateConfirmDto,
) {
if (!req['user_id']) {
throw new HttpException('UNAUTHORIZED', HttpStatus.UNAUTHORIZED);
}
const confirm = await this.confirmationService.findConfirm(req['user_id']);
if (!confirm || confirm.confirmation_status == 'reserved') {
throw new HttpException('UNAUTHORIZED', HttpStatus.UNAUTHORIZED);
}

if (
updateConfirmDto.confirmation_status != 'yes' &&
updateConfirmDto.confirmation_status != 'no'
) {
throw new HttpException(
'INVALID CONFIRMATION STATUS',
HttpStatus.BAD_REQUEST,
);
}

return this.confirmationService.updateConfirm(
req['user_id'],
updateConfirmDto,
);
}

@Post('user-answer-confirmation')
@ApiResponse({ status: 200, type: AnswerConfirmResponseDto })
async createUserAnswerConfirmation(
@Req() req: Request,
@Body() createAnswerConfirmDto: CreateAnswerConfirmDto,
) {
if (!req['user_id']) {
throw new HttpException('UNAUTHORIZED', HttpStatus.UNAUTHORIZED);
}
const confirm = await this.confirmationService.findConfirm(req['user_id']);
if (!confirm || confirm.confirmation_status == 'reserved') {
throw new HttpException('UNAUTHORIZED', HttpStatus.UNAUTHORIZED);
}
return this.confirmationService.createAnswerConfirm(
req['user_id'],
createAnswerConfirmDto,
);
}
}
9 changes: 9 additions & 0 deletions apps/server/src/confirmation/confirmation.module.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { Module } from '@nestjs/common';
import { ConfirmationService } from './confirmation.service';
import { ConfirmationController } from './confirmation.controller';

@Module({
controllers: [ConfirmationController],
providers: [ConfirmationService],
})
export class ConfirmationModule {}
18 changes: 18 additions & 0 deletions apps/server/src/confirmation/confirmation.service.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { Test, TestingModule } from '@nestjs/testing';
import { ConfirmationService } from './confirmation.service';

describe('ConfirmationService', () => {
let service: ConfirmationService;

beforeEach(async () => {
const module: TestingModule = await Test.createTestingModule({
providers: [ConfirmationService],
}).compile();

service = module.get<ConfirmationService>(ConfirmationService);
});

it('should be defined', () => {
expect(service).toBeDefined();
});
});
56 changes: 56 additions & 0 deletions apps/server/src/confirmation/confirmation.service.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import { Injectable } from '@nestjs/common';
import { PrismaService } from 'src/prisma/prisma.service';
import { UpdateConfirmInfoDto } from './dto/UpdateConfirmInfo.dto';
import { CreateAnswerConfirmDto } from './dto/CreateAnswerConfirm.dto';
import { UpdateConfirmDto } from './dto/UpdateConfirm.dto';

@Injectable()
export class ConfirmationService {
constructor(private prisma: PrismaService) {}

findConfirm(userId: string) {
return this.prisma.confirmation.findUnique({ where: { user_id: userId } });
}

updateConfirmInfo(userId: string, updateConfirmDto: UpdateConfirmInfoDto) {
return this.prisma.confirmation.update({
where: { user_id: userId },
data: {
...updateConfirmDto,
isInfoDone: new Date(),
},
});
}

updateConfirm(userId: string, updateConfirmDto: UpdateConfirmDto) {
return this.prisma.confirmation.update({
where: { user_id: userId },
data: {
confirmation_status: updateConfirmDto.confirmation_status,
isConfirmDone: new Date(),
},
});
}

async createAnswerConfirm(
userId: string,
createAnswerConfirmDto: CreateAnswerConfirmDto,
) {
await this.prisma.confirmation.update({
where: { user_id: userId },
data: {
isAnswerDone: new Date(),
},
});
return this.prisma.answerConfirm.upsert({
where: { user_id: userId },
create: {
user_id: userId,
...createAnswerConfirmDto,
},
update: {
...createAnswerConfirmDto,
},
});
}
}
Loading
Loading