Skip to content

Commit

Permalink
Merge pull request #36 from GenaDrop/fix/contest
Browse files Browse the repository at this point in the history
fix: all contests display
  • Loading branch information
Ebube111 authored Dec 18, 2023
2 parents b1993e5 + 60792ee commit 5985da4
Show file tree
Hide file tree
Showing 4 changed files with 76 additions and 16 deletions.
44 changes: 37 additions & 7 deletions apps/BosGenaDrop/widget/CPlanet/DropsFund/Contest/Index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,19 @@ const Search = styled.div`
border: 1px solid #efefef;
height: 48px;
background: #fff;
input {
border: none;
}
input:focus: {
`;

const Input = styled.input`
&&& {
padding: 8px;
font-size: 16px;
border: none;
flex: 1;
&:focus {
outline: none;
border: none;
}
}
`;

const Filter = styled.div`
Expand Down Expand Up @@ -123,6 +129,20 @@ const Cards = styled.div`
background: white;
`;

const NoContest = styled.div`
display: flex;
align-items: center;
justify-content: center;
width: 100%;
padding: 24px 32px;
p {
color: #d0d0d0;
font-size: 24px;
font-weight: 600;
}
`

const isFutureTimestamp = (timestamp) => {
const currentTimestamp = Math.floor(Date.now() / 1000); // Convert current time to seconds

Expand Down Expand Up @@ -151,12 +171,20 @@ useEffect(() => {
)
);
break;
case "PAID":
setContest([]);
break;
case "PAST":
setContest(
fetchedContests?.filter(
(data) => !isFutureTimestamp(data[1]?.voting_end_time)
)
);
break;
default:
// Default case: handle the default state here
setContest(fetchedContests);
break;
}
}, [contest, activeTab]);

Expand All @@ -168,7 +196,7 @@ return (
</div>
<div className="searchContainer">
<Search>
<input />
<Input />
{searchSvg}
</Search>
<Filter>
Expand Down Expand Up @@ -200,7 +228,7 @@ return (
</Tab>
</Tabs>
<Cards>
{contest?.map((data, index) => (
{contest?.length > 0 ? contest?.map((data, index) => (
<Widget
src="bos.genadrop.near/widget/CPlanet.DropsFund.Explore.Card"
key={index}
Expand All @@ -214,7 +242,9 @@ return (
isGateway: props.isGateway
}}
/>
))}
)): <NoContest>
<p>There are no {activeTab} Contest available</p>
</NoContest>}
</Cards>
</ExploreRoot>
</ExploreContainer>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ const Username = styled.div`
font-family: Helvetica Neue;
font-size: 16px;
font-style: normal;
font-weight: 400;
font-weight: 400;
line-height: normal;
text-transform: uppercase;
margin-bottom: 20px;
Expand Down
44 changes: 37 additions & 7 deletions build/BosGenaDrop/src/CPlanet/DropsFund/Contest/Index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,19 @@ const Search = styled.div`
border: 1px solid #efefef;
height: 48px;
background: #fff;
input {
border: none;
}
input:focus: {
`;

const Input = styled.input`
&&& {
padding: 8px;
font-size: 16px;
border: none;
flex: 1;
&:focus {
outline: none;
border: none;
}
}
`;

const Filter = styled.div`
Expand Down Expand Up @@ -123,6 +129,20 @@ const Cards = styled.div`
background: white;
`;

const NoContest = styled.div`
display: flex;
align-items: center;
justify-content: center;
width: 100%;
padding: 24px 32px;
p {
color: #d0d0d0;
font-size: 24px;
font-weight: 600;
}
`

const isFutureTimestamp = (timestamp) => {
const currentTimestamp = Math.floor(Date.now() / 1000); // Convert current time to seconds

Expand Down Expand Up @@ -151,12 +171,20 @@ useEffect(() => {
)
);
break;
case "PAID":
setContest([]);
break;
case "PAST":
setContest(
fetchedContests?.filter(
(data) => !isFutureTimestamp(data[1]?.voting_end_time)
)
);
break;
default:
// Default case: handle the default state here
setContest(fetchedContests);
break;
}
}, [contest, activeTab]);

Expand All @@ -168,7 +196,7 @@ return (
</div>
<div className="searchContainer">
<Search>
<input />
<Input />
{searchSvg}
</Search>
<Filter>
Expand Down Expand Up @@ -200,7 +228,7 @@ return (
</Tab>
</Tabs>
<Cards>
{contest?.map((data, index) => (
{contest?.length > 0 ? contest?.map((data, index) => (
<Widget
src="bos.genadrop.near/widget/CPlanet.DropsFund.Explore.Card"
key={index}
Expand All @@ -214,7 +242,9 @@ return (
isGateway: props.isGateway
}}
/>
))}
)): <NoContest>
<p>There are no {activeTab} Contest available</p>
</NoContest>}
</Cards>
</ExploreRoot>
</ExploreContainer>
Expand Down
2 changes: 1 addition & 1 deletion build/BosGenaDrop/src/CPlanet/DropsFund/Contest/Single.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ const Username = styled.div`
font-family: Helvetica Neue;
font-size: 16px;
font-style: normal;
font-weight: 400;
font-weight: 400;
line-height: normal;
text-transform: uppercase;
margin-bottom: 20px;
Expand Down

0 comments on commit 5985da4

Please sign in to comment.