From 3591dd54322b3e3f553d69a0aa851a54c7aabb4d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Ribeiro?= Date: Tue, 16 Jul 2024 10:38:19 -0300 Subject: [PATCH] Add order details links, reset fields on advanced configs close, balance validation, and add remove draft orders dialog (#56) * add links on order details and create new text for order hash * reset fields on advanced settings dialog close * add validation if balance bigger than sell amount * handle null price error * add select all option on draft and open order tables * refactor get or fetch usd price redability * fix market price information and fix dialog padding * remove unused imports * add draft order delete dialog * on back to home page preserve order tab * Add action menu on tables to invert price (#57) * add action menu on tables to invert price * run formater and linter * increase test timeout --------- Co-authored-by: Pedro Yves Fracari Co-authored-by: Pedro Yves Fracari <55461956+yvesfracari@users.noreply.github.com> --- package.json | 2 +- pnpm-lock.yaml | 6 +- .../[safeAddress]/[orderId]/page.tsx | 2 +- src/components/AdvancedSettingsDialog.tsx | 9 +- src/components/DraftOrdersTab.tsx | 70 ++++-- src/components/HistoryOrdersTab.tsx | 39 ++- src/components/OpenOrdersTab.tsx | 62 +++-- src/components/OrderDetails.tsx | 132 +++++----- src/components/OrderDetailsInformation.tsx | 2 +- src/components/OrderDropdownMenuCell.tsx | 67 ++++++ src/components/OrdersTabs.tsx | 5 +- src/components/PriceInputCard.tsx | 1 + src/components/RemoveDraftOrdersDialog.tsx | 62 +++++ src/components/ReviewOrdersDialog.tsx | 13 +- src/components/TokenInputCard.tsx | 23 +- src/components/TokenSelect.tsx | 4 +- .../swap-card/SwapCardSubmitButton.tsx | 226 ++++++++---------- src/components/swap-card/SwapForm.tsx | 2 +- src/contexts/appContext.tsx | 2 +- src/contexts/ordersContext.tsx | 2 +- src/contexts/swapCardContext.tsx | 14 +- src/contexts/tokensContext.tsx | 10 +- src/hooks/useOrderList.ts | 6 +- src/hooks/useSwap.ts | 6 +- src/hooks/useTokenList.ts | 4 +- src/hooks/useTransaction.ts | 2 +- src/hooks/useUIState.ts | 2 +- src/lib/__tests__/oracleRouter.test.ts | 20 +- src/lib/schema.ts | 8 +- src/lib/tokenUtils.ts | 10 +- src/lib/tooltipDescriptions.ts | 2 +- 31 files changed, 515 insertions(+), 300 deletions(-) create mode 100644 src/components/OrderDropdownMenuCell.tsx create mode 100644 src/components/RemoveDraftOrdersDialog.tsx diff --git a/package.json b/package.json index 6521797..140a589 100644 --- a/package.json +++ b/package.json @@ -67,7 +67,6 @@ "clsx": "^2.1.1", "cmdk": "^0.2.1", "embla-carousel-react": "8.1.6", - "eslint-plugin-react-compiler": "0.0.0-experimental-0998c1e-20240625", "gql": "^1.1.2", "graphql-codegen-plugin-typescript-swr": "^0.8.5", "graphql-request": "6.1.0", @@ -114,6 +113,7 @@ "eslint-plugin-graphql": "latest", "eslint-plugin-import": "^2.29.1", "eslint-plugin-prettier": "latest", + "eslint-plugin-react-compiler": "0.0.0-experimental-0998c1e-20240625", "eslint-plugin-react-hooks": "latest", "eslint-plugin-simple-import-sort": "latest", "eslint-plugin-tailwindcss": "^3.17.4", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 9189311..0ff2c0f 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -149,9 +149,6 @@ importers: embla-carousel-react: specifier: 8.1.6 version: 8.1.6(react@19.0.0-rc-df5f2736-20240712) - eslint-plugin-react-compiler: - specifier: 0.0.0-experimental-0998c1e-20240625 - version: 0.0.0-experimental-0998c1e-20240625(eslint@8.56.0) gql: specifier: ^1.1.2 version: 1.1.2 @@ -285,6 +282,9 @@ importers: eslint-plugin-prettier: specifier: latest version: 5.1.3(eslint-config-prettier@9.1.0(eslint@8.56.0))(eslint@8.56.0)(prettier@3.3.2) + eslint-plugin-react-compiler: + specifier: 0.0.0-experimental-0998c1e-20240625 + version: 0.0.0-experimental-0998c1e-20240625(eslint@8.56.0) eslint-plugin-react-hooks: specifier: latest version: 4.6.0(eslint@8.56.0) diff --git a/src/app/[chainId]/[safeAddress]/[orderId]/page.tsx b/src/app/[chainId]/[safeAddress]/[orderId]/page.tsx index ed7bdfc..ccd8214 100644 --- a/src/app/[chainId]/[safeAddress]/[orderId]/page.tsx +++ b/src/app/[chainId]/[safeAddress]/[orderId]/page.tsx @@ -3,7 +3,7 @@ import { Address } from "viem"; import { OrderDetails } from "#/components/OrderDetails"; import { ChainId } from "#/lib/publicClients"; -export default async function OrderPage({ +export default function OrderPage({ params, }: { params: { diff --git a/src/components/AdvancedSettingsDialog.tsx b/src/components/AdvancedSettingsDialog.tsx index 5b56bdf..dca9890 100644 --- a/src/components/AdvancedSettingsDialog.tsx +++ b/src/components/AdvancedSettingsDialog.tsx @@ -78,8 +78,15 @@ export function AdvancedSettingsDialog() { const receiver = useWatch({ control, name: "receiver" }); + const handleOpenChange = (isOpen: boolean) => { + if (!isOpen) { + reset(advancedSettings); + } + setOpen(isOpen); + }; + return ( - + +