-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'rc-1.17.0' into refactor/adjust-delegate-registration-form
- Loading branch information
Showing
23 changed files
with
639 additions
and
354 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
{ | ||
"name": "arkvault", | ||
"version": "1.15.0", | ||
"version": "1.17.0", | ||
"engines": { | ||
"node": ">=20.12.2" | ||
}, | ||
|
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
29 changes: 29 additions & 0 deletions
29
src/domains/transaction/components/RecipientsModal/RecipientsList.test.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,29 @@ | ||
import React from "react"; | ||
import { RecipientsList } from "./RecipientsList"; | ||
import { RecipientItem } from "./RecipientsModal.contracts"; | ||
import { render, screen } from "@testing-library/react"; | ||
|
||
const recipients: RecipientItem[] = [ | ||
{ | ||
address: "FJKDSALJFKASLJFKSDAJD333FKFKDSAJFKSAJFKLASJKDFJ", | ||
alias: "Recipient 1", | ||
amount: 150, | ||
}, | ||
{ | ||
address: "AhFJKDSALJFKASLJFKSDEAJ333FKFKDSAJFKSAJFKLASJKDFJ", | ||
alias: "Recipient 2", | ||
amount: 100, | ||
}, | ||
]; | ||
|
||
describe("RecipientsList", () => { | ||
it("should render", () => { | ||
const ticker = "DARK"; | ||
|
||
render(<RecipientsList recipients={recipients} ticker={ticker} />); | ||
|
||
expect(screen.getAllByTestId("RecipientsListItem").length).toBe(recipients.length); | ||
expect(screen.getByText(recipients[0].alias)).toBeInTheDocument(); | ||
expect(screen.getByText(recipients[0].amount + ` ${ticker}`)).toBeInTheDocument(); | ||
}); | ||
}); |
55 changes: 55 additions & 0 deletions
55
src/domains/transaction/components/RecipientsModal/RecipientsList.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,55 @@ | ||
import { useTranslation } from "react-i18next"; | ||
import { InfoDetail, MultiEntryItem } from "@/app/components/MultiEntryItem/MultiEntryItem"; | ||
import { Address } from "@/app/components/Address"; | ||
import { Amount } from "@/app/components/Amount"; | ||
import React from "react"; | ||
import { RecipientsProperties } from "@/domains/transaction/components/RecipientsModal/RecipientsModal.contracts"; | ||
|
||
export const RecipientsList = ({ recipients, ticker }: RecipientsProperties): JSX.Element => { | ||
const { t } = useTranslation(); | ||
|
||
return ( | ||
<> | ||
{recipients.map((recipient, index) => ( | ||
<MultiEntryItem | ||
key={index} | ||
size="md" | ||
dataTestId="RecipientsListItem" | ||
titleSlot={ | ||
<div className="flex w-full items-center justify-between"> | ||
<div className="whitespace-nowrap text-sm font-semibold leading-[17px] text-theme-secondary-700 dark:text-theme-secondary-500"> | ||
{t("COMMON.RECIPIENT_#", { count: index + 1 })} | ||
</div> | ||
</div> | ||
} | ||
bodySlot={ | ||
<div className="space-y-4"> | ||
<InfoDetail | ||
label="Address" | ||
body={ | ||
<Address | ||
address={recipient.address} | ||
walletName={recipient.alias} | ||
showCopyButton | ||
walletNameClass="leading-[17px] text-sm" | ||
addressClass="leading-[17px] text-sm text-theme-secondary-500 dark:text-theme-secondary-700" | ||
/> | ||
} | ||
/> | ||
<InfoDetail | ||
label="Value" | ||
body={ | ||
<Amount | ||
ticker={ticker} | ||
value={recipient.amount as number} | ||
className="text-sm font-semibold leading-[17px] text-theme-secondary-900 dark:text-theme-secondary-200" | ||
/> | ||
} | ||
/> | ||
</div> | ||
} | ||
/> | ||
))} | ||
</> | ||
); | ||
}; |
11 changes: 11 additions & 0 deletions
11
src/domains/transaction/components/RecipientsModal/RecipientsModal.contracts.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,11 @@ | ||
export interface RecipientItem { | ||
address: string; | ||
alias?: string; | ||
amount?: number; | ||
isDelegate?: boolean; | ||
} | ||
|
||
export interface RecipientsProperties { | ||
recipients: RecipientItem[]; | ||
ticker: string; | ||
} |
49 changes: 49 additions & 0 deletions
49
src/domains/transaction/components/RecipientsModal/RecipientsModal.test.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,49 @@ | ||
import React from "react"; | ||
import { RecipientItem } from "./RecipientsModal.contracts"; | ||
import { screen } from "@testing-library/react"; | ||
import { RecipientsModal } from "./RecipientsModal"; | ||
import { renderResponsive } from "@/utils/testing-library"; | ||
|
||
const recipients: RecipientItem[] = [ | ||
{ | ||
address: "FJKDSALJFKASLJFKSDAJD333FKFKDSAJFKSAJFKLASJKDFJ", | ||
alias: "Recipient 1", | ||
amount: 150, | ||
}, | ||
{ | ||
address: "AhFJKDSALJFKASLJFKSDEAJ333FKFKDSAJFKSAJFKLASJKDFJ", | ||
alias: "Recipient 2", | ||
amount: 100, | ||
}, | ||
]; | ||
|
||
describe("RecipientsModal", () => { | ||
it("should render `RecipientsLists` in `sm` screen", () => { | ||
renderResponsive( | ||
<RecipientsModal recipients={recipients} ticker="DARK" isOpen={true} onClose={vi.fn()} />, | ||
"sm", | ||
); | ||
|
||
expect(screen.getAllByTestId("RecipientsListItem").length).toBeTruthy(); | ||
expect(screen.queryByTestId("TableWrapper")).not.toBeInTheDocument(); | ||
}); | ||
|
||
it("should render `RecipientsTable` in `lg` screen", () => { | ||
renderResponsive( | ||
<RecipientsModal recipients={recipients} ticker="DARK" isOpen={true} onClose={vi.fn()} />, | ||
"lg", | ||
); | ||
|
||
expect(screen.getByTestId("TableWrapper")).toBeInTheDocument(); | ||
expect(screen.queryAllByTestId("RecipientsListItem").length).toBe(0); | ||
}); | ||
|
||
it("should show number of recipients in the modal title", () => { | ||
renderResponsive( | ||
<RecipientsModal recipients={recipients} ticker="DARK" isOpen={true} onClose={vi.fn()} />, | ||
"sm", | ||
); | ||
|
||
expect(screen.getByTestId("RecipientsModal--RecipientsCount")).toHaveTextContent(recipients.length); | ||
}); | ||
}); |
53 changes: 53 additions & 0 deletions
53
src/domains/transaction/components/RecipientsModal/RecipientsModal.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,53 @@ | ||
import React from "react"; | ||
import { Modal } from "@/app/components/Modal"; | ||
import { useTranslation } from "react-i18next"; | ||
import { useBreakpoint } from "@/app/hooks"; | ||
import { RecipientsTable } from "@/domains/transaction/components/RecipientsModal/RecipientsTable"; | ||
import { RecipientsList } from "@/domains/transaction/components/RecipientsModal/RecipientsList"; | ||
import { RecipientItem } from "@/domains/transaction/components/RecipientsModal/RecipientsModal.contracts"; | ||
|
||
interface Properties { | ||
isOpen: boolean; | ||
onClose: () => void; | ||
recipients: RecipientItem[]; | ||
ticker: string; | ||
} | ||
|
||
const ModalTitle = ({ count }: { count: number }) => { | ||
const { t } = useTranslation(); | ||
|
||
return ( | ||
<span className="inline-flex items-center gap-1 font-semibold leading-5"> | ||
<span>{t("COMMON.RECIPIENTS")} </span> | ||
<span | ||
className="text-theme-secondary-500 dark:text-theme-secondary-500" | ||
data-testid="RecipientsModal--RecipientsCount" | ||
> | ||
({count}) | ||
</span> | ||
</span> | ||
); | ||
}; | ||
|
||
export const RecipientsModal: React.FC<Properties> = ({ isOpen, onClose, recipients, ticker }) => { | ||
const { isMdAndAbove } = useBreakpoint(); | ||
|
||
return ( | ||
<Modal | ||
isOpen={isOpen} | ||
size="3xl" | ||
title={<ModalTitle count={recipients.length} />} | ||
onClose={onClose} | ||
noButtons | ||
data-testid="RecipientsModal" | ||
> | ||
<div className="mt-2.5 md:mt-[18px]"> | ||
{isMdAndAbove ? ( | ||
<RecipientsTable recipients={recipients} ticker={ticker} /> | ||
) : ( | ||
<RecipientsList recipients={recipients} ticker={ticker} /> | ||
)} | ||
</div> | ||
</Modal> | ||
); | ||
}; |
29 changes: 29 additions & 0 deletions
29
src/domains/transaction/components/RecipientsModal/RecipientsTable.test.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,29 @@ | ||
import React from "react"; | ||
import { RecipientItem } from "./RecipientsModal.contracts"; | ||
import { RecipientsTable } from "./RecipientsTable"; | ||
import { render, screen } from "@testing-library/react"; | ||
|
||
const recipients: RecipientItem[] = [ | ||
{ | ||
address: "FJKDSALJFKASLJFKSDAJD333FKFKDSAJFKSAJFKLASJKDFJ", | ||
alias: "Recipient 1", | ||
amount: 150, | ||
}, | ||
{ | ||
address: "AhFJKDSALJFKASLJFKSDEAJ333FKFKDSAJFKSAJFKLASJKDFJ", | ||
alias: "Recipient 2", | ||
amount: 100, | ||
}, | ||
]; | ||
|
||
describe("RecipientsTable", () => { | ||
it("should render", () => { | ||
const ticker = "DARK"; | ||
|
||
render(<RecipientsTable recipients={recipients} ticker={ticker} />); | ||
|
||
expect(screen.getByTestId("TableWrapper")).toBeInTheDocument(); | ||
expect(screen.getByText(recipients[0].alias)).toBeInTheDocument(); | ||
expect(screen.getByText(recipients[0].amount + ` ${ticker}`)).toBeInTheDocument(); | ||
}); | ||
}); |
72 changes: 72 additions & 0 deletions
72
src/domains/transaction/components/RecipientsModal/RecipientsTable.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,72 @@ | ||
import React, { FC, useCallback, useMemo } from "react"; | ||
import { useTranslation } from "react-i18next"; | ||
import { Column } from "react-table"; | ||
import { TableWrapper } from "@/app/components/Table/TableWrapper"; | ||
import { Table, TableCell, TableRow } from "@/app/components/Table"; | ||
import { Address } from "@/app/components/Address"; | ||
import { Amount } from "@/app/components/Amount"; | ||
import { | ||
RecipientItem, | ||
RecipientsProperties, | ||
} from "@/domains/transaction/components/RecipientsModal/RecipientsModal.contracts"; | ||
|
||
export const RecipientsTable: FC<RecipientsProperties> = ({ recipients, ticker }) => { | ||
const { t } = useTranslation(); | ||
|
||
const columns = useMemo<Column<RecipientItem>[]>( | ||
() => [ | ||
{ | ||
Header: "#", | ||
headerClassName: "no-border", | ||
}, | ||
{ | ||
Header: t("COMMON.ADDRESS"), | ||
accessor: "alias", | ||
headerClassName: "no-border", | ||
}, | ||
{ | ||
Header: t("COMMON.AMOUNT"), | ||
accessor: "amount", | ||
className: "justify-end", | ||
headerClassName: "no-border", | ||
}, | ||
], | ||
[t], | ||
); | ||
|
||
const renderTableRow = useCallback( | ||
(recipient: RecipientItem, index: number) => ( | ||
<TableRow key={index} border className="relative"> | ||
<TableCell variant="start" innerClassName="pl-6"> | ||
<span className="text-sm font-semibold leading-[17px] text-theme-text">{index + 1}</span> | ||
</TableCell> | ||
|
||
<TableCell> | ||
<Address | ||
walletName={recipient.alias} | ||
address={recipient.address} | ||
truncateOnTable | ||
showCopyButton | ||
walletNameClass="text-sm text-theme-secondary-900 dark:text-theme-secondary-200 leading-[17px]" | ||
addressClass="text-sm text-theme-secondary-700 dark:text-theme-secondary-500 leading-[17px] flex items-center h-5" | ||
/> | ||
</TableCell> | ||
|
||
<TableCell variant="end" innerClassName="justify-end pr-6"> | ||
<span className="whitespace-nowrap text-sm font-semibold leading-[17px]"> | ||
<Amount ticker={ticker} value={recipient.amount as number} /> | ||
</span> | ||
</TableCell> | ||
</TableRow> | ||
), | ||
[ticker], | ||
); | ||
|
||
return ( | ||
<TableWrapper> | ||
<Table className="with-x-padding overflow-hidden rounded-xl" columns={columns} data={recipients}> | ||
{renderTableRow} | ||
</Table> | ||
</TableWrapper> | ||
); | ||
}; |
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 @@ | ||
export * from "./RecipientsModal"; |
Oops, something went wrong.