Skip to content

Commit

Permalink
fix: deposit/withdraw/transfer links
Browse files Browse the repository at this point in the history
  • Loading branch information
ap211unitech committed Jun 25, 2024
1 parent 5a2e06e commit 16f05ed
Show file tree
Hide file tree
Showing 15 changed files with 50 additions and 90 deletions.
9 changes: 6 additions & 3 deletions apps/hestia/src/components/balances/Overview/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,16 +44,19 @@ export const Overview = () => {
</HoverCard>
</div>
<div className="flex items-center gap-2 sm:max-w-[25rem] w-full flex-wrap">
<OverviewCard icon="RiSkipDownLine" href="/thea">
<OverviewCard icon="RiSkipDownLine" href="/send-and-receive">
Deposit
</OverviewCard>
<OverviewCard
icon="RiSkipUpLine"
href="/thea?from=Polkadex&to=Polkadot"
href="/send-and-receive?type=withdraw"
>
Withdraw
</OverviewCard>
<OverviewCard icon="RiArrowLeftRightLine" href="/transfer">
<OverviewCard
icon="RiArrowLeftRightLine"
href="/transfer/PDEX?type=transfer"
>
Transfer
</OverviewCard>
</div>
Expand Down
17 changes: 4 additions & 13 deletions apps/hestia/src/components/balances/Table/columns.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { createColumnHelper } from "@tanstack/react-table";
import { AssetsProps } from "@orderbook/core/hooks";
import { getChainFromTicker } from "@orderbook/core/helpers";
import { Tokens, Typography } from "@polkadex/ux";
import { Fragment } from "react";

Expand Down Expand Up @@ -82,29 +81,21 @@ export const columns = [
columnHelper.accessor((row) => row, {
id: "actions",
cell: (e) => {
const chainName =
getChainFromTicker(e.getValue().ticker) ?? e.getValue().name;
return (
<ActionsCard
withdrawLink={{
pathname: "/thea",
pathname: "/send-and-receive",
query: {
from: "Polkadex",
to: chainName,
asset: e.getValue().ticker,
type: "withdraw",
},
}}
depositLink={{
pathname: "/thea",
query: {
from: chainName,
to: "Polkadex",
asset: e.getValue().ticker,
},
pathname: "/send-and-receive",
}}
tradeLink={`/trading/${e.getValue().ticker}`}
transferLink={{
pathname: `/transfer/${e.getValue().ticker}`,
query: { type: "transfer" },
}}
/>
);
Expand Down
17 changes: 4 additions & 13 deletions apps/hestia/src/components/balances/Table/responsiveTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,34 +41,25 @@ export const ResponsiveTable = ({
</Drawer.Content>
<Drawer.Footer className="flex flex-col gap-2 p-4">
<Button.Solid asChild>
<Link href={`/transfer/${ticker}`}>Transfer</Link>
<Link href={`/transfer/${ticker}?type=transfer`}>Transfer</Link>
</Button.Solid>
<Button.Solid appearance="secondary" asChild>
<Link
href={{
pathname: "/thea",
pathname: "/send-and-receive",
query: {
from: "Polkadex",
to: chainName,
asset: ticker,
type: "withdraw",
},
}}
target="_blank"
>
Withdraw
</Link>
</Button.Solid>
<Button.Solid appearance="secondary" asChild>
<Link
href={{
pathname: "/thea",
query: {
from: chainName,
to: "Polkadex",
asset: ticker,
},
pathname: "/send-and-receive",
}}
target="_blank"
>
Deposit
</Link>
Expand Down
16 changes: 4 additions & 12 deletions apps/hestia/src/components/trading/Orders/Balances/columns.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { createColumnHelper } from "@tanstack/react-table";
import { Typography, Token, tokenAppearance } from "@polkadex/ux";
import { AssetsProps } from "@orderbook/core/hooks";
import { getChainFromTicker } from "@orderbook/core/helpers";

import { ActionsCard } from "@/components/balances/Table/actionsCard";
import { AmountCard } from "@/components/ui/ReadyToUse/amountCard";
Expand Down Expand Up @@ -87,29 +86,22 @@ export const columns = [
balanceColumnHelper.accessor((row) => row, {
id: "actions",
cell: (e) => {
const chainName = getChainFromTicker(e.getValue().ticker);
return (
<ActionsCard
hideButton
withdrawLink={{
pathname: "/thea",
pathname: "/send-and-receive",
query: {
from: "Polkadex",
to: chainName,
asset: e.getValue().ticker,
type: "withdraw",
},
}}
depositLink={{
pathname: "/thea",
query: {
from: chainName,
to: "Polkadex",
asset: e.getValue().ticker,
},
pathname: "/send-and-receive",
}}
tradeLink={`/trading/${e.getValue().ticker}`}
transferLink={{
pathname: `/transfer/${e.getValue().ticker}`,
query: { type: "transfer" },
}}
/>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,16 +36,14 @@ export const ResponsiveTable = ({
</Drawer.Content>
<Drawer.Footer className="flex flex-col gap-2 p-4">
<Button.Solid asChild>
<Link href={`/transfer/${ticker}`}>Transfer</Link>
<Link href={`/transfer/${ticker}?type=transfer`}>Transfer</Link>
</Button.Solid>
<Button.Solid appearance="secondary" asChild>
<Link
href={{
pathname: "/thea",
pathname: "/send-and-receive",
query: {
from: "Polkadex",
to: chainName,
asset: ticker,
type: "withdraw",
},
}}
>
Expand All @@ -55,12 +53,7 @@ export const ResponsiveTable = ({
<Button.Solid appearance="secondary" asChild>
<Link
href={{
pathname: "/thea",
query: {
from: chainName,
to: "Polkadex",
asset: ticker,
},
pathname: "/send-and-receive",
}}
>
Deposit
Expand Down
19 changes: 6 additions & 13 deletions apps/hestia/src/components/trading/PlaceOrder/balance.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
"use client";

import { getChainFromTicker } from "@orderbook/core/helpers";
import { Button, Dropdown, Icons, Typography } from "@polkadex/ux";
import Link from "next/link";
import { PropsWithChildren } from "react";
Expand All @@ -9,7 +8,6 @@ export const Balance = ({
baseTicker,
children,
}: PropsWithChildren<{ baseTicker: string }>) => {
const chainName = getChainFromTicker(baseTicker);
return (
<div className=" self-end flex items-center gap-1">
<Typography.Text size="xs">
Expand All @@ -29,11 +27,9 @@ export const Balance = ({
<Typography.Text asChild size="sm">
<Link
href={{
pathname: "/thea",
pathname: "/send-and-receive",
query: {
from: "Polkadex",
to: chainName,
asset: baseTicker,
type: "withdraw",
},
}}
>
Expand All @@ -45,12 +41,7 @@ export const Balance = ({
<Typography.Text asChild size="sm">
<Link
href={{
pathname: "/thea",
query: {
from: chainName,
to: "Polkadex",
asset: baseTicker,
},
pathname: "/send-and-receive",
}}
>
Deposit
Expand All @@ -59,7 +50,9 @@ export const Balance = ({
</Dropdown.Item>
<Dropdown.Item>
<Typography.Text asChild size="sm">
<Link href={`/transfer/${baseTicker}`}>Transfer</Link>
<Link href={`/transfer/${baseTicker}?type=transfer`}>
Transfer
</Link>
</Typography.Text>
</Dropdown.Item>
</Dropdown.Content>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,10 @@ export const FromTrading = ({
transfer: "Another Funding Account",
};

const withDropown = type === "deposit" || type === "transfer";
return (
<Card
label="To"
title={typeTitle[type]}
dropdown={withDropown}
onChangeDirection={onChangeDirection}
>
<RenderConditional
Expand Down
12 changes: 1 addition & 11 deletions apps/hestia/src/components/transfer/Form/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -146,13 +146,6 @@ export const Form = ({
: onChangeTradingMax();
};

const handleChanteType = (e: MouseEvent<HTMLElement>) => {
e.preventDefault();
e.stopPropagation();
resetForm();
onChangeType(isFromFunding ? "withdraw" : "deposit");
};

const validationSchema = useMemo(
() =>
isFromFunding
Expand Down Expand Up @@ -335,10 +328,7 @@ export const Form = ({
selectedAssetTicker={selectedAsset?.ticker}
/>

<button
onClick={handleChanteType}
className="h-full flex items-center justify-center p-2 max-lg:w-full max-lg:border-y border-primary hover:bg-level-1 duration-300 transition-colors"
>
<button className="h-full flex items-center justify-center p-2 max-lg:w-full max-lg:border-y border-primary hover:bg-level-1 duration-300 transition-colors">
<RiArrowRightLine
className={classNames(
"w-6 h-6 transition-all duration-300",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,11 +99,7 @@ export const InsufficientBalance = ({
<HoverCard.Trigger asChild>
<Link
href={{
pathname: "/thea",
query: {
from: chainName,
to: "Polkadex",
},
pathname: "/send-and-receive",
}}
target="_blank"
className={classNames(
Expand Down
2 changes: 1 addition & 1 deletion apps/hestia/src/components/ui/ConnectWallet/newUser.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ export const NewUser = ({
</Interaction.Content>
<Interaction.Footer>
{walletBalance >= MINIMUM_PDEX_REQUIRED ? (
<Link href="/transfer/PDEX">
<Link href="/send-and-receive">
<Interaction.Action className="w-full" onClick={onClose}>
Transfer funds
</Interaction.Action>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ export const TradingAccountSuccessfull = ({
<Interaction.Action
onClick={() => {
onClose();
router.push("/transfer");
router.push("/send-and-receive");
}}
>
Transfer funds
Expand Down
6 changes: 5 additions & 1 deletion apps/hestia/src/components/ui/Footer/QuickStart/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,11 @@ export const QuickStart = ({
className="underline"
asChild
>
<Link href="/thea" target="_blank" rel="noreferrer noopener">
<Link
href="/send-and-receive"
target="_blank"
rel="noreferrer noopener"
>
using THEA
</Link>
</Typography.Text>
Expand Down
2 changes: 1 addition & 1 deletion apps/hestia/src/components/ui/Header/fundWalletModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ export const FundWalletModal = ({
icon="TransferToTrading"
title="Transfer to trading account"
description="Move funds from your funding account to your trading account."
href="/transfer/PDEX?type=deposit"
href="/transfer/PDEX?type=transfer"
onClick={() => onOpenChange(false)}
/>
</div>
Expand Down
9 changes: 9 additions & 0 deletions apps/hestia/src/middleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ export function middleware(req: NextRequest) {
maintenanceMode,
} = defaultConfig;

const isTransferPage = req.nextUrl.pathname.startsWith("/transfer");

if (maintenanceMode) {
return NextResponse.redirect(new URL("/maintenance", req.url));
}
Expand All @@ -17,6 +19,13 @@ export function middleware(req: NextRequest) {
if (!isBridgeEnabled && req.nextUrl.pathname.startsWith("/thea")) {
return NextResponse.redirect(new URL("/", req.url));
}
if (isTransferPage) {
const nextUrl = req.nextUrl;
if (nextUrl.searchParams.get("type") !== "transfer") {
nextUrl.searchParams.set("type", "transfer");
return NextResponse.redirect(nextUrl);
}
}
}

export const config = {
Expand Down
6 changes: 3 additions & 3 deletions packages/core/src/constants/notifications.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,9 @@ export const NOTIFICATIONS = {
return {
category: "General",
message: `New Trading Account Created 🎉`,
description: `Your new trading account have been successfully created. Transfer funds from your funding account to your trading account to start trading.`,
description: `Your new trading account have been successfully created. Deposit more funds from your funding account to Polkadex orderbook to start trading.`,
type: "Success",
href: "/transfer/PDEX",
href: "/send-and-receive",
};
},
removeTradingAccount: (): NotificationPayload => {
Expand All @@ -107,7 +107,7 @@ export const NOTIFICATIONS = {
message: `Trading account removed`,
description: `Your trading account have been successfully removed from the blockchain. Don't worry your funds are safe. You can create another trading account to start trading with them.`,
type: "Success",
href: "/transfer/PDEX",
href: "/trading/PDEXUSDT",
};
},
claimReward: ({ reward }: { reward: string }): NotificationPayload => {
Expand Down

0 comments on commit 16f05ed

Please sign in to comment.