@@ -316,17 +316,17 @@ router.put('/:id', requireAuth, async (req, res): Promise<void> => {
316316 icpAddress,
317317 votingPleaUnsubscribed
318318 } : {
319- email : string | undefined ,
320- name : string | undefined ,
321- ethereumAddress : string | undefined ,
322- solanaAddress : string | undefined ,
323- bitcoinAddress : string | undefined ,
324- bitcoinCashAddress : string | undefined ,
325- polkadotAddress : string | undefined ,
326- cosmosAddress : string | undefined ,
327- stellarAddress : string | undefined ,
328- icpAddress : string | undefined ,
329- votingPleaUnsubscribed : string | undefined
319+ email : string | null ,
320+ name : string | null ,
321+ ethereumAddress : string | null ,
322+ solanaAddress : string | null ,
323+ bitcoinAddress : string | null ,
324+ bitcoinCashAddress : string | null ,
325+ polkadotAddress : string | null ,
326+ cosmosAddress : string | null ,
327+ stellarAddress : string | null ,
328+ icpAddress : string | null ,
329+ votingPleaUnsubscribed : string | null
330330 } = req . body ;
331331 const authenticatedUserId = ( req as any ) . userId ;
332332
@@ -348,7 +348,7 @@ router.put('/:id', requireAuth, async (req, res): Promise<void> => {
348348 } )
349349 } ;
350350
351- if ( ethereumAddress !== undefined && String ( ethereumAddress ) . trim ( ) && ! isValidEthereumAddress ( ethereumAddress ) ) {
351+ if ( ethereumAddress !== null && String ( ethereumAddress ) . trim ( ) && ! isValidEthereumAddress ( ethereumAddress ) ) {
352352 validationErrors . ethereumAddress = 'Invalid Ethereum address format.' ;
353353 }
354354
@@ -360,7 +360,7 @@ router.put('/:id', requireAuth, async (req, res): Promise<void> => {
360360 return ;
361361 }
362362
363- let normalizedVotingPleaPreference : string | boolean | undefined = votingPleaUnsubscribed ; // TODO@P 3: Use one type, not two.
363+ let normalizedVotingPleaPreference : string | boolean | null = votingPleaUnsubscribed ; // TODO@P 3: Use one type, not two.
364364 if ( typeof normalizedVotingPleaPreference === 'string' ) {
365365 normalizedVotingPleaPreference = normalizedVotingPleaPreference === 'true' ;
366366 }
@@ -388,16 +388,16 @@ router.put('/:id', requireAuth, async (req, res): Promise<void> => {
388388 await tx . user . update ( {
389389 where : { id : parseInt ( id as string ) } ,
390390 data : {
391- ...( name !== undefined && { name } ) , // FIXME@P 3
392- ...{ ethereumAddress : ethereumAddress !== undefined ? String ( ethereumAddress ) . trim ( ) : null } ,
393- ...{ solanaAddress : solanaAddress !== undefined ? String ( solanaAddress ) . trim ( ) : null } ,
394- ...{ bitcoinAddress : bitcoinAddress !== undefined ? String ( bitcoinAddress ) . trim ( ) : null } ,
395- ...{ bitcoinCashAddress : bitcoinCashAddress !== undefined ? String ( bitcoinCashAddress ) . trim ( ) : null } ,
396- ...{ polkadotAddress : polkadotAddress !== undefined ? String ( polkadotAddress ) . trim ( ) : null } ,
397- ...{ cosmosAddress : cosmosAddress !== undefined ? String ( cosmosAddress ) . trim ( ) : null } ,
398- ...{ stellarAddress : stellarAddress !== undefined ? String ( stellarAddress ) . trim ( ) : null } ,
399- ...{ icpAddress : icpAddress !== undefined ? String ( icpAddress ) . trim ( ) : null } ,
400- ...( normalizedVotingPleaPreference !== undefined && { votingPleaUnsubscribed : normalizedVotingPleaPreference } )
391+ ...( name !== null && { name } ) , // FIXME@P 3
392+ ...{ ethereumAddress : ethereumAddress !== null ? String ( ethereumAddress ) . trim ( ) : null } ,
393+ ...{ solanaAddress : solanaAddress !== null ? String ( solanaAddress ) . trim ( ) : null } ,
394+ ...{ bitcoinAddress : bitcoinAddress !== null ? String ( bitcoinAddress ) . trim ( ) : null } ,
395+ ...{ bitcoinCashAddress : bitcoinCashAddress !== null ? String ( bitcoinCashAddress ) . trim ( ) : null } ,
396+ ...{ polkadotAddress : polkadotAddress !== null ? String ( polkadotAddress ) . trim ( ) : null } ,
397+ ...{ cosmosAddress : cosmosAddress !== null ? String ( cosmosAddress ) . trim ( ) : null } ,
398+ ...{ stellarAddress : stellarAddress !== null ? String ( stellarAddress ) . trim ( ) : null } ,
399+ ...{ icpAddress : icpAddress !== null ? String ( icpAddress ) . trim ( ) : null } ,
400+ ...( normalizedVotingPleaPreference !== null && { votingPleaUnsubscribed : normalizedVotingPleaPreference } )
401401 } ,
402402 } ) ;
403403
0 commit comments