From d121c46d7ae8de720d11e29cf462e10e31d21d97 Mon Sep 17 00:00:00 2001 From: bakansm Date: Sat, 13 Jan 2024 17:08:32 +0700 Subject: [PATCH 1/2] feat: get value search input --- .../potlock/widget/Components/ListSection.jsx | 23 ++++++++++--------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/apps/potlock/widget/Components/ListSection.jsx b/apps/potlock/widget/Components/ListSection.jsx index 3dd23597..e7762781 100644 --- a/apps/potlock/widget/Components/ListSection.jsx +++ b/apps/potlock/widget/Components/ListSection.jsx @@ -11,12 +11,10 @@ const donationContractId = "donate.potlock.near"; const [totalProjects, setTotalProjects] = useState(props.items); const [displayProject, setDisplayProject] = useState([]); const [lastNumberOfProject, setLastNumberOfProject] = useState(0); -const [filterType, setFilterType] = useState(null); +const [searchTerm, setSearchTerm] = useState(null); if (!totalProjects) return "loading"; -console.log(totalProjects); - const loadProjects = () => { setLastNumberOfProject(lastNumberOfProject + 9); setDisplayProject( @@ -121,6 +119,9 @@ const sortOldToNew = (projects) => { useEffect(() => { const newTotalProjects = []; + for (const project of totalProjects) { + console.log(Social.getr(`${project.id}/profile`)); + } const promises = totalProjects.map((project) => { return Near.asyncView(donationContractId, "get_donations_for_recipient", { recipient_id: project.id, @@ -129,12 +130,12 @@ useEffect(() => { newTotalProjects.push({ ...project, total }); }); }); - Promise.all(promises).then((allProjects) => { + Promise.all(promises).then(() => { setTotalProjects(newTotalProjects); }); }, []); -useEffect(() => { +const handleFilterChange = (filterType) => { switch (filterType) { case "Newest to Oldest": sortNewToOld(totalProjects); @@ -149,7 +150,7 @@ useEffect(() => { sortLowestToHighest(totalProjects); break; } -}, [filterType]); +}; const Container = styled.div` display: flex; @@ -232,12 +233,12 @@ return ( sortNewToOld(project), - sortOldToNew: (project) => sortOldToNew(project), projectLength: totalProjects.length, - filterList: filterList, - setFilterType: (filter) => { - setFilterType(filter); + setSearchTerm: (value) => { + setSearchTerm(value); + }, + handleFilterChange: (filter) => { + handleFilterChange(filter); }, }} /> From bdf66e79ea0ff38ce82dee226c0c1143cf172e6d Mon Sep 17 00:00:00 2001 From: bakansm Date: Sat, 13 Jan 2024 23:22:12 +0700 Subject: [PATCH 2/2] feat: add on Bottom at the end of project list --- apps/potlock/widget/Components/ListSection.jsx | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/apps/potlock/widget/Components/ListSection.jsx b/apps/potlock/widget/Components/ListSection.jsx index e7762781..a0c8aa3a 100644 --- a/apps/potlock/widget/Components/ListSection.jsx +++ b/apps/potlock/widget/Components/ListSection.jsx @@ -224,6 +224,14 @@ const Tag = styled.div` } `; +const OnBottom = styled.div` + width: 100%; + display: flex; + align-items: center; + justify-content: center; + padding: 20px 0; +`; + return (
@@ -252,5 +260,6 @@ return ( {displayProject} + {lastNumberOfProject >= totalProjects.length && On bottom} );