Skip to content

Commit

Permalink
bug fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Megha-Dev-19 committed Mar 4, 2024
1 parent aef2252 commit 68c3070
Show file tree
Hide file tree
Showing 5 changed files with 92 additions and 52 deletions.
3 changes: 3 additions & 0 deletions src/devhub/entity/proposal/AccountInput.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ return (
value: value,
onChange: (e) => {
onUpdate(e.target.value);
if (e.target.value.includes(".near")) {
return;
}
setAutoComplete(true);
},
skipPaddingGap: true,
Expand Down
2 changes: 1 addition & 1 deletion src/devhub/entity/proposal/CategoryTag.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ const Container = styled.div`
background-color: #7c66dc;
}
.yellow-bg {
background-color: #f2f0ce;
background-color: #dcc266;
}
.cyan-bg {
background-color: #0daebb;
Expand Down
74 changes: 39 additions & 35 deletions src/devhub/entity/proposal/Editor.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -234,42 +234,42 @@ const memoizedDraftData = useMemo(
);

useEffect(() => {
let data = editProposalData || JSON.parse(draftProposalData);
let snapshot = data.snapshot;
if (allowDraft && data) {
if (timestamp) {
snapshot =
data.snapshot_history.find((item) => item.timestamp === timestamp) ??
data.snapshot;
if (allowDraft) {
let data = editProposalData || JSON.parse(draftProposalData);
let snapshot = data.snapshot;
if (data) {
if (timestamp) {
snapshot =
data.snapshot_history.find((item) => item.timestamp === timestamp) ??
data.snapshot;
}
if (
draftProposalData &&
editProposalData &&
editProposalData.id === JSON.parse(draftProposalData).id
) {
snapshot = {
...editProposalData.snapshot,
...JSON.parse(draftProposalData).snapshot,
};
}
setCategory(snapshot.category);
setTitle(snapshot.name);
setSummary(snapshot.summary);
setDescription(snapshot.description);
setReceiverAccount(snapshot.receiver_account);
setRequestedSponsor(snapshot.requested_sponsor);
setRequestedSponsorshipAmount(snapshot.requested_sponsorship_usd_amount);
setSupervisor(snapshot.supervisor);

const token = tokensOptions.find(
(item) => item.value === snapshot.requested_sponsorship_paid_in_currency
);
setRequestedSponsorshipToken(token ?? tokensOptions);
}
if (
draftProposalData &&
editProposalData &&
editProposalData.id === JSON.parse(draftProposalData).id
) {
snapshot = {
...editProposalData.snapshot,
...JSON.parse(draftProposalData).snapshot,
};
}
setCategory(snapshot.category);
setTitle(snapshot.name);
setSummary(snapshot.summary);
setDescription(snapshot.description);
setReceiverAccount(snapshot.receiver_account);
setRequestedSponsor(snapshot.requested_sponsor);
setRequestedSponsorshipAmount(snapshot.requested_sponsorship_usd_amount);
setSupervisor(snapshot.supervisor);

const token = tokensOptions.find(
(item) =>
JSON.stringify(item.value) ===
JSON.stringify(snapshot.requested_sponsorship_paid_in_currency)
);
setRequestedSponsorshipToken(token);
setLoading(false);
}
setLoading(false);
}, [editProposalData, draftProposalData]);
}, [editProposalData, draftProposalData, allowDraft]);

useEffect(() => {
if (draftProposalData) {
Expand Down Expand Up @@ -552,7 +552,11 @@ const onSubmit = ({ isDraft, isCancel }) => {
supervisor: supervisor || null,
requested_sponsor: requestedSponsor,
timeline: isCancel
? { status: "CANCELLED" }
? {
status: "CANCELLED",
sponsor_requested_review: false,
reviewer_completed_attestation: false,
}
: isDraft
? { status: "DRAFT" }
: {
Expand Down
8 changes: 4 additions & 4 deletions src/devhub/entity/proposal/History.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,9 @@ const history = (
<a
class="dropdown-item"
href={href({
widgetSrc:
"${REPL_DEVHUB}/widget/devhub.entity.proposal.Proposal",
widgetSrc: "${REPL_DEVHUB}/widget",
params: {
page: "proposal",
id: proposalId,
timestamp: item.timestamp,
compareTimestamp: null,
Expand Down Expand Up @@ -102,9 +102,9 @@ const history = (
<a
class="dropdown-item"
href={href({
widgetSrc:
"${REPL_DEVHUB}/widget/devhub.entity.proposal.Proposal",
widgetSrc: "${REPL_DEVHUB}/widget/app",
params: {
page: "proposal",
id: proposalId,
timestamp: currentTimestamp,
compareTimestamp: item.timestamp,
Expand Down
57 changes: 45 additions & 12 deletions src/devhub/entity/proposal/Proposal.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ const { href } = VM.require("${REPL_DEVHUB}/widget/core.lib.url") || {
const { readableDate } = VM.require(
"${REPL_DEVHUB}/widget/core.lib.common"
) || { readableDate: () => {} };
const { getDepositAmountForWriteAccess } = VM.require(
"${REPL_DEVHUB}/widget/core.lib.common"
);
getDepositAmountForWriteAccess || (getDepositAmountForWriteAccess = () => {});

const accountId = context.accountId;
/*
Expand Down Expand Up @@ -217,7 +221,16 @@ const item = {
path: `${REPL_DEVHUB_CONTRACT}/post/main`,
blockHeight,
};
const proposalURL = `${REPL_DEVHUB}/widget/devhub.entity.proposal.Proposal?id=${proposal.id}&timestamp=${snapshot.timestamp}`;
const proposalURL = `https://near.org/${REPL_DEVHUB}/widget/app?page=proposal&id=${proposal.id}&timestamp=${snapshot.timestamp}`;

let grantNotify = Near.view(
"${REPL_SOCIAL_CONTRACT}",
"is_write_permission_granted",
{
predecessor_id: "${REPL_DEVHUB_CONTRACT}",
key: context.accountId + "/index/notify",
}
);

const KycVerificationStatus = () => {
const isVerified = true;
Expand Down Expand Up @@ -363,7 +376,7 @@ const CheckBox = ({ value, isChecked, label, disabled, onClick }) => {
type="checkbox"
value={value}
checked={isChecked}
disabled={disabled}
disabled={!isModerator || disabled}
onChange={(e) => onClick(e.target.checked)}
/>
<label style={{ width: "90%" }} class="form-check-label text-black">
Expand Down Expand Up @@ -391,21 +404,41 @@ const RadioButton = ({ value, isChecked, label }) => {
const isAllowedToEditProposal = Near.view(
"${REPL_DEVHUB_CONTRACT}",
"is_allowed_to_edit_proposal",
{ proposal_id: proposal.id, editor: accountId }
{
proposal_id: proposal.id,
editor: accountId,
}
);

const isModerator = isAllowedToEditProposal && proposal.author_id !== accountId;
const isModerator = Near.view("${REPL_DEVHUB_LEGACY}", "has_moderator", {
account_id: accountId,
});

const editProposalStatus = ({ timeline }) => {
Near.call({
contractName: "${REPL_DEVHUB_CONTRACT}",
methodName: "edit_proposal_timeline",
args: {
id: proposal.id,
timeline: timeline,
const calls = [
{
contractName: "${REPL_DEVHUB_CONTRACT}",
methodName: "edit_proposal_timeline",
args: {
id: proposal.id,
timeline: timeline,
},
gas: 270000000000000,
},
gas: 270000000000000,
});
];
if (grantNotify === false) {
calls.unshift({
contractName: "${REPL_SOCIAL_CONTRACT}",
methodName: "grant_write_permission",
args: {
predecessor_id: "${REPL_DEVHUB_CONTRACT}",
keys: [context.accountId + "/index/notify"],
},
gas: Big(10).pow(14),
deposit: getDepositAmountForWriteAccess(userStorageDeposit),
});
}
Near.call(calls);
};

const [isReviewModalOpen, setReviewModal] = useState(false);
Expand Down

0 comments on commit 68c3070

Please sign in to comment.