Skip to content

Commit

Permalink
add target date to withdrawal controller (podkrepi-bg#561)
Browse files Browse the repository at this point in the history
* added: targetDate in withdrawal model
* cleaned previous linter issues
  • Loading branch information
quantum-grit authored Oct 3, 2023
1 parent 259ea9f commit 2eaf4bb
Show file tree
Hide file tree
Showing 9 changed files with 22 additions and 14 deletions.
4 changes: 2 additions & 2 deletions apps/api/src/auth/auth.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ describe('AuthService', () => {
let config: ConfigService
let admin: KeycloakAdminClient
let keycloak: KeycloakConnect.Keycloak
let marketing: NotificationsProviderInterface<any>
let marketing: NotificationsProviderInterface<unknown>

const person: Person = {
id: 'e43348aa-be33-4c12-80bf-2adfbf8736cd',
Expand Down Expand Up @@ -113,7 +113,7 @@ describe('AuthService', () => {
service = module.get<AuthService>(AuthService)
config = module.get<ConfigService>(ConfigService)
admin = module.get<KeycloakAdminClient>(KeycloakAdminClient)
marketing = module.get<NotificationsProviderInterface<any>>(NotificationsProviderInterface)
marketing = module.get<NotificationsProviderInterface<never>>(NotificationsProviderInterface)
keycloak = module.get<KeycloakConnect.Keycloak>(KEYCLOAK_INSTANCE)
})

Expand Down
1 change: 0 additions & 1 deletion apps/api/src/campaign-file/campaign-file.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import { CampaignFileService } from './campaign-file.service'
import { CampaignService } from '../campaign/campaign.service'
import { KeycloakTokenParsed, isAdmin } from '../auth/keycloak'
import { ApiTags } from '@nestjs/swagger'
import { CampaignFileRole } from '@prisma/client'

@ApiTags('campaign-file')
@Controller('campaign-file')
Expand Down
4 changes: 2 additions & 2 deletions apps/api/src/campaign/campaign.controller.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ describe('CampaignController', () => {
let controller: CampaignController
let prismaService: PrismaService
let campaignService: CampaignService
let marketingProvider: NotificationsProviderInterface<any>
let marketingProvider: NotificationsProviderInterface<unknown>
let marketingService: MarketingNotificationsService
const personServiceMock = {
findOneByKeycloakId: jest.fn(() => {
Expand Down Expand Up @@ -196,7 +196,7 @@ describe('CampaignController', () => {
prismaService = prismaMock
campaignService = module.get<CampaignService>(CampaignService)
marketingService = module.get<MarketingNotificationsService>(MarketingNotificationsService)
marketingProvider = module.get<NotificationsProviderInterface<any>>(
marketingProvider = module.get<NotificationsProviderInterface<never>>(
NotificationsProviderInterface,
)

Expand Down
4 changes: 2 additions & 2 deletions apps/api/src/campaign/campaign.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import { MarketingNotificationsService } from '../notifications/notifications.se

describe('CampaignService', () => {
let service: CampaignService
let marketing: NotificationsProviderInterface<any>
let marketing: NotificationsProviderInterface<unknown>

const mockCreateCampaign = {
slug: 'test-slug',
Expand Down Expand Up @@ -106,7 +106,7 @@ describe('CampaignService', () => {
.compile()

service = module.get<CampaignService>(CampaignService)
marketing = module.get<NotificationsProviderInterface<any>>(NotificationsProviderInterface)
marketing = module.get<NotificationsProviderInterface<never>>(NotificationsProviderInterface)
})

describe('update', () => {
Expand Down
1 change: 0 additions & 1 deletion apps/api/src/config/shutdown.config.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { INestApplication, ShutdownSignal } from '@nestjs/common'
import { PrismaService } from '../prisma/prisma.service'

export function setupShutdownHooks(app: INestApplication) {
// https://www.prisma.io/docs/guides/upgrade-guides/upgrading-versions/upgrading-to-prisma-5
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import * as fs from 'fs'
import { PrismaClient } from '@prisma/client'
import * as sgClient from '@sendgrid/client'
import { Logger } from '@nestjs/common'
import { ClientRequest } from '@sendgrid/client/src/request'

sgClient.setApiKey(process.env['SENDGRID_API_KEY'] || '')

Expand All @@ -28,7 +29,7 @@ async function createMarketingTemplatesIfNotExisting() {
url: `/v3/designs`,
method: 'POST',
body: data,
} as any
} as ClientRequest

const [response] = await sgClient.request(request)

Expand Down
6 changes: 4 additions & 2 deletions apps/api/src/notifications/notifications.controller.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ describe('MarketingNotificationsController', () => {
jest.spyOn(marketingProvider, 'getContactsInfo').mockImplementation(async () => ({}))
// Mock hash
jest
.spyOn(MarketingNotificationsService.prototype as any, 'generateHash')
.spyOn(MarketingNotificationsService.prototype, 'generateHash')
.mockReturnValue('hash-value')
})

Expand All @@ -128,7 +128,9 @@ describe('MarketingNotificationsController', () => {
it('should skip sending if user is registered + subscribed', async () => {
prismaMock.person.findFirst.mockResolvedValue(RegisteredMock)

await expect(controller.sendConfirmation({ email: RegisteredMock.email })).resolves.toEqual({
await expect(
controller.sendConfirmation({ email: RegisteredMock.email as string }),
).resolves.toEqual({
message: 'Subscribed',
})

Expand Down
2 changes: 1 addition & 1 deletion apps/api/src/prisma/prisma.service.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { PrismaClient } from '@prisma/client'
import { INestApplication, Injectable, OnModuleInit } from '@nestjs/common'
import { Injectable, OnModuleInit } from '@nestjs/common'

@Injectable()
export class PrismaService extends PrismaClient implements OnModuleInit {
Expand Down
11 changes: 9 additions & 2 deletions apps/api/src/withdrawal/dto/create-withdrawal.dto.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { ApiProperty } from '@nestjs/swagger'
import { Currency, WithdrawStatus } from '@prisma/client'
import { Expose } from 'class-transformer'
import { IsEnum, IsNumber, IsString, IsUUID, IsOptional } from 'class-validator'
import { Expose, Type } from 'class-transformer'
import { IsEnum, IsNumber, IsString, IsUUID, IsOptional, IsDate } from 'class-validator'
export class CreateWithdrawalDto {
@ApiProperty({ enum: WithdrawStatus })
@Expose()
Expand Down Expand Up @@ -49,4 +49,11 @@ export class CreateWithdrawalDto {
@IsOptional()
@Expose()
approvedById?: string

@ApiProperty()
@Expose()
@IsOptional()
@IsDate()
@Type(() => Date)
targetDate?: Date | null
}

0 comments on commit 2eaf4bb

Please sign in to comment.