Skip to content

Commit

Permalink
fixing e2e
Browse files Browse the repository at this point in the history
  • Loading branch information
Marchand-Nicolas committed Oct 14, 2024
1 parent c73abf4 commit 4c3863f
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 14 deletions.
7 changes: 5 additions & 2 deletions components/discover/claimModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ const ClaimModal: FunctionComponent<ClaimModalProps> = ({
/>
</div>
<div className="flex w-full flex-col py-4 max-h-80 overflow-auto">
{rewards && Object.keys(rewards).length > 0 ? (
{rewards && calls.length > 0 ? (
Object.entries(rewards)
.filter(([key, rewardList]) => key && rewardList.length > 0)
.map(([key, rewardList]) => (
Expand Down Expand Up @@ -178,7 +178,10 @@ const ClaimModal: FunctionComponent<ClaimModalProps> = ({
<Typography type={TEXT_TYPE.BODY_MIDDLE}>Cancel</Typography>
</button>
<div className="w-fit">
<Button disabled={!calls} onClick={doClaimRewards}>
<Button
disabled={!calls || calls.length === 0 || loading}
onClick={doClaimRewards}
>
Claim all
</Button>
</div>
Expand Down
36 changes: 24 additions & 12 deletions components/discover/defiTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ import { getRedirectLink } from "@utils/defi";
import DefiTableSkeleton from "./defiTableSkeleton";
import ClaimModal from "./claimModal";
import SuccessModal from "./successModal";
import { useAccount } from "@starknet-react/core";

type DataTableProps = {
data: TableInfo[];
Expand Down Expand Up @@ -247,14 +248,16 @@ const DataTable: FunctionComponent<DataTableProps> = ({ data, loading }) => {
},
]);

const { address } = useAccount();

const [tokenFilter, setTokenFilter] = useState<string>();
const [liquidityFilter, setLiquidityFilter] = useState<string>();
const [securityFilter, setSecurityFilter] = useState<string>();
const [airdropFilter, setAirdropFilter] = useState<string>();

const [showClaimModal, setShowClaimModal] = useState(false);
const [showSuccessModal, setShowSuccessModal] = useState(false);

const table = useReactTable({
data,
columns,
Expand Down Expand Up @@ -312,7 +315,9 @@ const DataTable: FunctionComponent<DataTableProps> = ({ data, loading }) => {
return (
<div className="w-full overflow-x-auto">
<div className="">
<div className={`flex w-100 lg:flex-row flex-col justify-between items-start`}>
<div
className={`flex w-100 lg:flex-row flex-col justify-between items-start`}
>
<div className={`flex w-100 flex-col gap-2`}>
<Typography type={TEXT_TYPE.H4} color="secondary">
Explore reward opportunities
Expand All @@ -322,8 +327,9 @@ const DataTable: FunctionComponent<DataTableProps> = ({ data, loading }) => {
</Typography>
</div>
<div
onClick={() => setShowClaimModal(true)}
className="flex flex-row items-center justify-evenly gap-4 bg-white rounded-xl modified-cursor-pointer h-min lg:mt-2 mt-8 px-6 py-2.5">
onClick={() => address && setShowClaimModal(true)}
className="flex flex-row items-center justify-evenly gap-4 bg-white rounded-xl modified-cursor-pointer h-min lg:mt-2 mt-8 px-6 py-2.5"
>
<AppIcon app="starknet" className="w-5 h-5" />
<Typography type={TEXT_TYPE.BUTTON_LARGE} color="background">
Claim all
Expand Down Expand Up @@ -414,13 +420,14 @@ const DataTable: FunctionComponent<DataTableProps> = ({ data, loading }) => {
return (
<TableHead
key={header.id}
onClick={header.column.getToggleSortingHandler()}>
onClick={header.column.getToggleSortingHandler()}
>
{header.isPlaceholder
? null
: flexRender(
header.column.columnDef.header,
header.getContext()
)}
header.column.columnDef.header,
header.getContext()
)}
</TableHead>
);
})}
Expand All @@ -435,9 +442,12 @@ const DataTable: FunctionComponent<DataTableProps> = ({ data, loading }) => {
data-state={row.getIsSelected() && "selected"}
onClick={() => {
window.open(
getRedirectLink(row.getValue("app"), row.getValue("action")),
getRedirectLink(
row.getValue("app"),
row.getValue("action")
),
"_blank"
)
);
}}
>
{row.getVisibleCells().map((cell) => (
Expand All @@ -463,7 +473,9 @@ const DataTable: FunctionComponent<DataTableProps> = ({ data, loading }) => {
onClick={() =>
table.getCanPreviousPage() ? table.previousPage() : null
}
style={table.getCanPreviousPage() ? {} : { cursor: 'not-allowed' }}
style={
table.getCanPreviousPage() ? {} : { cursor: "not-allowed" }
}
>
<CDNImage
src="/icons/chevronLeft.svg"
Expand All @@ -475,7 +487,7 @@ const DataTable: FunctionComponent<DataTableProps> = ({ data, loading }) => {
<div
className="flex modified-cursor-pointer"
onClick={() => (table.getCanNextPage() ? table.nextPage() : null)}
style={table.getCanNextPage() ? {} : { cursor: 'not-allowed' }}
style={table.getCanNextPage() ? {} : { cursor: "not-allowed" }}
>
<CDNImage
src="/icons/chevronRight.svg"
Expand Down

0 comments on commit 4c3863f

Please sign in to comment.