Skip to content

Commit

Permalink
update prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
BigDealCompany committed May 25, 2024
1 parent 0f6b82d commit e217cb6
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 18 deletions.
2 changes: 0 additions & 2 deletions src/constants/tokens.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ let url = '';

// Immediately invoke the setBackendUrl function


export const fetchTokens = async () => {
const response = await fetch(`${url}/tokens/all?chainId=11111`, {
method: 'GET',
Expand All @@ -45,7 +44,6 @@ export const fetchTokens = async () => {
}
};


let isFetchTokensInitialized = false; // Flag to track whether fetchTokens has been called

const initializeFetchTokens = async () => {
Expand Down
29 changes: 13 additions & 16 deletions src/pages/Markets/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ const tokenPairsAreEqual = (tokens1: [Token, Token], tokens2?: [Token, Token]):
}
const [token10, token11] = tokens1;
const [token20, token21] = tokens2;


if (!token10.equals(token20) && !token10.equals(token21)) return false;
if (!token11.equals(token20) && !token11.equals(token21)) return false;
Expand All @@ -53,8 +52,8 @@ export default function Markets({
const { t } = useTranslation();
const theme = useContext(ThemeContext);

const [totalValueLocked, setTotalValueLocked] = useState('');
const [results, setResults] = useState<any[]>([]);
const [totalValueLocked, setTotalValueLocked] = useState('');
const [results, setResults] = useState<any[]>([]);
const fetchTotalValueLocked = async () => {
const response = await (
await fetch(`${BACKEND_URL}/markets/totalLocked?chainId=${chainId && ChainId.MAINNET}`)
Expand All @@ -80,7 +79,6 @@ export default function Markets({

const jsonData = await response.json();
return jsonData;

} catch (error) {
console.error(error);
// Handle the error if needed
Expand All @@ -98,17 +96,17 @@ export default function Markets({
results.push(data);
}
}
const resultsMarkets = results.flatMap(result => {

const resultsMarkets = results.flatMap((result) => {
return result.data?.markets || [];
});
setResults(resultsMarkets);

setResults(resultsMarkets);
}

useEffect(() => {
fetchDataFromAllPages();
}, [])
}, []);

const isMobile = window.innerWidth <= MEDIA_WIDTHS.upToMedium;
const { chainId } = useActiveWeb3React();
Expand All @@ -135,19 +133,18 @@ export default function Markets({

const marketList = useMemo(() => {
let combinedMarkets = markets;

if (searchQuery) {
// Check if markets is not null before spreading its values
combinedMarkets = [...markets, ...alldata];
}

const itemsPerPage = 10;
const currentPage = page ? parseInt(page, 10) : 1;

const currentPage = page ? parseInt(page, 10) : 1;
const startIndex = (currentPage - 1) * itemsPerPage;
const endIndex = startIndex + itemsPerPage;


const filteredMarkets = combinedMarkets.filter((info: MarketInfo) => {
return (
info.pair.token0.symbol?.toLowerCase().includes(searchQuery) ||
Expand All @@ -156,8 +153,8 @@ export default function Markets({
info.pair.token1.name?.toLowerCase().includes(searchQuery)
);
});
console.log(startIndex, " ", endIndex)
if(searchQuery){
console.log(startIndex, ' ', endIndex);
if (searchQuery) {
return filteredMarkets.slice(startIndex, endIndex);
}
return filteredMarkets;
Expand Down

0 comments on commit e217cb6

Please sign in to comment.