Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added new contract task type in the admin dashboard #843

Merged
merged 11 commits into from
Oct 6, 2024
26 changes: 15 additions & 11 deletions app/admin/quests/dashboard/[questId]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -529,11 +529,11 @@ export default function Page({ params }: QuestIdProps) {
desc: step.data.contract_desc,
href: step.data.contract_href,
cta: step.data.contract_cta,
calls: step.data.calls,
calls: JSON.parse(step.data.contract_calls),
});
}
} catch (error) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this catch, you can add

showNotification(`Error adding ${step.type} task: ${error}`, "error");

So that if there is any issue while parsing the JSON, the user is instantly informed

console.error(`Error adding task of type ${step.type}:`, error);
showNotification(`Error adding ${step.type} task: ${error}`, "error");
}
}
}, []);
Expand Down Expand Up @@ -630,14 +630,18 @@ export default function Page({ params }: QuestIdProps) {
href: step.data.balance_href,
});
} else if (step.type === "Contract") {
await AdminService.updateContract({
id: step.data.id,
name: step.data.contract_name,
desc: step.data.contract_desc,
href: step.data.contract_href,
cta: step.data.contract_cta,
calls: step.data.calls,
});
try {
await AdminService.updateContract({
id: step.data.id,
name: step.data.contract_name,
desc: step.data.contract_desc,
href: step.data.contract_href,
cta: step.data.contract_cta,
calls: JSON.parse(step.data.contract_calls),
});
} catch (error) {
showNotification(`Error adding ${step.type} task: ${error}`, "error");
PoulavBhowmick03 marked this conversation as resolved.
Show resolved Hide resolved
}
}
});

Expand Down Expand Up @@ -777,7 +781,7 @@ export default function Page({ params }: QuestIdProps) {
<AdminQuestDetails
quest={questData}
// eslint-disable-next-line @typescript-eslint/no-empty-function
setShowDomainPopup={() => {}}
setShowDomainPopup={() => { }}
hasRootDomain={false}
rewardButtonTitle={questData.disabled ? "Enable" : "Disable"}
onRewardButtonClick={async () => {
Expand Down