Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

move: opportunity files in modules/ & fix: every type error encountered in it #13

Merged
merged 4 commits into from
Jan 17, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/components/composite/Hero.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export type HeroProps = PropsWithChildren<{
breadcrumbs?: { name?: string; link: string; component?: ReactNode }[];
navigation?: { label: ReactNode; link: string };
description: ReactNode;
tags?: ReactNode[];
tags?: ReactNode[] | ReactNode;
sideDatas?: HeroInformations[];
tabs?: { label: ReactNode; link: string; key: string }[];
}>;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Button, Group, Icon, Select } from "dappkit";
import { useMemo } from "react";
import { DEFAULT_ITEMS_PER_PAGE } from "../../../constants/pagination";
import useSearchParamState from "../../../hooks/filtering/useSearchParamState";
import { DEFAULT_ITEMS_PER_PAGE } from "../../constants/pagination";
import useSearchParamState from "../../hooks/filtering/useSearchParamState";

export type PaginationProps = {
count?: number;
Expand Down
3 changes: 2 additions & 1 deletion src/components/element/Tag.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import type { Chain, Token } from "@merkl/api";
import type { Opportunity } from "@merkl/api";
import { useSearchParams } from "@remix-run/react";
import {
Button,
Expand All @@ -17,7 +18,6 @@ import {
import merklConfig from "../../config";
import { actions } from "../../config/actions";
import { statuses } from "../../config/status";
import type { Opportunity } from "../../modules/opportunity/opportunity.model";

export type TagTypes = {
chain: Opportunity["chain"];
Expand All @@ -34,6 +34,7 @@ export type TagType<T extends keyof TagTypes = keyof TagTypes> = {
};
export type TagProps<T extends keyof TagTypes> = {
type: T;
look?: PrimitiveTagProps["look"];
value: TagTypes[T];
filter?: boolean;
size?: PrimitiveTagProps["size"];
Expand Down
6 changes: 3 additions & 3 deletions src/components/element/campaign/CampaignLibrary.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import type { Chain } from "@merkl/api";
import type { Campaign, Chain } from "@merkl/api";
import type { Opportunity } from "@merkl/api";
import { Box, Button, Group, Icon, Text, Title } from "dappkit";
import moment from "moment";
import { useMemo, useState } from "react";
import type { OpportunityWithCampaigns } from "../../../modules/opportunity/opportunity.model";
import { CampaignTable } from "./CampaignTable";
import CampaignTableRow from "./CampaignTableRow";

export type CampaignLibraryProps = {
opportunity: OpportunityWithCampaigns;
opportunity: Opportunity & { campaigns: Campaign[] };
chain: Chain;
};

Expand Down
4 changes: 2 additions & 2 deletions src/components/element/campaign/CampaignTableRow.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import Tag from "@core/components/element/Tag";
import type { Campaign, Chain as ChainType } from "@merkl/api";
import type { Opportunity } from "@merkl/api";
import {
Box,
Button,
Expand All @@ -23,8 +25,6 @@ import { type ReactNode, useCallback, useMemo, useState } from "react";
import { v4 as uuidv4 } from "uuid";
import EtherScan from "../../../assets/images/etherscan.svg";
import useCampaign from "../../../hooks/resources/useCampaign";
import type { Opportunity } from "../../../modules/opportunity/opportunity.model";
import Tag from "../Tag";
import Token from "../token/Token";
import { CampaignRow } from "./CampaignTable";
import CampaignTooltipDates from "./CampaignTooltipDates";
Expand Down
2 changes: 1 addition & 1 deletion src/components/element/chain/ChainTableRow.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { TagTypes } from "@core/components/element/Tag";
import type { Chain } from "@merkl/api";
import { Link } from "@remix-run/react";
import { type BoxProps, Group, Icon, Title, mergeClass } from "dappkit";
import type { TagTypes } from "../Tag";
import { ChainRow } from "./ChainTable";

export type ChainTableRowProps = {
Expand Down
8 changes: 4 additions & 4 deletions src/components/element/functions/SearchBar.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import type { Opportunity } from "@merkl/api";
import { Form, useLocation } from "@remix-run/react";
import { Divider, Group, Icon, Icons, Input, Modal, Title, useShortcut } from "dappkit";
import { Divider, Group, Icon, Input, Modal, Title, useShortcut } from "dappkit";
import { Button } from "dappkit";
import { Scroll } from "dappkit";
import { type ReactNode, useEffect, useMemo, useState } from "react";
import useOpportunity from "../../../hooks/resources/useOpportunity";
import { type Results, type Searchable, useMerklSearch } from "../../../hooks/useMerklSearch";
import useOpportunityData from "../../../modules/opportunity/hooks/useOpportunityMetadata";

const titles: { [S in Searchable]: ReactNode } = {
chain: "Chains",
Expand All @@ -14,12 +14,12 @@ const titles: { [S in Searchable]: ReactNode } = {
};

function OpportunityResult({ opportunity }: { opportunity: Opportunity }) {
const { link, icons } = useOpportunity(opportunity);
const { link, Icons } = useOpportunityData(opportunity);

return (
<>
<Button to={link} look="soft">
<Icons>{icons}</Icons>
<Icons />
{opportunity.name}
<Icon remix="RiArrowRightLine" />
</Button>
Expand Down
2 changes: 1 addition & 1 deletion src/components/element/leaderboard/LeaderboardLibrary.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { useMemo } from "react";
import { v4 as uuidv4 } from "uuid";
import { DEFAULT_ITEMS_PER_PAGE } from "../../../constants/pagination";
import type { RewardService } from "../../../modules/reward/reward.service";
import Pagination from "../opportunity/Pagination";
import Pagination from "../Pagination";
import { LeaderboardTable, LeaderboardTableWithoutReason } from "./LeaderboardTable";
import LeaderboardTableRow from "./LeaderboardTableRow";

Expand Down
6 changes: 3 additions & 3 deletions src/components/element/participate/Participate.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import OpportunityShortCard from "@core/modules/opportunity/components/items/OpportunityShortCard";
import type { Opportunity } from "@merkl/api";
import { useLocation } from "@remix-run/react";
import { Button, Group, Icon, Input, PrimitiveTag, Text, Value } from "dappkit";
Expand All @@ -7,10 +8,9 @@ import { Fmt } from "dappkit";
import { Suspense, useEffect, useMemo, useState } from "react";
import { I18n } from "../../../I18n";
import merklConfig from "../../../config";
import useOpportunity from "../../../hooks/resources/useOpportunity";
import useParticipate from "../../../hooks/useParticipate";
import useOpportunityData from "../../../modules/opportunity/hooks/useOpportunityMetadata";
import { TokenService } from "../../../modules/token/token.service";
import OpportunityShortCard from "../opportunity/OpportunityShortCard";
import TokenSelect from "../token/TokenSelect";
import Interact from "./Interact.client";

Expand Down Expand Up @@ -42,7 +42,7 @@ export default function Participate({
loading,
} = useParticipate(opportunity.chainId, opportunity.protocol?.id, opportunity.identifier, tokenAddress);

const { link } = useOpportunity(opportunity);
const { link } = useOpportunityData(opportunity);
const location = useLocation();
const isOnOpportunityPage = location.pathname.includes("/opportunities/");
const [success, setSuccess] = useState(false);
Expand Down
2 changes: 1 addition & 1 deletion src/components/element/position/PositionLibrary.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { PositionT } from "@merkl/api/dist/src/modules/v4/liquidity";
import { Text, Title } from "dappkit";
import { useMemo } from "react";
import Pagination from "../opportunity/Pagination";
import Pagination from "../Pagination";
import { PositionTable } from "./PositionTable";
import PositionTableRow from "./PositionTableRow";

Expand Down
2 changes: 1 addition & 1 deletion src/components/element/position/PositionTableRow.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import OpportunityButton from "@core/modules/opportunity/components/OpportunityButton";
import type { PositionT } from "@merkl/api/dist/src/modules/v4/liquidity";
import { type Component, PrimitiveTag, Value, sizeScale } from "dappkit";
import { useMemo } from "react";
import { parseUnits } from "viem";
import merklConfig from "../../../config";
import OpportunityButton from "../opportunity/OpportunityButton";
import Token from "../token/Token";
import { PositionRow } from "./PositionTable";

Expand Down
2 changes: 1 addition & 1 deletion src/components/element/protocol/ProtocolLibrary.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { Protocol } from "@merkl/api";
import { Group } from "dappkit";
import { useMemo } from "react";
import Pagination from "../opportunity/Pagination";
import Pagination from "../Pagination";
import ProtocolCell from "./ProtocolCell";
import ProtocolFilters from "./ProtocolFilters";

Expand Down
2 changes: 1 addition & 1 deletion src/components/element/reinvest/ReinvestBanner.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import OpportunityCell from "@core/modules/opportunity/components/items/OpportunityCell";
import type { Opportunity } from "@merkl/api";
import { Collapsible, EventBlocker, Group, Icon, Space, Text, mergeClass } from "dappkit";
import { useEffect, useMemo, useState } from "react";
import { I18n } from "../../../I18n";
import OpportunityCell from "../../../components/element/opportunity/OpportunityCell";
import merklConfig from "../../../config";
import { OpportunityService } from "../../../modules/opportunity/opportunity.service";

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import Tag from "@core/components/element/Tag";
import type { Reward } from "@merkl/api";
import { Button, type Component, Icon, Space, Value, mergeClass } from "dappkit";
import { TransactionButton, type TransactionButtonProps } from "dappkit";
Expand All @@ -9,7 +10,6 @@ import { useMemo, useState } from "react";
import merklConfig from "../../../config";
import useReward from "../../../hooks/resources/useReward";
import { UserService } from "../../../modules/user/user.service";
import Tag from "../Tag";
import { ClaimRewardsChainRow } from "./ClaimRewardsChainTable";
import { ClaimRewardsTokenTable } from "./ClaimRewardsTokenTable";
import ClaimRewardsTokenTableRow from "./ClaimRewardsTokenTableRow";
Expand Down
4 changes: 2 additions & 2 deletions src/components/element/rewards/ClaimRewardsTokenTableRow.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import Tag from "@core/components/element/Tag";
import OpportunityButton from "@core/modules/opportunity/components/OpportunityButton";
import type { Reward } from "@merkl/api";
import { Checkbox, type Component, Divider, type GetSet, Group, Icon, Space } from "dappkit";
import { Collapsible } from "dappkit";
import { Fmt } from "dappkit";
import { useMemo, useState } from "react";
import Tag from "../Tag";
import OpportunityButton from "../opportunity/OpportunityButton";
import { ClaimRewardsTokenRow } from "./ClaimRewardsTokenTable";
import ClaimRewardsTokenTablePrice from "./ClaimRewardsTokenTablePrice";

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import OpportunityButton from "@core/modules/opportunity/components/OpportunityButton";
import type { Reward } from "@merkl/api";
import { type Component, Divider, type GetSet } from "dappkit";
import OpportunityButton from "../../opportunity/OpportunityButton";
import Token from "../../token/Token";
import { ClaimRewardsByOpportunityRow } from "./ClaimRewardsTableByOpportunity";

Expand Down
2 changes: 1 addition & 1 deletion src/components/element/token/TokenLibrary.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { Token } from "@merkl/api";
import { Group } from "dappkit";
import { useMemo } from "react";
import Pagination from "../opportunity/Pagination";
import Pagination from "../Pagination";
import TokenFilters from "./TokenFilters";
import { TokenTable } from "./TokenTable";
import TokenTableRow from "./TokenTableRow";
Expand Down
2 changes: 1 addition & 1 deletion src/components/element/token/TokenTableRow.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import type { TagTypes } from "@core/components/element/Tag";
import type { Token } from "@merkl/api";
import { Link } from "@remix-run/react";
import { Button, Group, Icon, Value } from "dappkit";
import type { BoxProps } from "dappkit";
import { Title } from "dappkit";
import { mergeClass } from "dappkit";
import merklConfig from "../../../config";
import type { TagTypes } from "../Tag";
import { TokenRow } from "./TokenTable";

export type TokenTableRowProps = {
Expand Down
2 changes: 1 addition & 1 deletion src/hooks/resources/useCampaign.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import type { Campaign as CampaignFromApi } from "@merkl/api";
import type { Opportunity } from "@merkl/api";
import { Bar, Icon } from "dappkit";
import { Group, Text, Value } from "dappkit";
import { Time } from "dappkit";
Expand All @@ -8,7 +9,6 @@ import { parseUnits } from "viem";
import type { RuleType } from "../../components/element/campaign/rules/Rule";
import Token from "../../components/element/token/Token";
import type { Campaign } from "../../modules/campaigns/campaign.model";
import type { Opportunity } from "../../modules/opportunity/opportunity.model";

export default function useCampaign(campaign: CampaignFromApi, opportunity?: Opportunity) {
if (!campaign)
Expand Down
Loading
Loading