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

check allocation based on all projects #387

Open
wants to merge 7 commits into
base: develop
Choose a base branch
from
Open
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
12 changes: 10 additions & 2 deletions src/components/ProjectCard/ProjectHoverCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@ import { useFetchAllRound } from '@/hooks/useFetchAllRound';
import { SupportButton } from './SupportButton';
import { useFetchMostRecentEndRound } from '../ProjectDetail/usefetchMostRecentEndRound';
import { Button, ButtonColor } from '../Button';
import { isAllocationDone } from '@/config/configuration';
import { IconTokenSchedule } from '../Icons/IconTokenSchedule';
import { useFetchAllProjects } from '@/hooks/useFetchAllProjects';
import { useCheckProjectPriceStatus } from '@/hooks/useCheckProjectPriceStatus ';

interface ProjectCardProps extends React.HTMLAttributes<HTMLDivElement> {
project: IProject;
Expand All @@ -39,9 +40,17 @@ export const ProjectHoverCard: FC<ProjectCardProps> = ({
const router = useRouter();
const { data: POLPrice } = useFetchTokenPrice();
const { data: activeRoundDetails } = useFetchActiveRoundDetails();
const { data: allProjects, isLoading } = useFetchAllProjects();

const isQaccRoundEnded = useFetchMostRecentEndRound(activeRoundDetails);
const { data: allRounds } = useFetchAllRound();

const { data: projectPriceUpdated } = useCheckProjectPriceStatus(
allProjects,
allRounds,
);

const isAllocationDone = !!projectPriceUpdated;
useEffect(() => {
console.log(
project?.title,
Expand Down Expand Up @@ -94,7 +103,6 @@ export const ProjectHoverCard: FC<ProjectCardProps> = ({
contractAddress: project.abc?.fundingManagerAddress || '',
});

const { data: allRounds } = useFetchAllRound();
const tokenPriceRangeStatus = useTokenPriceRangeStatus({
project,
allRounds,
Expand Down
13 changes: 12 additions & 1 deletion src/components/QaccRoundEndBanner.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,20 @@
import React from 'react';
import { isAllocationDone } from '@/config/configuration';
import { useFetchAllProjects } from '@/hooks/useFetchAllProjects';
import { useFetchAllRound } from '@/hooks/useFetchAllRound';
import QaccRoundStats from './QaccRoundStats';
import { useCheckProjectPriceStatus } from '@/hooks/useCheckProjectPriceStatus ';

interface QaccRoundEndBannerProps {}
const QaccRoundEndBanner: React.FC<QaccRoundEndBannerProps> = ({}) => {
const { data: allProjects } = useFetchAllProjects();
const { data: allRounds } = useFetchAllRound();

const { data: projectPriceUpdated } = useCheckProjectPriceStatus(
allProjects,
allRounds,
);

const isAllocationDone = !!projectPriceUpdated;
return (
<div className='flex flex-col p-9 gap-9 mx-auto w-[80%] bg-[#F6F3FF] rounded-xl justify-center z-40 mt-12'>
<div className='flex flex-col gap-2 justify-center font-sans'>
Expand Down
24 changes: 24 additions & 0 deletions src/hooks/useCheckProjectPriceStatus .ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { useQuery } from '@tanstack/react-query';
import { getTokenPriceRangeStatus } from '@/services/tokenPrice.service';

export const useCheckProjectPriceStatus = (
allProjects: any,
allRounds: any,
) => {
return useQuery({
enabled: !!allProjects && !!allRounds,
queryKey: ['projectPriceStatus'],
queryFn: async () => {
for (const project of allProjects.projects) {
const { isPriceUpToDate } = await getTokenPriceRangeStatus({
project,
allRounds,
});
if (!isPriceUpToDate) {
return false;
}
}
return true;
},
});
};
2 changes: 1 addition & 1 deletion src/services/tokenPrice.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ const getBondingCurveSwapsQuery = `
}
`;

async function getTokenPriceRangeStatus({
export async function getTokenPriceRangeStatus({
allRounds,
project,
}: UseTokenPriceRangeStatusProps): Promise<TokenPriceRangeStatusResult> {
Expand Down