From 7fde755ec8e6128aa5aeaf35dc26358897841629 Mon Sep 17 00:00:00 2001 From: Anson He Date: Mon, 1 Jan 2024 22:06:08 -0500 Subject: [PATCH] address review comments --- backend/service/personalpurchases.service.js | 4 +++- backend/service/sponsorshipfunds.service.js | 8 +++++--- backend/service/uwfinancepurchases.service.js | 14 ++++---------- .../TicketContent/UPRAdminContentTable.js | 12 ++---------- 4 files changed, 14 insertions(+), 24 deletions(-) diff --git a/backend/service/personalpurchases.service.js b/backend/service/personalpurchases.service.js index ce22ae0..f4c1500 100644 --- a/backend/service/personalpurchases.service.js +++ b/backend/service/personalpurchases.service.js @@ -33,15 +33,17 @@ const createPersonalPurchase = async (body) => { } const updatePersonalPurchase = async (id, body) => { - // READY_TO_BUY -> PURCHASED_AND_RECEIPTS_SUBMITTED const newPurchaseTicket = PersonalPurchase.findByIdAndUpdate(id, body, { new: true, }) const annotatedPPR = await getPersonalPurchase(id) + + // READY_TO_BUY -> PURCHASED_AND_RECEIPTS_SUBMITTED if (body?.status === 'PURCHASED_AND_RECEIPTS_SUBMITTED') { await sendEmailPPRPurchasedAndReceiptsSubmittedToCoordinator( annotatedPPR ) + // PURCHASED_AND_RECEIPTS_SUBMITTED -> REPORTER_PAID } else if (body?.status === 'REPORTER_PAID') { await sendEmailPPRReimbursedToReporter(annotatedPPR) } diff --git a/backend/service/sponsorshipfunds.service.js b/backend/service/sponsorshipfunds.service.js index 9db03ca..f38ef9c 100644 --- a/backend/service/sponsorshipfunds.service.js +++ b/backend/service/sponsorshipfunds.service.js @@ -67,17 +67,19 @@ const updateSponsorshipFund = async (id, body) => { const status = annotatedSponsorshipFund.status if (status === 'CLAIM_SUBMITTED') { - sendEmailSFReimbursementRequestToCoordinator(annotatedSponsorshipFund) + await sendEmailSFReimbursementRequestToCoordinator( + annotatedSponsorshipFund + ) } if (status === 'SUBMITTED_TO_SF') { - sendEmailSFConfirmReimbursementSubmitToCoordinator( + await sendEmailSFConfirmReimbursementSubmitToCoordinator( annotatedSponsorshipFund ) } if (status === 'REIMBURSED') { - sendEmailSFReimbursementReceivedToTeam(annotatedSponsorshipFund) + await sendEmailSFReimbursementReceivedToTeam(annotatedSponsorshipFund) } return newSponsorshipFund diff --git a/backend/service/uwfinancepurchases.service.js b/backend/service/uwfinancepurchases.service.js index 1c7c7ae..cbc5097 100644 --- a/backend/service/uwfinancepurchases.service.js +++ b/backend/service/uwfinancepurchases.service.js @@ -34,8 +34,6 @@ const createNewUWFinancePurchase = async (body) => { } const updateUWFinancePurchase = async (id, body) => { - const existingPurchaseTicket = await getUWFinancePurchase(id) - // SENT_TO_COORDINATOR -> ORDERED const newPurchaseTicket = await UWFinancePurchase.findByIdAndUpdate( id, body, @@ -43,10 +41,8 @@ const updateUWFinancePurchase = async (id, body) => { new: true, } ) - if ( - existingPurchaseTicket.status === 'SENT_TO_COORDINATOR' && - body.status === 'ORDERED' - ) { + // SENT_TO_COORDINATOR -> ORDERED + if (body.status === 'ORDERED') { const annotatedUPR = await getUWFinancePurchase(id) const emails = [ sendEmailUPRPurchasedToCoordinator(annotatedUPR), @@ -54,10 +50,8 @@ const updateUWFinancePurchase = async (id, body) => { ] await Promise.all(emails) } - if ( - existingPurchaseTicket.status === 'ORDERED' && - body.status === 'READY_FOR_PICKUP' - ) { + // ORDERED -> READY_FOR_PICKUP + if (body.status === 'READY_FOR_PICKUP') { const annotatedUPR = await getUWFinancePurchase(id) await sendEmailUPRReadyForPickupToCoordinator(annotatedUPR) } diff --git a/frontend/src/components/TicketContent/UPRAdminContentTable.js b/frontend/src/components/TicketContent/UPRAdminContentTable.js index 0fea8df..92dad71 100644 --- a/frontend/src/components/TicketContent/UPRAdminContentTable.js +++ b/frontend/src/components/TicketContent/UPRAdminContentTable.js @@ -26,16 +26,8 @@ const UPRAdminContentTable = () => { } useEffect(() => { - if (!currentTicket.requisition_number) { - setReqNum('') - } else { - setReqNum(currentTicket.requisition_number) - } - if (!currentTicket.po_number) { - setPoNum('') - } else { - setPoNum(currentTicket.po_number) - } + setReqNum(currentTicket.requisition_number ?? '') + setPoNum(currentTicket.po_number ?? '') }, [ location.pathname, currentTicket.requisition_number,