-
Notifications
You must be signed in to change notification settings - Fork 63
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
Showing
22 changed files
with
369 additions
and
101 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
34 changes: 34 additions & 0 deletions
34
src/app/pages/Market/crypto-exchange/components/ExchangeCountdown.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,34 @@ | ||
import React, { memo } from 'react'; | ||
|
||
import Countdown from 'react-countdown'; | ||
|
||
import { getExchangeData } from 'lib/apis/exolix/utils'; | ||
|
||
import { useCryptoExchangeDataState } from '../context'; | ||
|
||
const FORTY_FIVE_MINUTES_IN_MS = 45 * 60 * 1000; | ||
|
||
interface Props { | ||
className?: string; | ||
} | ||
|
||
export const ExchangeCountdown = memo<Props>(({ className }) => { | ||
const { exchangeData, setExchangeData } = useCryptoExchangeDataState(); | ||
|
||
if (!exchangeData) return null; | ||
|
||
return ( | ||
<Countdown | ||
renderer={props => ( | ||
<span className={className}> | ||
{props.minutes}:{props.seconds < 10 ? '0' + props.seconds : props.seconds} | ||
</span> | ||
)} | ||
date={new Date(exchangeData.createdAt).getTime() + FORTY_FIVE_MINUTES_IN_MS} | ||
onComplete={async () => { | ||
const data = await getExchangeData(exchangeData.id); | ||
setExchangeData(data); | ||
}} | ||
/> | ||
); | ||
}); |
35 changes: 35 additions & 0 deletions
35
src/app/pages/Market/crypto-exchange/components/InfoBlock.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,35 @@ | ||
import React, { FC } from 'react'; | ||
|
||
import clsx from 'clsx'; | ||
|
||
import { T, TID } from 'lib/i18n'; | ||
|
||
interface InfoContainerProps extends PropsWithChildren { | ||
className?: string; | ||
} | ||
|
||
export const InfoContainer: FC<InfoContainerProps> = ({ className, children }) => ( | ||
<div className={clsx('flex flex-col px-4 py-2 rounded-lg shadow-bottom border-0.5 border-transparent', className)}> | ||
{children} | ||
</div> | ||
); | ||
|
||
interface InfoRawProps extends InfoContainerProps { | ||
title: TID; | ||
bottomSeparator?: boolean; | ||
} | ||
|
||
export const InfoRaw: FC<InfoRawProps> = ({ title, bottomSeparator, className, children }) => ( | ||
<div | ||
className={clsx( | ||
'py-3 flex flex-row justify-between items-center', | ||
bottomSeparator && 'border-b-0.5 border-lines', | ||
className | ||
)} | ||
> | ||
<p className="p-1 text-font-description text-grey-1"> | ||
<T id={title} /> | ||
</p> | ||
{children} | ||
</div> | ||
); |
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
22 changes: 22 additions & 0 deletions
22
src/app/pages/Market/crypto-exchange/components/SupportButton.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,22 @@ | ||
import React, { memo } from 'react'; | ||
|
||
import clsx from 'clsx'; | ||
|
||
import { Anchor, IconBase } from 'app/atoms'; | ||
import { ReactComponent as OutLinkIcon } from 'app/icons/base/outLink.svg'; | ||
import { T } from 'lib/i18n'; | ||
|
||
import { EXOLIX_CONTACT_LINK } from '../config'; | ||
|
||
interface Props { | ||
className?: string; | ||
} | ||
|
||
export const SupportLink = memo<Props>(({ className }) => ( | ||
<Anchor href={EXOLIX_CONTACT_LINK} className={clsx('py-0.5 flex flex-row justify-center items-center', className)}> | ||
<span className="text-font-description-bold text-secondary"> | ||
<T id="exolixSupport" /> | ||
</span> | ||
<IconBase size={16} className="text-secondary" Icon={OutLinkIcon} /> | ||
</Anchor> | ||
)); |
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,11 +1,20 @@ | ||
import { useState } from 'react'; | ||
|
||
import constate from 'constate'; | ||
|
||
import { ExchangeData } from 'lib/apis/exolix/types'; | ||
import { useStorage } from 'lib/temple/front'; | ||
import { useAccount } from 'temple/front'; | ||
|
||
export type Steps = 0 | 1 | 2 | 3; | ||
|
||
export const [CryptoExchangeDataProvider, useCryptoExchangeDataState] = constate(() => { | ||
const currentAccount = useAccount(); | ||
|
||
const [exchangeData, setExchangeData] = useStorage<ExchangeData | nullish>( | ||
`topup_exchange_data_state_${currentAccount.id}`, | ||
null | ||
); | ||
|
||
export const [ExchangeDataProvider, useExchangeDataState] = constate(() => { | ||
const [exchangeData, setExchangeData] = useState<ExchangeData | nullish>(null); | ||
const [step, setStep] = useStorage<Steps>(`topup_step_state_${currentAccount.id}`, 0); | ||
|
||
return { exchangeData, setExchangeData }; | ||
return { exchangeData, setExchangeData, step, setStep }; | ||
}); |
35 changes: 35 additions & 0 deletions
35
src/app/pages/Market/crypto-exchange/hooks/use-top-up-update.ts
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,35 @@ | ||
import { useEffect, useRef } from 'react'; | ||
|
||
import { toastError } from 'app/toaster'; | ||
import { getExchangeData } from 'lib/apis/exolix/utils'; | ||
|
||
import { useCryptoExchangeDataState } from '../context'; | ||
|
||
export const useTopUpUpdate = () => { | ||
const { exchangeData, setExchangeData } = useCryptoExchangeDataState(); | ||
|
||
const isAlive = useRef(false); | ||
|
||
useEffect(() => { | ||
let timeoutId = setTimeout(async function repeat() { | ||
isAlive.current = true; | ||
if (!exchangeData) return; | ||
|
||
try { | ||
const data = await getExchangeData(exchangeData.id); | ||
if (!isAlive.current) { | ||
return; | ||
} | ||
setExchangeData(data); | ||
timeoutId = setTimeout(repeat, 3000); | ||
} catch (e) { | ||
toastError('Failed to update order status!'); | ||
} | ||
}, 3000); | ||
|
||
return () => { | ||
isAlive.current = false; | ||
clearTimeout(timeoutId); | ||
}; | ||
}, [exchangeData, setExchangeData]); | ||
}; |
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
Oops, something went wrong.