@@ -2,6 +2,7 @@ import { ChangeRequest, daysBetween, Task, User, wbsPipe, WorkPackage } from 'sh
22import { sendMessage } from '../integrations/slack' ;
33import { getUserSlackId } from './users.utils' ;
44import prisma from '../prisma/prisma' ;
5+ import { HttpException } from './errors.utils' ;
56
67// build the "due" string for the upcoming deadlines slack message
78const buildDueString = ( daysUntilDeadline : number ) : string => {
@@ -67,3 +68,24 @@ export const sendSlackTaskAssignedNotification = async (slackId: string, task: T
6768 const linkButtonText = 'View Task' ;
6869 await sendMessage ( slackId , msg , link , linkButtonText ) ;
6970} ;
71+
72+ /**
73+ * Send a notification to users that reimbursement request is denied on Slack
74+ * @param slackId the slack id of the assignee
75+ * @param denial the denial if the reimbursement request
76+ */
77+ export const sendReimbursementRequestDeniedNotification = async ( slackId : string , requestId : string ) : Promise < void > => {
78+ if ( process . env . NODE_ENV !== 'production' ) return ; // don't send msgs unless in prod
79+
80+ const msg = `Your reimbursement request has been denied.` ;
81+ const link = `https://finishlinebyner.com/finance/reimbursement-requests/${ requestId } ` ;
82+ const linkButtonText = 'View Reimbursement Request' ;
83+
84+ try {
85+ await sendMessage ( slackId , msg , link , linkButtonText ) ;
86+ } catch ( error : unknown ) {
87+ if ( error instanceof Error ) {
88+ throw new HttpException ( 500 , `Failed to send slack notification: ${ error . message } ` ) ;
89+ }
90+ }
91+ } ;
0 commit comments