Skip to content

Commit

Permalink
Merge pull request #4 from Giveth/add-OP-filters
Browse files Browse the repository at this point in the history
add onlyVerified and onlyListed to filters
  • Loading branch information
RamRamez authored Oct 19, 2023
2 parents a9e1f26 + a8f9f13 commit 158db98
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 6 deletions.
24 changes: 19 additions & 5 deletions src/components/views/home/ProjectsCount.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,15 @@ const ProjectsCount = () => {
const [fromDate, setFromDate] = useState(firstOfGiveth());
const [toDate, setToDate] = useState(firstOfNextMonth());
const [includesOptimism, setIncludesOptimism] = useState(false);
const [onlyVerified, setOnlyVerified] = useState(false);
const [onlyListed, setOnlyListed] = useState(false);

const { projectsCount, loading } = useProjectsCount(
fromDate,
toDate,
includesOptimism,
onlyVerified,
onlyListed,
);

const { total, totalPerMonthAndYear } = projectsCount || {};
Expand Down Expand Up @@ -85,14 +90,23 @@ const ProjectsCount = () => {
direction={'top'}
>
<TooltipBody>
When this option is selected, only projects that are
verified and have the receiving address as OP will
be displayed. When it's not selected, projects from
any network, including those that aren't verified,
will be shown.
When this option is selected, projects that doesn't
have OP as receiving address won't be displayed.
</TooltipBody>
</IconWithTooltip>
</Flex>
<br />
<CheckBox
checked={onlyVerified}
onChange={setOnlyVerified}
label='Show only verified projects'
/>
<br />
<CheckBox
checked={onlyListed}
onChange={setOnlyListed}
label='Show only listed projects'
/>
</Col>
<Col md={1} />
<Col md={2}>
Expand Down
4 changes: 4 additions & 0 deletions src/gql/gqlProjects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,15 @@ export const fetchProjectsCount = `
$fromDate: String
$toDate: String
$includesOptimism: Boolean
$onlyVerified: Boolean
$onlyListed: Boolean
) {
projectsPerDate(
fromDate: $fromDate
toDate: $toDate
includesOptimism: $includesOptimism
onlyVerified: $onlyVerified
onlyListed: $onlyListed
) {
total
totalPerMonthAndYear {
Expand Down
6 changes: 5 additions & 1 deletion src/hooks/useProjectsCount.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ const useProjectsCount = (
fromDate: Date,
toDate: Date,
includesOptimism?: boolean,
onlyVerified?: boolean,
onlyListed?: boolean,
) => {
const [projectsCount, setProjectsCount] = useState<IResFormat>();
const [loading, setLoading] = useState<boolean>(true);
Expand All @@ -18,14 +20,16 @@ const useProjectsCount = (
fromDate: formatDateToISO(fromDate),
toDate: formatDateToISO(toDate),
includesOptimism: includesOptimism || false,
onlyVerified: onlyVerified || false,
onlyListed: onlyListed || false,
};
backendGQLRequest(fetchProjectsCount, variables)
.then((res: IFetchProjectsCount) => {
setProjectsCount(res.data.projectsPerDate);
})
.catch(showToastError)
.finally(() => setLoading(false));
}, [fromDate, toDate, includesOptimism]);
}, [fromDate, toDate, includesOptimism, onlyListed, onlyVerified]);

return { projectsCount, loading };
};
Expand Down

1 comment on commit 158db98

@vercel
Copy link

@vercel vercel bot commented on 158db98 Oct 19, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.