Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow reapproving a payment in the trustee interface #2145 #2154

Merged
merged 3 commits into from
Oct 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,20 @@ interface ApproveInvoicesPromptProps {
isOpen: boolean;
isLoading: boolean;
isFinished: boolean;
isReapproval?: boolean;
onApprove: () => void;
onClose: () => void;
}

const ApproveInvoicesPrompt: FC<ApproveInvoicesPromptProps> = (props) => {
const { isOpen, isFinished, isLoading, onApprove, onClose } = props;
const {
isOpen,
isFinished,
isLoading,
isReapproval = false,
onApprove,
onClose,
} = props;

const handleApprove = () => {
onApprove();
Expand Down Expand Up @@ -45,7 +53,9 @@ const ApproveInvoicesPrompt: FC<ApproveInvoicesPromptProps> = (props) => {
<>
<ConfirmationIcon className="approve-invoices-prompt-wrapper__confirmation-icon" />
<h3 className="approve-invoices-prompt-wrapper__title">
Are you sure you want to approve all invoices
{isReapproval
? "Are you sure you want to reapprove this card?"
: "Are you sure you want to approve all invoices?"}
</h3>
<div className="approve-invoices-prompt-wrapper__actions-wrapper">
<button
Expand All @@ -58,7 +68,7 @@ const ApproveInvoicesPrompt: FC<ApproveInvoicesPromptProps> = (props) => {
className="button-blue approve-invoices-prompt-wrapper__approve-button"
onClick={handleApprove}
>
Approve all
{isReapproval ? "Reapprove" : "Approve all"}
</button>
</div>
</>
Expand All @@ -67,7 +77,7 @@ const ApproveInvoicesPrompt: FC<ApproveInvoicesPromptProps> = (props) => {
<>
<CheckIcon className="approve-invoices-prompt-wrapper__check-icon" />
<h3 className="approve-invoices-prompt-wrapper__title">
Invoices are successfully approved!
Invoices are successfully {isReapproval ? "re" : ""}approved!
</h3>
<button
className="button-blue approve-invoices-prompt-wrapper__done-button"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import { StickyInfo } from "../../components/StickyInfo";
import {
checkDeclinedProposal,
checkPendingApprovalProposal,
checkPendingReapprovalProposal,
} from "../../helpers";
import {
approveOrDeclineProposal,
Expand Down Expand Up @@ -60,6 +61,9 @@ const InvoiceAcceptanceContainer: FC = () => {
const isPendingApprovalProposal = Boolean(
proposalForApproval && checkPendingApprovalProposal(proposalForApproval),
);
const isPendingReapprovalProposal = Boolean(
proposalForApproval && checkPendingReapprovalProposal(proposalForApproval),
);
const isApprovedProposal = Boolean(
proposalForApproval &&
!checkDeclinedProposal(proposalForApproval) &&
Expand Down Expand Up @@ -181,20 +185,22 @@ const InvoiceAcceptanceContainer: FC = () => {
payoutDocs={payoutDocs}
onDocClick={handleInvoiceTileClick}
/>
{isPendingApprovalProposal && (
{(isPendingApprovalProposal || isPendingReapprovalProposal) && (
<div className="invoice-acceptance-container__actions-wrapper">
<button
className="button-blue invoice-acceptance-container__approve-button"
onClick={handleApproveClick}
>
Approve All
</button>
<button
className="button-blue invoice-acceptance-container__decline-button"
onClick={handleDeclineClick}
>
Decline
{isPendingReapprovalProposal ? "Reapprove" : "Approve All"}
</button>
{!isPendingReapprovalProposal && (
<button
className="button-blue invoice-acceptance-container__decline-button"
onClick={handleDeclineClick}
>
Decline
</button>
)}
</div>
)}
</>
Expand All @@ -210,6 +216,7 @@ const InvoiceAcceptanceContainer: FC = () => {
isOpen={isApprovePromptOpen}
isLoading={submissionState.loading}
isFinished={submissionState.finished}
isReapproval={isPendingReapprovalProposal}
onApprove={handleSubmit}
onClose={handleApprovePromptClose}
/>
Expand Down
6 changes: 6 additions & 0 deletions src/pages/Trustee/helpers/proposalState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@ export const checkPendingApprovalProposal = (
proposal.data.tracker.status ===
FundingAllocationStatus.PENDING_INVOICE_APPROVAL;

export const checkPendingReapprovalProposal = (
proposal: FundsAllocation,
): boolean =>
proposal.data.tracker.status ===
FundingAllocationStatus.PENDING_SELLER_APPROVAL;

export const checkDeclinedProposal = (proposal: FundsAllocation): boolean =>
proposal.data.legal.payoutDocsRejectionReason !== null &&
proposal.data.tracker.status ===
Expand Down
Loading