Skip to content

Commit

Permalink
address review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
ansonjwhe committed Jan 2, 2024
1 parent fb2fb47 commit 7fde755
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 24 deletions.
4 changes: 3 additions & 1 deletion backend/service/personalpurchases.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
8 changes: 5 additions & 3 deletions backend/service/sponsorshipfunds.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 4 additions & 10 deletions backend/service/uwfinancepurchases.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,30 +34,24 @@ 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,
{
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),
sendEmailUPRPurchasedToReporter(annotatedUPR),
]
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)
}
Expand Down
12 changes: 2 additions & 10 deletions frontend/src/components/TicketContent/UPRAdminContentTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 7fde755

Please sign in to comment.