Skip to content

Commit

Permalink
Remove grid, list, and shuffle buttons from View Ballot pag (#132)
Browse files Browse the repository at this point in the history
  • Loading branch information
electrone901 authored Oct 24, 2023
1 parent 77d9a10 commit bdbbca5
Showing 1 changed file with 4 additions and 26 deletions.
30 changes: 4 additions & 26 deletions packages/nextjs/components/ballot/AllBallots.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import useSWR from "swr";
import { useAccount } from "wagmi";
import * as solid from "@heroicons/react/20/solid";
import YourBallot from "~~/components/op/projects/YourBallot";
import ProjectsPageHeader from "~~/components/projects/ProjectsPageHeader";
import Sidebar from "~~/components/shared/Sidebar";
import { useBallot } from "~~/context/BallotContext";
import { fetcher } from "~~/utils/fetcher";
Expand All @@ -28,11 +27,8 @@ const AllBallots = () => {
const { state, dispatch } = useBallot();
const router = useRouter();
const [wallet, setWallet] = useState<boolean | false>(false);

const { isLoading: isFetching } = useSWR(`/api/projects?pageQuery=1&limit=12`, fetcher);
const [selectedCategory, setSelectedCategory] = useState("all");
const [ballotProjects, setBallotProjects] = useState<IBallotProject[]>([]);

const [filteredBallotProjects, setFilteredBallotProjects] = useState<IBallotProject[] | undefined>([]);
const [isLoading, setIsLoading] = useState(false);
const [loadingMessage, setLoadingMessage] = useState("");
Expand All @@ -59,7 +55,9 @@ const AllBallots = () => {
);
};
useEffect(() => {
setBallotProjects([...state.projects.map((project: any) => ({ ...project, isOpenModal: false }))]);
const _ballotProjects = [...state.projects.map((project: any) => ({ ...project, isOpenModal: false }))];
setBallotProjects(_ballotProjects);
setFilteredBallotProjects(_ballotProjects);
}, [state]);
const handleOpenBallotModal = (id: string) => {
setBallotProjects(prev => {
Expand All @@ -81,18 +79,6 @@ const AllBallots = () => {
setWallet(isDisconnected);
}, [isDisconnected]);

useEffect(() => {
function filterProjects() {
const _filteredProjects =
selectedCategory === "all"
? ballotProjects
: ballotProjects?.filter(project => project.category === selectedCategory);
setFilteredBallotProjects(_filteredProjects);
}
filterProjects();
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [selectedCategory, ballotProjects]);

if (isFetching) {
return (
<div className="flex mt-8 pt-8 justify-center">
Expand Down Expand Up @@ -130,15 +116,7 @@ const AllBallots = () => {
<div className="mx-auto px-12 mt-12 pb-12 grid grid-cols-1 lg:grid-cols-[350px,1fr] gap-8">
{!wallet ? <YourBallot /> : <Sidebar />}
<div>
<div className="container mx-auto">
<ProjectsPageHeader
titleHeader="My ballot"
display="grids"
onCategoryChange={setSelectedCategory}
projects={ballotProjects}
onShuffleProjects={setBallotProjects}
/>
</div>
<h1 className="font-bold text-2xl leading-8 pl-3 ">My ballot</h1>
{ballotProjects.length === 0 ? (
<div className="text-center mt-12">
<p>You have no projects in your ballot</p>
Expand Down

0 comments on commit bdbbca5

Please sign in to comment.