Skip to content

Commit

Permalink
copy refinement
Browse files Browse the repository at this point in the history
scroll to view warning message

revert scroll view and simplify demo user screens

refine boolean code and remove redundant space

copy refinement on send component
  • Loading branch information
RODO94 committed Nov 13, 2024
1 parent 38286f3 commit 13d917e
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 42 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import type {
PaymentStatus,
} from "@opensystemslab/planx-core/types";
import Card from "@planx/components/shared/Preview/Card";
import { ErrorSummaryContainer } from "@planx/components/shared/Preview/ErrorSummaryContainer";
import SaveResumeButton from "@planx/components/shared/Preview/SaveResumeButton";
import { WarningContainer } from "@planx/components/shared/Preview/WarningContainer";
import DelayedLoadingIndicator from "components/DelayedLoadingIndicator/DelayedLoadingIndicator";
Expand Down Expand Up @@ -87,11 +86,7 @@ const InviteToPayForm: React.FC<InviteToPayFormProps> = ({
yourDetailsLabel,
paymentStatus,
}) => {
const [sessionId, path, teamSlug] = useStore((state) => [
state.sessionId,
state.path,
state.teamSlug,
]);
const [sessionId, path] = useStore((state) => [state.sessionId, state.path]);
const [isLoading, setIsLoading] = useState(false);
const [error, setError] = useState(false);
const isSaveReturn = path === ApplicationPath.SaveAndReturn;
Expand Down Expand Up @@ -257,16 +252,15 @@ const InviteToPayForm: React.FC<InviteToPayFormProps> = ({
no longer be able to make changes.
</Typography>
</WarningContainer>
{teamSlug !== "demo" &&
(error ? (
<ErrorWrapper
error={"Error generating payment request, please try again"}
>
<SubmitButton />
</ErrorWrapper>
) : (
{error ? (
<ErrorWrapper
error={"Error generating payment request, please try again"}
>
<SubmitButton />
))}
</ErrorWrapper>
) : (
<SubmitButton />
)}
</StyledForm>
<Button
variant="contained"
Expand All @@ -278,18 +272,6 @@ const InviteToPayForm: React.FC<InviteToPayFormProps> = ({
>
{"I want to pay for this application myself"}
</Button>

{teamSlug === "demo" && (
<ErrorSummaryContainer mt={2}>
<Typography variant="h4" ml={2} mb={1}>
GOV.UK Pay is not configured for the Demo team
</Typography>
<Typography variant="body2" ml={2}>
You can click "I want to pay for this application myself" to
continue your application
</Typography>
</ErrorSummaryContainer>
)}
{isSaveReturn && <SaveResumeButton />}
</Card>
);
Expand Down
21 changes: 12 additions & 9 deletions editor.planx.uk/src/@planx/components/Pay/Public/Pay.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,7 @@ enum Action {
Success,
}

export const PAY_API_ERROR_UNSUPPORTED_TEAM =
"GOV.UK Pay is not enabled for this local authority";
export const PAY_API_ERROR_UNSUPPORTED_TEAM = "GOV.UK Pay is not enabled for";

function Component(props: Props) {
const [
Expand Down Expand Up @@ -76,6 +75,11 @@ function Component(props: Props) {

const metadata = [...(props.govPayMetadata || []), ...defaultMetadata];

const errorMessage =
teamSlug !== "demo"
? "GOV.UK Pay is not enabled for this local authority"
: "GOV.UK Pay is not enabled for the Demo team";

// Handles UI states
const reducer = (_state: ComponentState, action: Action): ComponentState => {
switch (action) {
Expand Down Expand Up @@ -114,6 +118,10 @@ function Component(props: Props) {

const handleError = useErrorHandler();

const isTeamSupported =
state.status !== "unsupported_team" && teamSlug !== "demo";
const showPayOptions = props.allowInviteToPay && !props.hidePay;

useEffect(() => {
// Auto-skip component when fee=0
if (fee <= 0) {
Expand Down Expand Up @@ -294,17 +302,12 @@ function Component(props: Props) {
: "Retry payment"
}
error={
(state.status === "unsupported_team" &&
"GOV.UK Pay is not enabled for this local authority") ||
(state.status === "unsupported_team" && errorMessage) ||
(state.status === "undefined_fee" &&
"We are unable to calculate your fee right now") ||
undefined
}
showInviteToPay={
props.allowInviteToPay &&
!props.hidePay &&
state.status !== "unsupported_team"
}
showInviteToPay={showPayOptions && isTeamSupported}
paymentStatus={govUkPayment?.state?.status}
hidePay={props.hidePay}
/>
Expand Down
12 changes: 6 additions & 6 deletions editor.planx.uk/src/@planx/components/Send/Public.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const SendComponent: React.FC<Props> = ({
) {
return <SkipSendWarning {...fullProps} />;
} else if (window.location.pathname.split("/")[1] === "demo") {
return <DemoTeamWarning />;
return <DemoTeamWarning {...fullProps} />;
} else {
return <CreateSendEvents {...fullProps} />;
}
Expand All @@ -55,15 +55,15 @@ const SkipSendWarning: React.FC<Props> = (props) => (
</Card>
);

const DemoTeamWarning: React.FC = () => (
<Card>
const DemoTeamWarning: React.FC<Props> = (props) => (
<Card handleSubmit={props.handleSubmit}>
<ErrorSummaryContainer role="status">
<Typography variant="h4" ml={2} mb={1}>
The send component is not configured for the Demo team
Send is disabled for the Demo team
</Typography>
<Typography variant="body2" ml={2}>
Integrations need to be configured to allow submissions to be sent from
PlanX
Team integrations need to be configured to allow submissions to be sent
from PlanX
</Typography>
</ErrorSummaryContainer>
</Card>
Expand Down

0 comments on commit 13d917e

Please sign in to comment.