-
Notifications
You must be signed in to change notification settings - Fork 70
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3cd5294
commit 890f1e4
Showing
12 changed files
with
123 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
67 changes: 67 additions & 0 deletions
67
src/components/DepositSubmittedScreen/DepositSubmittedScreen.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
import { FC, useState } from "react"; | ||
import { useTranslation } from "react-i18next"; | ||
|
||
import { SubmittedDepositTransaction } from "../../entities/SubmittedTransaction/SubmittedTransaction"; | ||
import useDebounce from "../../hooks/useDebounce"; | ||
import { | ||
OverlayContainer, | ||
OverlaySubHeading, | ||
OverlayTitle, | ||
OverlayTransactionLink, | ||
} from "../../styled-components/Overlay/Overlay"; | ||
import { TransactionStatusType } from "../../types/transactionTypes"; | ||
import OverlayLoader from "../OverlayLoader/OverlayLoader"; | ||
|
||
interface DepositSubmittedScreenProps { | ||
chainId?: number; | ||
transaction?: SubmittedDepositTransaction; | ||
className?: string; | ||
} | ||
|
||
const DepositSubmittedScreen: FC<DepositSubmittedScreenProps> = ({ | ||
chainId, | ||
transaction, | ||
className = "", | ||
}) => { | ||
const { t } = useTranslation(); | ||
const [isAnimatedToCenter, setIsAnimatedToCenter] = useState(false); | ||
|
||
const isSucceeded = transaction?.status === TransactionStatusType.succeeded; | ||
|
||
useDebounce( | ||
() => { | ||
if (isSucceeded) { | ||
setIsAnimatedToCenter(true); | ||
} | ||
}, | ||
500, | ||
[isSucceeded] | ||
); | ||
|
||
return ( | ||
<OverlayContainer | ||
className={className} | ||
style={{ | ||
transform: isAnimatedToCenter ? "translateY(5rem)" : "translateY(0)", | ||
}} | ||
> | ||
<OverlayLoader isSucceeded={isSucceeded} /> | ||
<OverlayTitle type="h2"> | ||
{isSucceeded | ||
? t("orders.depositComplete") | ||
: t("orders.depositProcessing")} | ||
</OverlayTitle> | ||
<OverlaySubHeading isHidden={isSucceeded}> | ||
{transaction?.hash && chainId && ( | ||
<OverlayTransactionLink | ||
isHidden={isSucceeded} | ||
chainId={chainId} | ||
hash={transaction.hash} | ||
/> | ||
)} | ||
</OverlaySubHeading> | ||
</OverlayContainer> | ||
); | ||
}; | ||
|
||
export default DepositSubmittedScreen; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { FC } from "react"; | ||
|
||
import { OverlaySpinningLoader } from "../../styled-components/Overlay/Overlay"; | ||
import { Container, StyledIcon } from "./OverlayLoader.styles"; | ||
|
||
interface OverlayLoaderProps { | ||
isSucceeded?: boolean; | ||
className?: string; | ||
} | ||
|
||
const OverlayLoader: FC<OverlayLoaderProps> = ({ isSucceeded, className }) => { | ||
return ( | ||
<Container className={className}> | ||
{isSucceeded ? ( | ||
<StyledIcon name="check-circle" /> | ||
) : ( | ||
<OverlaySpinningLoader /> | ||
)} | ||
</Container> | ||
); | ||
}; | ||
|
||
export default OverlayLoader; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,11 @@ | ||
import { useAppSelector } from "../app/hooks"; | ||
import { SubmittedDepositTransaction } from "../entities/SubmittedTransaction/SubmittedTransaction"; | ||
import { selectPendingDeposits } from "../features/transactions/transactionsSlice"; | ||
|
||
const useDepositPending = (): boolean => { | ||
const useDepositPending = (): SubmittedDepositTransaction | undefined => { | ||
const pendingDeposits = useAppSelector(selectPendingDeposits); | ||
|
||
return !!pendingDeposits.length; | ||
return pendingDeposits.length ? pendingDeposits[0] : undefined; | ||
}; | ||
|
||
export default useDepositPending; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters