Lift up redirect url link (#263)

This commit is contained in:
Ildar Galeev 2024-02-01 20:36:50 +07:00 committed by GitHub
parent e5ba2567ea
commit 43e0b9b1ba
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 11 additions and 6 deletions

View File

@ -55,11 +55,6 @@ export const ActionBlock = () => {
)}
</>
)}
{initConfig.redirectUrl && (
<OthersButton onClick={() => window.open(initConfig.redirectUrl, '_self')}>
{locale['form.button.back.to.website']}
</OthersButton>
)}
</ErrorBlock>
);
};

View File

@ -1,6 +1,7 @@
import { useContext, useEffect, useMemo } from 'react';
import styled from 'styled-components';
import { Link } from 'checkout/components/ui';
import { FormName, ModalForms, ModalName, ResultFormInfo, ResultType } from 'checkout/hooks';
import { findNamed } from 'checkout/utils/find-named';
import isNil from 'checkout/utils/is-nil';
@ -13,6 +14,10 @@ import { InitialContext } from '../../../../initial-context';
import { ResultContext } from '../../../../result-context';
import { ModalContext } from '../../../modal-context';
const OthersButton = styled(Link)`
padding-top: 12px;
`;
const Title = styled.h2`
font-weight: 500;
font-size: 32px;
@ -40,7 +45,7 @@ const Container = styled.div<{ $hasActions: boolean }>`
`;
const ResultForm = ({ onMount }: { onMount: () => void }) => {
const { locale } = useContext(InitialContext);
const { locale, initConfig } = useContext(InitialContext);
const { setIsComplete } = useContext(ResultContext);
const { modalState } = useContext(ModalContext);
const { hasActions, type, header, description, hasDone } = useMemo(() => {
@ -81,6 +86,11 @@ const ResultForm = ({ onMount }: { onMount: () => void }) => {
<Title>{header}</Title>
<Description> {description}</Description>
{hasActions ? <ActionBlock /> : false}
{initConfig?.redirectUrl && (
<OthersButton onClick={() => window.open(initConfig.redirectUrl, '_self')}>
{locale['form.button.back.to.website']}
</OthersButton>
)}
</Container>
);
};