@@ -34,6 +34,7 @@ import {
3434 getReimbursementRequestWhereInput
3535} from '../utils/finance.utils.js' ;
3636import { notifySponsorTaskAssignee } from '../utils/slack.utils.js' ;
37+ import { uploadFile } from '../utils/google-integration.utils.js' ;
3738import { isUserFinanceTeamOrHead } from '../utils/reimbursement-requests.utils.js' ;
3839
3940export default class FinanceServices {
@@ -80,7 +81,8 @@ export default class FinanceServices {
8081 contactPhone ?: string ,
8182 contactPosition ?: string ,
8283 stockDescription ?: string ,
83- discountDescription ?: string
84+ discountDescription ?: string ,
85+ logoImage ?: Express . Multer . File
8486 ) {
8587 if ( ! ( await userHasPermission ( submitter . userId , organization . organizationId , isHead ) ) )
8688 throw new AccessDeniedException ( 'Only heads can create a sponsor' ) ;
@@ -104,6 +106,15 @@ export default class FinanceServices {
104106 data : { name : contactName , email : contactEmail , phone : contactPhone , position : contactPosition }
105107 } ) ;
106108
109+ let logoImageId : string | undefined ;
110+ if ( logoImage ) {
111+ const logoImageData = await uploadFile ( logoImage ) ;
112+ if ( ! logoImageData ?. id || ! logoImageData ?. name ) {
113+ throw new HttpException ( 500 , 'Sponsor logo upload failed' ) ;
114+ }
115+ logoImageId = logoImageData . id ;
116+ }
117+
107118 const sponsor = await prisma . sponsor . create ( {
108119 data : {
109120 name,
@@ -118,6 +129,7 @@ export default class FinanceServices {
118129 taxExempt,
119130 discountCode,
120131 sponsorNotes,
132+ logoImageId,
121133 contactId : contact . sponsorContactId ,
122134 sponsorTasks : {
123135 create : sponsorTasks . map ( ( task ) => ( {
@@ -1223,7 +1235,8 @@ export default class FinanceServices {
12231235 contactPhone ?: string ,
12241236 contactPosition ?: string ,
12251237 stockDescription ?: string ,
1226- discountDescription ?: string
1238+ discountDescription ?: string ,
1239+ logoImage ?: Express . Multer . File
12271240 ) : Promise < Sponsor > {
12281241 if ( ! ( await userHasPermission ( submitter . userId , organization . organizationId , isHead ) ) )
12291242 throw new AccessDeniedException ( 'Only heads can edit sponsors.' ) ;
@@ -1321,6 +1334,15 @@ export default class FinanceServices {
13211334 data : { name : contactName , email : contactEmail , phone : contactPhone , position : contactPosition }
13221335 } ) ;
13231336
1337+ let logoImageId : string | undefined ;
1338+ if ( logoImage ) {
1339+ const logoImageData = await uploadFile ( logoImage ) ;
1340+ if ( ! logoImageData ?. id || ! logoImageData ?. name ) {
1341+ throw new HttpException ( 500 , 'Sponsor logo upload failed' ) ;
1342+ }
1343+ logoImageId = logoImageData . id ;
1344+ }
1345+
13241346 const updatedSponsor = await prisma . sponsor . update ( {
13251347 where : { sponsorId : oldSponsor . sponsorId } ,
13261348 data : {
@@ -1335,7 +1357,8 @@ export default class FinanceServices {
13351357 tier : sponsorTierId ? { connect : { sponsorTierId } } : { disconnect : true } ,
13361358 taxExempt,
13371359 discountCode,
1338- sponsorNotes
1360+ sponsorNotes,
1361+ ...( logoImageId && { logoImageId } )
13391362 } ,
13401363 ...getSponsorQueryArgs ( organization . organizationId )
13411364 } ) ;
0 commit comments