Skip to content

Commit

Permalink
feat: reorganize types (#70)
Browse files Browse the repository at this point in the history
* chore: moved pool types to global types

* chore: added new build/package entry point types
  • Loading branch information
hussedev authored Dec 1, 2024
1 parent acdc61d commit ac5beb7
Show file tree
Hide file tree
Showing 15 changed files with 47 additions and 40 deletions.
5 changes: 5 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@
"types": "./dist/mocks.d.ts",
"import": "./dist/mocks.js",
"require": "./dist/mocks.js"
},
"./types": {
"types": "./dist/types.d.ts",
"import": "./dist/types.js",
"require": "./dist/types.js"
}
},
"scripts": {
Expand Down
4 changes: 3 additions & 1 deletion src/components/Badges/PoolBadge/PoolBadge.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { Meta, StoryObj } from "@storybook/react";

import { PoolBadge, PoolStatus, PoolType } from "./PoolBadge";
import { PoolStatus, PoolType } from "@/types";

import { PoolBadge } from "./PoolBadge";

const meta: Meta<typeof PoolBadge> = {
title: "Components/PoolBadge",
Expand Down
13 changes: 1 addition & 12 deletions src/components/Badges/PoolBadge/PoolBadge.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,7 @@ import { match } from "ts-pattern";

import { cn } from "@/lib/utils";
import { Badge } from "@/primitives";

export enum PoolStatus {
PreRound = "PreRound",
RoundInProgress = "RoundInProgress",
ApplicationsInProgress = "ApplicationsInProgress",
FundingPending = "FundingPending",
}

export enum PoolType {
QuadraticFunding = "allov2.DonationVotingMerkleDistributionDirectTransferStrategy",
DirectGrants = "allov2.DirectGrantsSimpleStrategy",
}
import { PoolStatus, PoolType } from "@/types";

const PoolBadgeVariants = tv({
variants: {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { Meta, StoryObj } from "@storybook/react";

import { PoolCardProps, PoolCardQueryProps } from "@/components";
import { PoolStatus, PoolType } from "@/components/Badges";
import { createQueryState } from "@/lib";
import { PoolStatus, PoolType } from "@/types";

import { PoolCard } from "./PoolCard";

Expand Down
6 changes: 3 additions & 3 deletions src/components/pool/components/PoolCard/PoolCard.tsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import { UseQueryResult } from "@tanstack/react-query";
import { match, P } from "ts-pattern";

import { OnClickProps, PoolData } from "@/types";
import { Skeleton } from "@/ui-shadcn/skeleton";

import { onClickProps, PoolData } from "../../types";
import { PoolDataCard } from "./PoolDataCard";

export interface PoolCardQueryProps extends onClickProps {
export interface PoolCardQueryProps extends OnClickProps {
queryResult: UseQueryResult<PoolData, Error>;
}

export interface PoolCardProps extends PoolData, onClickProps {}
export interface PoolCardProps extends PoolData, OnClickProps {}

export function PoolCard(props: PoolCardProps | PoolCardQueryProps) {
return match(props)
Expand Down
6 changes: 3 additions & 3 deletions src/components/pool/components/PoolCard/PoolDataCard.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { IconLabel, PoolBadge } from "@/components";
import { getChainInfo } from "@/lib";
import { modularRedirect } from "@/lib/utils";

import { onClickProps, PoolData } from "../../types";
import { PoolData } from "@/types";
import { OnClickProps } from "@/types";

export interface PoolDataCardProps {
data: PoolData;
redirectProps?: onClickProps;
redirectProps?: OnClickProps;
}

export function PoolDataCard({ data, redirectProps }: PoolDataCardProps) {
Expand Down
3 changes: 2 additions & 1 deletion src/components/pool/components/PoolSummary/PoolSummary.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { tv } from "tailwind-variants";

import { IconLabel, PoolBadge, PoolStatus, PoolType } from "@/components";
import { IconLabel, PoolBadge } from "@/components";
import { getChainInfo } from "@/lib";
import { cn } from "@/lib/utils";
import { Breadcrumb, Button, Icon, IconType } from "@/primitives";
import { PoolStatus, PoolType } from "@/types";

const variants = tv({
variants: {
Expand Down
1 change: 0 additions & 1 deletion src/components/pool/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
export * from "./components";
export * from "./types";
1 change: 0 additions & 1 deletion src/components/pool/types/index.ts

This file was deleted.

16 changes: 0 additions & 16 deletions src/components/pool/types/types.ts

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Address } from "viem";

import { PoolType } from "@/components/Badges";
import { useCheckerContext } from "@/features/checker/store/hooks/useCheckerContext";
import { PoolType } from "@/types";

import { generatePoolUUID } from "~checker/utils/generatePoolUUID";
import { categorizeProjectReviews } from "~checker/utils/mapApplicationsForOverviewPage";
Expand Down
2 changes: 2 additions & 0 deletions src/types/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export * from "./onClickProps";
export * from "./pool";
4 changes: 4 additions & 0 deletions src/types/onClickProps.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export interface OnClickProps {
redirectLink?: string;
redirect?: boolean;
}
21 changes: 21 additions & 0 deletions src/types/pool.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
export enum PoolStatus {
PreRound = "PreRound",
RoundInProgress = "RoundInProgress",
ApplicationsInProgress = "ApplicationsInProgress",
FundingPending = "FundingPending",
}

export enum PoolType {
QuadraticFunding = "allov2.DonationVotingMerkleDistributionDirectTransferStrategy",
DirectGrants = "allov2.DirectGrantsSimpleStrategy",
}

export interface PoolData {
roundName: string;
roundId: string;
chainId: number;
poolType: PoolType;
startDate: Date;
endDate: Date;
poolStatus: PoolStatus;
}
1 change: 1 addition & 0 deletions vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export default defineConfig({
lib: resolve(__dirname, "./src/lib/index.ts"),
mainAll: resolve(__dirname, "./src/mainAll.ts"),
mocks: resolve(__dirname, "./src/mocks/handlers.ts"),
types: resolve(__dirname, "./src/types/index.ts"),
},
name: "gitcoin-ui",
fileName: (format: any, filename: any) => `${filename}.js`,
Expand Down

0 comments on commit ac5beb7

Please sign in to comment.