From ff0946dc15759b595c34b6b7fcf93bcbe7dc241d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dafydd=20Ll=C5=B7r=20Pearson?= Date: Wed, 4 Dec 2024 16:09:10 +0000 Subject: [PATCH] feat: Remove toggle for FeeBreakdown (#4039) --- .../Pay/Editor/FeeBreakdownSection.tsx | 18 +-------- .../@planx/components/Pay/Public/Confirm.tsx | 3 +- .../components/Pay/Public/Pay.stories.tsx | 1 - .../@planx/components/Pay/Public/Pay.test.tsx | 37 ------------------- .../src/@planx/components/Pay/model.ts | 2 - 5 files changed, 4 insertions(+), 57 deletions(-) diff --git a/editor.planx.uk/src/@planx/components/Pay/Editor/FeeBreakdownSection.tsx b/editor.planx.uk/src/@planx/components/Pay/Editor/FeeBreakdownSection.tsx index 5db61ca8ae..61b495a398 100644 --- a/editor.planx.uk/src/@planx/components/Pay/Editor/FeeBreakdownSection.tsx +++ b/editor.planx.uk/src/@planx/components/Pay/Editor/FeeBreakdownSection.tsx @@ -1,31 +1,17 @@ import ReceiptLongIcon from "@mui/icons-material/ReceiptLong"; -import { useFormikContext } from "formik"; import { hasFeatureFlag } from "lib/featureFlags"; import React from "react"; +import { FeaturePlaceholder } from "ui/editor/FeaturePlaceholder"; import ModalSection from "ui/editor/ModalSection"; import ModalSectionContent from "ui/editor/ModalSectionContent"; -import InputRow from "ui/shared/InputRow"; -import { Switch } from "ui/shared/Switch"; - -import { Pay } from "../model"; export const FeeBreakdownSection: React.FC = () => { - const { values, setFieldValue } = useFormikContext(); - if (!hasFeatureFlag("FEE_BREAKDOWN")) return null; return ( - - - setFieldValue("showFeeBreakdown", !values.showFeeBreakdown) - } - label="Display a breakdown of the fee to the applicant" - /> - + ); diff --git a/editor.planx.uk/src/@planx/components/Pay/Public/Confirm.tsx b/editor.planx.uk/src/@planx/components/Pay/Public/Confirm.tsx index 31913894d9..db484d2d19 100644 --- a/editor.planx.uk/src/@planx/components/Pay/Public/Confirm.tsx +++ b/editor.planx.uk/src/@planx/components/Pay/Public/Confirm.tsx @@ -6,6 +6,7 @@ import Typography from "@mui/material/Typography"; import { PaymentStatus } from "@opensystemslab/planx-core/types"; import Card from "@planx/components/shared/Preview/Card"; import SaveResumeButton from "@planx/components/shared/Preview/SaveResumeButton"; +import { hasFeatureFlag } from "lib/featureFlags"; import { useStore } from "pages/FlowEditor/lib/store"; import React, { useState } from "react"; import { ApplicationPath } from "types"; @@ -181,7 +182,7 @@ export default function Confirm(props: Props) { /> - {props.showFeeBreakdown && } + {hasFeatureFlag("FEE_BREAKDOWN") && } )} {page === "Pay" ? ( diff --git a/editor.planx.uk/src/@planx/components/Pay/Public/Pay.stories.tsx b/editor.planx.uk/src/@planx/components/Pay/Public/Pay.stories.tsx index 619503a550..5de59d2ec8 100644 --- a/editor.planx.uk/src/@planx/components/Pay/Public/Pay.stories.tsx +++ b/editor.planx.uk/src/@planx/components/Pay/Public/Pay.stories.tsx @@ -88,6 +88,5 @@ export const WithFeeBreakdown = { onConfirm: () => {}, error: undefined, showInviteToPay: false, - showFeeBreakdown: true, }, } satisfies Story; diff --git a/editor.planx.uk/src/@planx/components/Pay/Public/Pay.test.tsx b/editor.planx.uk/src/@planx/components/Pay/Public/Pay.test.tsx index be94bc59f8..71e43ed2d5 100644 --- a/editor.planx.uk/src/@planx/components/Pay/Public/Pay.test.tsx +++ b/editor.planx.uk/src/@planx/components/Pay/Public/Pay.test.tsx @@ -487,40 +487,3 @@ describe("the demo user view", () => { expect(errorHeader).toBeInTheDocument(); }); }); - -describe("Displaying the fee breakdown", () => { - beforeAll(() => (initialState = getState())); - afterEach(() => act(() => setState(initialState))); - - test("if the showFeeBreakdown prop is set, the breakdown is displayed to the user", () => { - mockHasFeatureFlag.mockReturnValue(true); - - const { getByRole, getByTestId } = setup( - , - ); - - expect(mockHasFeatureFlag).toHaveBeenCalledWith("FEE_BREAKDOWN"); - expect(mockHasFeatureFlag).toHaveBeenCalledTimes(1); - - expect( - getByRole("heading", { level: 3, name: "Fee breakdown" }), - ).toBeVisible(); - expect(getByTestId("fee-breakdown-table")).toBeVisible(); - }); - - test("if the showFeeBreakdown prop is not set, the breakdown is not displayed to the user", () => { - mockHasFeatureFlag.mockReturnValue(true); - - const { queryByRole, queryByTestId } = setup( - , - ); - - expect(mockHasFeatureFlag).toHaveBeenCalledWith("FEE_BREAKDOWN"); - expect(mockHasFeatureFlag).toHaveBeenCalledTimes(1); - - expect( - queryByRole("heading", { level: 3, name: "Fee breakdown" }), - ).not.toBeInTheDocument(); - expect(queryByTestId("fee-breakdown-table")).not.toBeInTheDocument(); - }); -}); diff --git a/editor.planx.uk/src/@planx/components/Pay/model.ts b/editor.planx.uk/src/@planx/components/Pay/model.ts index 5b390e42c6..eff610376f 100644 --- a/editor.planx.uk/src/@planx/components/Pay/model.ts +++ b/editor.planx.uk/src/@planx/components/Pay/model.ts @@ -27,7 +27,6 @@ export interface Pay extends BaseNodeData { yourDetailsDescription?: string; yourDetailsLabel?: string; govPayMetadata: GovPayMetadata[]; - showFeeBreakdown?: boolean; } export const toPence = (decimal: number) => Math.trunc(decimal * 100); @@ -182,7 +181,6 @@ export const getDefaultContent = (): Pay => ({ nomineeTitle: "Details of the person paying", yourDetailsTitle: "Your details", yourDetailsLabel: "Your name or organisation name", - showFeeBreakdown: false, govPayMetadata: [ { key: "flow",