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

Feat: Add Mandatory Domain checkbox to QuestDetailsForm and update Cr… #1086

Merged
merged 2 commits into from
Jan 28, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions components/admin/formSteps/QuestDetailsForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,28 @@ const QuestDetailsForm: FunctionComponent<QuestDetailsFormProps> = ({
</Typography>
</div>

<div className="flex flex-col gap-1">
<div className="flex items-center gap-2">
<input
type="checkbox"
name="mandatory_domain"
checked={questInput.mandatory_domain === null}
onChange={(e) => {
setQuestInput((prev: any) => ({
...prev,
mandatory_domain: e.target.checked ? null : "none",
}));
}}
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Fix type inconsistency in mandatory_domain handling.

The implementation uses null vs "none" string, but the type definition in backTypes.d.ts expects boolean | null. This mismatch could cause type errors and confusion.

Apply this diff to align with the type definition:

-      checked={questInput.mandatory_domain === null} 
-      onChange={(e) => {
-        setQuestInput((prev: any) => ({
-          ...prev,
-          mandatory_domain: e.target.checked ? null : "none",
-        }));
+      checked={questInput.mandatory_domain === true} 
+      onChange={(e) => {
+        setQuestInput((prev: any) => ({
+          ...prev,
+          mandatory_domain: e.target.checked ? true : null,
+        }));
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
checked={questInput.mandatory_domain === null}
onChange={(e) => {
setQuestInput((prev: any) => ({
...prev,
mandatory_domain: e.target.checked ? null : "none",
}));
}}
checked={questInput.mandatory_domain === true}
onChange={(e) => {
setQuestInput((prev: any) => ({
...prev,
mandatory_domain: e.target.checked ? true : null,
}));
}}

id="mandatory-domain-checkbox"
className={styles.customCheckbox}
/>
<label htmlFor="mandatory-domain-checkbox">Mandatory Domain</label>
</div>
<Typography type={TEXT_TYPE.BODY_MICRO} color="textGray">
Check this box if a domain is mandatory for this quest.
</Typography>
</div>

<div className="w-full sm:w-fit">
<Button onClick={onSubmit} disabled={submitButtonDisabled}>
<p>Save Changes</p>
Expand Down
2 changes: 2 additions & 0 deletions types/backTypes.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,7 @@ export type CreateQuest = {
img_card: string;
title_card: string;
issuer: string;
mandatory_domain?: boolean | null;
};

export type UpdateQuest = {
Expand All @@ -314,6 +315,7 @@ export type UpdateQuest = {
href: string;
image: string;
};
mandatory_domain?: boolean | null;
};

export type CreateBoost = {
Expand Down