@@ -48,6 +48,10 @@ import type {
4848
4949/**
5050 * Handles creating a project from intake data
51+ * @param tx Prisma transaction client
52+ * @param data Electrification project data
53+ * @param currentContext context data of current request
54+ * @returns Maniplated electrification data
5155 */
5256const generateElectrificationProjectData = async (
5357 tx : PrismaTransactionClient ,
@@ -60,7 +64,7 @@ const generateElectrificationProjectData = async (
6064 if ( ! activityId ) {
6165 activityId = ( await createActivity ( tx , Initiative . ELECTRIFICATION , generateCreateStamps ( currentContext ) ) )
6266 ?. activityId ;
63- const contacts = await searchContacts ( tx , { userId : [ currentContext . userId as string ] } ) ;
67+ const contacts = await searchContacts ( tx , { userId : [ currentContext . userId ! ] } ) ;
6468 if ( contacts [ 0 ] ) await createActivityContact ( tx , activityId , contacts [ 0 ] . contactId , ActivityContactRole . PRIMARY ) ;
6569 }
6670
@@ -98,6 +102,8 @@ const generateElectrificationProjectData = async (
98102
99103/**
100104 * Send an email with the confirmation of electrification project
105+ * @param req Express Request object
106+ * @param res Express Response object
101107 */
102108export const emailElectrificationProjectConfirmationController = async (
103109 req : Request < never , never , Email > ,
@@ -119,11 +125,9 @@ export const createElectrificationProjectController = async (
119125 res : Response
120126) => {
121127 // Provide an empty body if POST body is given undefined
122- if ( req . body === undefined ) {
123- req . body = {
124- project : { }
125- } as ElectrificationProjectIntake ;
126- }
128+ req . body ??= {
129+ project : { }
130+ } as ElectrificationProjectIntake ;
127131
128132 const result = await transactionWrapper < ElectrificationProject > ( async ( tx : PrismaTransactionClient ) => {
129133 const electrificationProject = await generateElectrificationProjectData ( tx , req . body , req . currentContext ) ;
0 commit comments