diff --git a/package-lock.json b/package-lock.json index 772f066..4281071 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "backend-8tech", - "version": "4.1.6", + "version": "4.1.7", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "backend-8tech", - "version": "4.1.6", + "version": "4.1.7", "license": "UNLICENSED", "dependencies": { "@nestjs/common": "^9.4.3", diff --git a/package.json b/package.json index 2a9902c..c14e03f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "backend-8tech", - "version": "4.1.6", + "version": "4.1.7", "description": "", "author": "8tech", "private": true, diff --git a/prisma/schema.prisma b/prisma/schema.prisma index 99d4a75..488bb1f 100644 --- a/prisma/schema.prisma +++ b/prisma/schema.prisma @@ -108,15 +108,15 @@ enum Role { } enum ContractStatus { - PENDING - ACCEPTED - REJECTED - ONGOING - COMPLETED + PENDING //default & menunggu konfirmasi recruiter + ACCEPTED //diterima recruiter tapi kontrak bleum deal + REJECTED //ditolak recruiter + ONGOING //kontrak sudah deal (kl kontrak yg di tawarin recuiter di acc sama freelancer) + COMPLETED // recruiter udah bayar (payment status = paid) } enum PaymentStatus { - PENDING - PAID - FAILED + PENDING //default + PAID //dibayar recruiter + ACCEPTED //diterima freelancer (guard biar paid out 2 kali) } diff --git a/src/contract/contract.controller.ts b/src/contract/contract.controller.ts index c5156db..a4f3d5f 100644 --- a/src/contract/contract.controller.ts +++ b/src/contract/contract.controller.ts @@ -10,10 +10,12 @@ import { Param, Redirect, Req, + Request, } from '@nestjs/common'; import { ApiBearerAuth, ApiBody, + ApiCookieAuth, ApiParam, ApiResponse, ApiTags, @@ -187,4 +189,46 @@ export class ContractController { ); return response; } + + @ApiBearerAuth() + @ApiCookieAuth() + @ApiParam({ + name: 'contractId', + type: String, + description: 'contractId of the job vacancy that want to be deleted', + }) + @ApiResponse({ + schema: { + example: { + status: true, + statusCode: 200, + data: { + id: '19eb7629-3cc4-49ec-8a50-eba25f9d2a62', + userId: 'd557b674-7f45-4734-9115-2ef1154959bc', + jobId: '9a6402b9-9a20-4ab1-bb15-9324398cef39', + paymentId: null, + title: + 'Lowongan pekerjaan Enna Alouette for d557b674-7f45-4734-9115-2ef1154959bc', + description: 'Contract for the following job description: auauaaa', + paymentRate: null, + template: null, + createdAt: '2024-01-16T17:35:13.586Z', + updatedAt: '2024-01-16T17:35:13.586Z', + status: 'PENDING', + customField: null, + workSubmission: null, + ratingId: null, + }, + }, + }, + }) + @Roles(Role.USER) + @UseGuards(JwtAuthGuard, RoleGuard) + @Get('reject/:contractId') + async rejectJobByContractId(@Request() req) { + console.info('#unapplyJobByContractId request incoming'); + return await this.contractService.unApplyJobByContractId( + req.params.contractId, + ); + } } diff --git a/src/contract/contract.service.ts b/src/contract/contract.service.ts index 37d2d36..c776811 100644 --- a/src/contract/contract.service.ts +++ b/src/contract/contract.service.ts @@ -226,6 +226,10 @@ export class ContractService { } //#endregion + async unApplyJobByContractId(contractId: string) { + return this.contractRepository.delete(contractId); + } + //#region File //Remove File by fileName removeFile(fileName) { diff --git a/src/users/user.controller.ts b/src/users/user.controller.ts index fc1f12f..8b44c06 100644 --- a/src/users/user.controller.ts +++ b/src/users/user.controller.ts @@ -191,44 +191,4 @@ export class UserController { console.info('#UserGetProfileInfoById request incoming'); return await this.userService.findOneById(params.id); } - - @ApiBearerAuth() - @ApiCookieAuth() - @ApiParam({ - name: 'contractId', - type: String, - description: 'contractId of the job vacancy that want to be deleted', - }) - @ApiResponse({ - schema: { - example: { - status: true, - statusCode: 200, - data: { - id: '19eb7629-3cc4-49ec-8a50-eba25f9d2a62', - userId: 'd557b674-7f45-4734-9115-2ef1154959bc', - jobId: '9a6402b9-9a20-4ab1-bb15-9324398cef39', - paymentId: null, - title: - 'Lowongan pekerjaan Enna Alouette for d557b674-7f45-4734-9115-2ef1154959bc', - description: 'Contract for the following job description: auauaaa', - paymentRate: null, - template: null, - createdAt: '2024-01-16T17:35:13.586Z', - updatedAt: '2024-01-16T17:35:13.586Z', - status: 'PENDING', - customField: null, - workSubmission: null, - ratingId: null, - }, - }, - }, - }) - @Roles(Role.USER) - @UseGuards(JwtAuthGuard, RoleGuard) - @Get('unapply/:contractId') - async unapplyJobByContractId(@Request() req, @Res() res) { - console.info('#unapplyJobByContractId request incoming'); - return await this.userService.unApplyJobByContractId(req.params.contractId); - } } diff --git a/src/users/users.module.ts b/src/users/users.module.ts index 68c1f41..3863751 100644 --- a/src/users/users.module.ts +++ b/src/users/users.module.ts @@ -5,7 +5,6 @@ import { UserController } from './user.controller'; import { UserRepository } from './user.repository'; import { UserHelper } from './user.helper'; import { CompanyRepository } from '../company/company.repository'; -import { ContractRepository } from '../contract/contract.repository'; @Module({ providers: [ @@ -14,7 +13,6 @@ import { ContractRepository } from '../contract/contract.repository'; UserRepository, UserHelper, CompanyRepository, - ContractRepository, ], exports: [UsersService], controllers: [UserController], diff --git a/src/users/users.service.ts b/src/users/users.service.ts index ea210e7..245525c 100644 --- a/src/users/users.service.ts +++ b/src/users/users.service.ts @@ -4,14 +4,12 @@ import { UserFilterRequestDto } from './dto/user-filter.dto'; import { UserHelper } from './user.helper'; import { User } from '@prisma/client'; import { CompanyRepository } from '../company/company.repository'; -import { ContractRepository } from '../contract/contract.repository'; @Injectable() export class UsersService { constructor( private userRepository: UserRepository, private companyRepository: CompanyRepository, - private contractRepository: ContractRepository, private userHelper: UserHelper, ) {} @@ -112,8 +110,4 @@ export class UsersService { ): Promise { return this.userRepository.getAppliedJob(userId, page, size); } - - async unApplyJobByContractId(contractId: string) { - return this.contractRepository.delete(contractId); - } }