Skip to content

Commit

Permalink
Merge pull request #91 from GenaDrop/stagging
Browse files Browse the repository at this point in the history
Stagging to main
  • Loading branch information
Ebube111 authored Jan 22, 2024
2 parents f9f2dfa + b5256d0 commit 4df5178
Show file tree
Hide file tree
Showing 24 changed files with 900 additions and 400 deletions.
2 changes: 2 additions & 0 deletions apps/BosGenaDrop/widget/CPlanet/DAO/Index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,8 @@ policy?.roles?.length &&
members = [...new Set(members)];
// --

if(!policy) return <div><h2>Not a Valid DAO</h2></div>

function makeAccountIdShorter(accountId) {
if (accountId.length > shortenLength) {
return accountId.slice(0, shortenLength) + "...";
Expand Down
32 changes: 30 additions & 2 deletions apps/BosGenaDrop/widget/CPlanet/DropsFund/Admin/Index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,20 @@ const Root = styled.div`
margin-top: 30px;
}
}
.error {
color: red;
font-size: 14px;
}
`

const [contestName, setName] = useState("")
const [description, setDescription] = useState("")
const [daoId, setDaoId] = useState("")
const [price, setPrice] = useState(0)
const [dateError, setDateError] = useState(false)
const [places, setPlaces] = useState(0)
const [daoIdError, setDaoIdError] = useState(false)
const [minArtVote, setMinArtVote] = useState(0)
const [submissionStart, setSubmissionStart] = useState("")
const [submissionEnd, setSubmissionEnd] = useState("")
Expand All @@ -64,13 +71,32 @@ function convertToTimestamp(dateString) {
return unixTimestamp;
}

const policy = Near.view(daoId.trim(), "get_policy");

const handleSubmit = () => {
Near.call("fund-vf.genadrop.near",
if(!policy) return setDaoIdError(true)
const submissionStartTimeStamp = convertToTimestamp(submissionStart);
const submissionEndTimeStamp = convertToTimestamp(submissionEnd);
const votingStartTimeStamp = convertToTimestamp(votingStart);
const votingEndTimeStamp = convertToTimestamp(votingEnd);

// Validation checks
if (
!submissionStart || !submissionEnd || !votingStart || !votingEnd ||
submissionStartTimeStamp >= submissionEndTimeStamp ||
votingStartTimeStamp >= votingEndTimeStamp ||
submissionEndTimeStamp >= votingStartTimeStamp
) {
return setDateError(true);
}


Near.call("fund-beta.genadrop.near",
"create_contest",
{
title: contestName,
description,
dao_id: daoId,
dao_id: daoId.trim(),
logo_url: "https://picsum.photos/200/300.jpg",
submission_start_time: convertToTimestamp(submissionStart),
submission_end_time: convertToTimestamp(submissionEnd),
Expand Down Expand Up @@ -103,6 +129,7 @@ return (
<div className="field">
<label>DAO Account ID</label>
<input value={daoId} onChange={e => setDaoId(e.target.value)} required />
{daoIdError && <span className="error">Invalid DAO ID</span>}
</div>
<div className="field">
<label>Price</label>
Expand Down Expand Up @@ -137,6 +164,7 @@ return (
<input value={votingEnd} onChange={e => setVotingEnd(e.target.value)} type="datetime-local" required />
</div>
</div>
{dateError && <span className="error">Invalid Date: Note that Voting time cannot be less than submission time and Start time cannot be less than End time.</span>}
<div className="button">
<button onClick={handleSubmit}>Create</button>
</div>
Expand Down
2 changes: 1 addition & 1 deletion apps/BosGenaDrop/widget/CPlanet/DropsFund/Admin/Payout.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ const [contestId, setContestId] = useState(0)
const [proposalId, setProposalId] = useState(0)

const handleSubmit = () => {
Near.call("fund-vf.genadrop.near",
Near.call("fund-beta.genadrop.near",
"set_payout_proposal_id",
{
contest_id: Number(contestId),
Expand Down
Loading

0 comments on commit 4df5178

Please sign in to comment.