Skip to content

Commit

Permalink
chore: remove normalizer, update endpoint, adjust interfaces
Browse files Browse the repository at this point in the history
  • Loading branch information
thekidnamedkd committed Oct 25, 2024
1 parent e807edc commit e911a6c
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 40 deletions.
6 changes: 5 additions & 1 deletion src/components/daoCard/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,12 @@ import {toDisplayEns} from 'utils/library';
import {Dashboard} from 'utils/paths';
import {IDao} from 'services/aragon-backend/domain/dao';

interface IDaoWithOverride extends IDao {
overrideUrl?: string;
}

export interface IDaoCardProps {
dao: IDao;
dao: IDaoWithOverride;
}

export const DaoCard = (props: IDaoCardProps) => {
Expand Down
12 changes: 3 additions & 9 deletions src/containers/daoExplorer/daoExplorer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import {
quickFilters,
} from '../daoFilterModal/data';
import {Toggle, ToggleGroup} from '@aragon/ods';
import {normalizeFeaturedDao} from 'utils/normalizeFeaturedDao';
import {useFeaturedDaos} from 'hooks/useFeaturedDaos';

const followedDaoToDao = (dao: NavigationDao): IDao => ({
Expand Down Expand Up @@ -105,14 +104,9 @@ export const DaoExplorer = () => {
const {isLoading, hasNextPage, isFetchingNextPage, fetchNextPage} =
useFollowList ? followedDaosResult : newDaosResult;

const {data: featuredDaos, isLoading: isLoadingFeaturedDaos} =
const {data: featuredDaoList, isLoading: isLoadingFeaturedDaos} =
useFeaturedDaos();

// Normalize the featured DAOs data
const featuredDaoList: IDao[] = featuredDaos
? featuredDaos.map(normalizeFeaturedDao)
: [];

const totalDaos = useFollowList
? followedDaosResult.data?.pages[0].total ?? 0
: newDaosResult.data?.pages[0].total ?? 0;
Expand Down Expand Up @@ -140,7 +134,7 @@ export const DaoExplorer = () => {

const noFeaturedDaosFound =
isLoadingFeaturedDaos === false &&
!featuredDaos &&
!featuredDaoList &&
filters.quickFilter === 'featuredDaos';

const handleClearFilters = () => {
Expand Down Expand Up @@ -287,7 +281,7 @@ export const DaoExplorer = () => {
<CardsWrapper>
{filters.quickFilter === 'featuredDaos' ? (
<>
{featuredDaoList.map(
{featuredDaoList?.map(
(dao: IDao, index: React.Key | null | undefined) => (
<DaoCard key={index} dao={dao} />
)
Expand Down
8 changes: 4 additions & 4 deletions src/hooks/useFeaturedDaos.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
import {useQuery} from '@tanstack/react-query';
import {IFeaturedDao} from 'services/aragon-backend/domain/dao';
import {IDao} from 'services/aragon-backend/domain/dao';

const FEATURED_DAOS_URL =
'https://raw.githubusercontent.com/aragon/app/develop/src/assets/data/featured.json';
'https://raw.githubusercontent.com/aragon/app/refs/heads/develop/src/assets/data/featured-daos.json';

const fetchFeaturedDaos = async (): Promise<IFeaturedDao[]> => {
const fetchFeaturedDaos = async (): Promise<IDao[]> => {
const response = await fetch(FEATURED_DAOS_URL);

if (!response.ok) {
throw new Error('Failed to fetch featured DAOs');
}

const data: IFeaturedDao[] = await response.json();
const data: IDao[] = await response.json();
return data;
};

Expand Down
11 changes: 0 additions & 11 deletions src/services/aragon-backend/domain/dao.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,4 @@ export interface IDao {
createdAt: string;
pluginName: string;
stats?: IDaoStats;
overrideUrl?: string;
}

export interface IFeaturedDao {
overrideUrl: string | undefined;
daoName: string;
description: string;
avatarUrl: string;
blockchain: SupportedNetworks;
daoAddress: Address;
urlOverride?: string;
}
15 changes: 0 additions & 15 deletions src/utils/normalizeFeaturedDao.ts

This file was deleted.

0 comments on commit e911a6c

Please sign in to comment.