@@ -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 {
@@ -56,7 +57,7 @@ export default class FinanceServices {
5657 * @param contactPosition The position of the sponsor contact.
5758 * @param sponsorTasks An array of sponsor tasks associated with the sponsor.
5859 * @param organization The organization for which the sponsor is being created.
59- *
60+ * @param logoImage An optional logo image file for the sponsor.
6061 * @returns The created sponsor object, including associated tasks.
6162 *
6263 * @throws AccessDeniedAdminOnlyException If the submitter does not have permission to create a sponsor.
@@ -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,8 @@ export default class FinanceServices {
104106 data : { name : contactName , email : contactEmail , phone : contactPhone , position : contactPosition }
105107 } ) ;
106108
109+ const { id : logoImageId } = logoImage ? await uploadFile ( logoImage ) : { id : undefined } ;
110+
107111 const sponsor = await prisma . sponsor . create ( {
108112 data : {
109113 name,
@@ -118,6 +122,7 @@ export default class FinanceServices {
118122 taxExempt,
119123 discountCode,
120124 sponsorNotes,
125+ logoImageId,
121126 contactId : contact . sponsorContactId ,
122127 sponsorTasks : {
123128 create : sponsorTasks . map ( ( task ) => ( {
@@ -1200,6 +1205,8 @@ export default class FinanceServices {
12001205 * @param contactPosition The position of the sponsor contact.
12011206 * @param sponsorTasks An array of sponsor tasks associated with the sponsor.
12021207 * @param organization The organization for which the sponsor is being edited.
1208+ * @param logoImage An optional logo image file for the sponsor.
1209+ *
12031210 * @returns the edited sponsor.
12041211 */
12051212
@@ -1223,7 +1230,8 @@ export default class FinanceServices {
12231230 contactPhone ?: string ,
12241231 contactPosition ?: string ,
12251232 stockDescription ?: string ,
1226- discountDescription ?: string
1233+ discountDescription ?: string ,
1234+ logoImage ?: Express . Multer . File
12271235 ) : Promise < Sponsor > {
12281236 if ( ! ( await userHasPermission ( submitter . userId , organization . organizationId , isHead ) ) )
12291237 throw new AccessDeniedException ( 'Only heads can edit sponsors.' ) ;
@@ -1321,6 +1329,8 @@ export default class FinanceServices {
13211329 data : { name : contactName , email : contactEmail , phone : contactPhone , position : contactPosition }
13221330 } ) ;
13231331
1332+ const { id : logoImageId } = logoImage ? await uploadFile ( logoImage ) : { id : undefined } ;
1333+
13241334 const updatedSponsor = await prisma . sponsor . update ( {
13251335 where : { sponsorId : oldSponsor . sponsorId } ,
13261336 data : {
@@ -1335,7 +1345,8 @@ export default class FinanceServices {
13351345 tier : sponsorTierId ? { connect : { sponsorTierId } } : { disconnect : true } ,
13361346 taxExempt,
13371347 discountCode,
1338- sponsorNotes
1348+ sponsorNotes,
1349+ ...( logoImageId && { logoImageId } )
13391350 } ,
13401351 ...getSponsorQueryArgs ( organization . organizationId )
13411352 } ) ;
0 commit comments