Skip to content

Commit

Permalink
fix: update award swu proposal status condition
Browse files Browse the repository at this point in the history
  • Loading branch information
IanFonzie committed Mar 19, 2024
1 parent 4d93a4c commit b90f38b
Showing 1 changed file with 32 additions and 13 deletions.
45 changes: 32 additions & 13 deletions src/back-end/lib/db/proposal/team-with-us.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1342,19 +1342,38 @@ export const awardTWUProposal = tryDb<

for (const id of otherProposalIds) {
// Get latest status for proposal and check equal to Evaluated/Awarded

await connection<RawHistoryRecord & { id: Id; proposal: Id }>(
"twuProposalStatuses"
)
.transacting(trx)
.insert({
id: generateUuid(),
proposal: id,
createdAt: now,
createdBy: session.user.id,
status: TWUProposalStatus.NotAwarded,
note: ""
});
const currentStatus = (
await connection<{ status: TWUProposalStatus }>("twuProposalStatuses")
.whereNotNull("status")
.andWhere("proposal", id)
.select("status")
.orderBy("createdAt", "desc")
.first()
)?.status;

if (
currentStatus &&
![
TWUProposalStatus.Disqualified,
TWUProposalStatus.Draft,
TWUProposalStatus.NotAwarded,
TWUProposalStatus.Submitted,
TWUProposalStatus.Withdrawn
].includes(currentStatus)
) {
await connection<RawHistoryRecord & { id: Id; proposal: Id }>(
"twuProposalStatuses"
)
.transacting(trx)
.insert({
id: generateUuid(),
proposal: id,
createdAt: now,
createdBy: session.user.id,
status: TWUProposalStatus.NotAwarded,
note: ""
});
}

await connection<RawTWUProposal>("twuProposals")
.where({ id: id })
Expand Down

0 comments on commit b90f38b

Please sign in to comment.