Skip to content

Commit

Permalink
fix: PR comments
Browse files Browse the repository at this point in the history
  • Loading branch information
DafyddLlyr committed Dec 9, 2024
1 parent bad6797 commit cc33fb1
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ export const FeeBreakdown: React.FC<{ inviteToPayFeeBreakdown?: IFeeBreakdown }>
return (
<Box mt={3}>
<Typography variant="h3" mb={1}>
Fee breakdown
Fee
</Typography>
<Typography variant="body1" mb={2}>
{DESCRIPTION}
Expand Down
38 changes: 21 additions & 17 deletions editor.planx.uk/src/pages/Pay/MakePayment.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
import { FeeBreakdown } from "@planx/components/Pay/Public/FeeBreakdown/FeeBreakdown";
import axios from "axios";
import { format } from "date-fns";
import { hasFeatureFlag } from "lib/featureFlags";
import { getExpiryDateForPaymentRequest } from "lib/pay";
import { useStore } from "pages/FlowEditor/lib/store";
import React, { useEffect, useState } from "react";
Expand Down Expand Up @@ -172,14 +173,10 @@ export default function MakePayment({
</Container>
);

const PaymentDetails = () => {
const PaymentDetails: React.FC<{ hasFeeBreakdown: boolean}> = ({ hasFeeBreakdown }) => {
const projectType = formatRawProjectTypes(rawProjectTypes);
const data = [
{ term: "Application type", details: flowName },
{
term: "Fee",
details: formattedPriceWithCurrencySymbol(toDecimal(paymentAmount)),
},
{
term: "Property address",
details: address,
Expand All @@ -190,6 +187,13 @@ export default function MakePayment({
},
];

if (!hasFeeBreakdown) {
data.splice(1, 0, {
term: "Fee",
details: formattedPriceWithCurrencySymbol(toDecimal(paymentAmount))
});
};

// Handle payments completed before page load
if (paidAt) {
data.push({
Expand Down Expand Up @@ -222,15 +226,17 @@ export default function MakePayment({
) : (
<>
<Header />
<PaymentDetails />
<PaymentDetails hasFeeBreakdown={Boolean(feeBreakdown)}/>
{(currentState === States.Ready ||
currentState === States.Reset ||
currentState === States.ReadyToRetry) &&
!isLoading && (
<>
<Container maxWidth="contentWrap" sx={{ mt: 6, pb: 0 }}>
<FeeBreakdown inviteToPayFeeBreakdown={feeBreakdown} />
</Container>
{hasFeatureFlag("FEE_BREAKDOWN") && (
<Container maxWidth="contentWrap" sx={{ mt: 6, pb: 0 }}>
<FeeBreakdown inviteToPayFeeBreakdown={feeBreakdown} />
</Container>
)}
<Confirm
fee={toDecimal(paymentAmount)}
onConfirm={readyAction}
Expand All @@ -254,9 +260,8 @@ async function fetchPayment({
govPayPaymentId?: string;
}): Promise<GovUKPayment | null> {
if (!govPayPaymentId) return Promise.resolve(null);
const paymentURL = `${
import.meta.env.VITE_APP_API_URL
}/payment-request/${paymentRequestId}/payment/${govPayPaymentId}`;
const paymentURL = `${import.meta.env.VITE_APP_API_URL
}/payment-request/${paymentRequestId}/payment/${govPayPaymentId}`;
const response = await axios.get<GovUKPayment>(paymentURL);
return response.data;
}
Expand All @@ -265,11 +270,10 @@ async function fetchPayment({
async function startNewPayment(
paymentRequestId: string,
): Promise<GovUKPayment> {
const paymentURL = `${
import.meta.env.VITE_APP_API_URL
}/payment-request/${paymentRequestId}/pay?returnURL=${encodeURIComponent(
window.location.href,
)}`;
const paymentURL = `${import.meta.env.VITE_APP_API_URL
}/payment-request/${paymentRequestId}/pay?returnURL=${encodeURIComponent(
window.location.href,
)}`;
const response = await axios.post<GovUKPayment>(paymentURL);
return response.data;
}
Expand Down

0 comments on commit cc33fb1

Please sign in to comment.