diff --git a/src/commands/signup/signup-interaction.dto.ts b/src/commands/signup/signup-interaction.dto.ts index 2d50d22c..97cfa2ff 100644 --- a/src/commands/signup/signup-interaction.dto.ts +++ b/src/commands/signup/signup-interaction.dto.ts @@ -1,6 +1,4 @@ -import { capitalCase } from 'change-case'; import { IsEnum, IsString, IsUrl, ValidateIf } from 'class-validator'; -import { ToCasing } from '../../common/decorators/to-casing.js'; import { ToLowercase } from '../../common/decorators/to-lowercase.js'; import { TransformUrl } from '../../common/decorators/transform-url.js'; import { Encounter } from '../../encounters/encounters.consts.js'; @@ -13,7 +11,7 @@ class SignupInteractionDto availability: string; @IsString() - @ToCasing(capitalCase) + @ToLowercase() character: string; @IsString() diff --git a/src/common/decorators/to-casing.ts b/src/common/decorators/to-casing.ts index 32065a2a..1e8c0423 100644 --- a/src/common/decorators/to-casing.ts +++ b/src/common/decorators/to-casing.ts @@ -9,4 +9,4 @@ type CaseTransformer = (value: string) => string; * @returns */ export const ToCasing = (fn: CaseTransformer) => - Transform(({ value }) => fn(value)); + Transform(({ value }) => value && fn(value)); diff --git a/src/sheets/sheets.service.ts b/src/sheets/sheets.service.ts index c674480f..2fa63c7c 100644 --- a/src/sheets/sheets.service.ts +++ b/src/sheets/sheets.service.ts @@ -2,6 +2,7 @@ import { sheets_v4 } from '@googleapis/sheets'; import { Inject, Injectable, Logger } from '@nestjs/common'; import { ConfigType } from '@nestjs/config'; import * as Sentry from '@sentry/node'; +import { capitalCase } from 'change-case'; import { AsyncQueue } from '../common/async-queue/async-queue.js'; import { PartyType, SignupDocument } from '../firebase/models/signup.model.js'; import { SignupCompositeKeyProps } from '../firebase/models/signup.model.js'; @@ -212,17 +213,12 @@ class SheetsService { // } private async upsertClearParty( - { - encounter, - character, - role, - world, - discordId, - progPoint = '', - }: Omit, + signup: Omit, spreadsheetId: string, ) { - const cellValues = [character, world, role, progPoint]; + const { encounter, character, world, discordId } = signup; + const cellValues = this.getCellValues(signup); + const { SHEET_EARLY_PROG_NAME, SHEET_PROG_NAME } = this.config; // need to check if we should remove prior signups from either earlyprog or mid prog sheet const requests = []; @@ -307,7 +303,7 @@ class SheetsService { // with how the prog sheet is setup visually with multiple column groups spanning different row lengths const rowOffset = values ? values.length + 1 : PROG_SHEET_STARTING_ROW; - const cellValues = [character, world, role, progPoint]; + const cellValues = this.getCellValues(signup); const updateRange = row === -1 @@ -421,6 +417,15 @@ class SheetsService { return sheetId; } + + private getCellValues({ + character, + world, + role, + progPoint = '', + }: SignupDocument) { + return [capitalCase(character), capitalCase(world), role, progPoint]; + } } export { SheetsService };