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

Conversation

Snehagupta1907
Copy link
Contributor

@Snehagupta1907 Snehagupta1907 commented Jan 28, 2025

close: #1017

Summary by CodeRabbit

  • New Features
    • Added a "Mandatory Domain" checkbox to the Quest Details Form.
    • Enhanced quest creation and update types to support optional domain requirements.

Copy link

vercel bot commented Jan 28, 2025

@Snehagupta1907 is attempting to deploy a commit to the LFG Labs Team on Vercel.

A member of the Team first needs to authorize it.

Copy link

vercel bot commented Jan 28, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
starknet-quest ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 28, 2025 9:02pm

Copy link
Contributor

coderabbitai bot commented Jan 28, 2025

Caution

Review failed

The pull request is closed.

Warning

There were issues while running some tools. Please review the errors and either fix the tool’s configuration or disable the tool if it’s a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

npm warn config production Use --omit=dev instead.
npm error code ERESOLVE
npm error ERESOLVE could not resolve
npm error
npm error While resolving: @typescript-eslint/[email protected]
npm error Found: [email protected]
npm error node_modules/eslint
npm error dev eslint@"^9.11.1" from the root project
npm error peer eslint@"^6.0.0 || ^7.0.0 || >=8.0.0" from @eslint-community/[email protected]
npm error node_modules/@eslint-community/eslint-utils
npm error @eslint-community/eslint-utils@"^4.2.0" from @typescript-eslint/[email protected]
npm error node_modules/@typescript-eslint/utils
npm error @typescript-eslint/utils@"5.62.0" from @typescript-eslint/[email protected]
npm error node_modules/@typescript-eslint/eslint-plugin
npm error dev @typescript-eslint/eslint-plugin@"^5.47.0" from the root project
npm error 1 more (eslint-config-next)
npm error 1 more (@typescript-eslint/type-utils)
npm error @eslint-community/eslint-utils@"^4.2.0" from [email protected]
npm error 5 more (@typescript-eslint/type-utils, ...)
npm error
npm error Could not resolve dependency:
npm error peer eslint@"^6.0.0 || ^7.0.0 || ^8.0.0" from @typescript-eslint/[email protected]
npm error node_modules/@typescript-eslint/eslint-plugin
npm error dev @typescript-eslint/eslint-plugin@"^5.47.0" from the root project
npm error @typescript-eslint/eslint-plugin@"^5.4.2 || ^6.0.0 || ^7.0.0 || ^8.0.0" from [email protected]
npm error node_modules/eslint-config-next
npm error dev eslint-config-next@"^14.0.1" from the root project
npm error
npm error Conflicting peer dependency: [email protected]
npm error node_modules/eslint
npm error peer eslint@"^6.0.0 || ^7.0.0 || ^8.0.0" from @typescript-eslint/[email protected]
npm error node_modules/@typescript-eslint/eslint-plugin
npm error dev @typescript-eslint/eslint-plugin@"^5.47.0" from the root project
npm error @typescript-eslint/eslint-plugin@"^5.4.2 || ^6.0.0 || ^7.0.0 || ^8.0.0" from [email protected]
npm error node_modules/eslint-config-next
npm error dev eslint-config-next@"^14.0.1" from the root project
npm error
npm error Fix the upstream dependency conflict, or retry
npm error this command with --force or --legacy-peer-deps
npm error to accept an incorrect (and potentially broken) dependency resolution.
npm error
npm error
npm error For a full report see:
npm error /.npm/_logs/2025-01-28T21_02_35_732Z-eresolve-report.txt
npm error A complete log of this run can be found in: /.npm/_logs/2025-01-28T21_02_35_732Z-debug-0.log

Walkthrough

The pull request introduces a new "Mandatory Domain" feature for quest creation and management. It adds a checkbox in the QuestDetailsForm component to specify whether a domain is mandatory for a quest. The changes include updating the QuestDetailsForm component to handle the new checkbox and modifying the CreateQuest and UpdateQuest types in the type definitions to support the mandatory_domain property.

Changes

File Change Summary
components/admin/formSteps/QuestDetailsForm.tsx Added a new checkbox for "Mandatory Domain" with state management logic to set mandatory_domain to null when checked or "none" when unchecked
types/backTypes.d.ts Added optional mandatory_domain to CreateQuest as `string

Possibly related issues

Possibly related PRs

Suggested labels

❌ Change request


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 0d363c9 and aff696e.

📒 Files selected for processing (3)
  • app/admin/quests/dashboard/[questId]/page.tsx (25 hunks)
  • components/admin/formSteps/QuestDetailsForm.tsx (3 hunks)
  • types/backTypes.d.ts (2 hunks)

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🔭 Outside diff range comments (1)
types/backTypes.d.ts (1)

Type inconsistency detected in mandatory_domain field implementation

The field implementation shows inconsistencies that need to be addressed:

  • Main type in backTypes.d.ts uses string | null
  • Other types use boolean | null
  • UI implementation toggles between null and "none" string value

The field appears to be new with no existing database usage, but the type inconsistency should be standardized before proceeding.

🔗 Analysis chain

Line range hint 179-199: Verify handling of existing quests.

Let's ensure the UI properly handles existing quests with different mandatory_domain values.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for existing usage of mandatory_domain in the codebase
echo "Searching for mandatory_domain usage in API handlers..."
rg -A 5 "mandatory_domain.*=|mandatory_domain.*:" --type ts

echo "Searching for mandatory_domain in database queries..."
rg -A 5 "mandatory_domain" --type sql

echo "Searching for related test cases..."
rg -A 5 "mandatory_domain" --type test

Length of output: 2383


Script:

#!/bin/bash
# Search for SQL files and quest-related operations
echo "Searching for SQL files..."
fd -e sql

echo "Searching for mandatory_domain in test files..."
rg -A 5 "mandatory_domain" "**/*test*"

echo "Searching for quest table operations..."
rg -A 10 "CREATE TABLE.*quest|ALTER TABLE.*quest" -g "*.sql"

Length of output: 569


Script:

#!/bin/bash
# Search for Prisma schema and database operations
echo "Searching for Prisma schema..."
fd "schema.prisma"

echo "Searching for mandatory_domain in test files..."
rg -A 5 "mandatory_domain" -g "*test*.ts" -g "*test*.tsx" -g "*spec*.ts" -g "*spec*.tsx"

echo "Searching for quest-related database operations in TypeScript files..."
rg -A 10 "model Quest|interface Quest|type Quest" -g "*.ts" -g "*.prisma"

Length of output: 3942

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between bebf69b and 0d363c9.

📒 Files selected for processing (2)
  • components/admin/formSteps/QuestDetailsForm.tsx (1 hunks)
  • types/backTypes.d.ts (2 hunks)
🔇 Additional comments (2)
components/admin/formSteps/QuestDetailsForm.tsx (1)

179-199: LGTM! Well-structured UI implementation.

The checkbox implementation follows good practices:

  • Proper accessibility with label and id association
  • Clear helper text explaining the feature
  • Consistent styling with other checkboxes
types/backTypes.d.ts (1)

293-293: LGTM! Clean type definitions.

The mandatory_domain property is well-defined:

  • Optional property (?) allows backward compatibility
  • Union type (boolean | null) appropriately represents the tri-state nature
  • Consistently added to both CreateQuest and UpdateQuest types

Also applies to: 318-318

Comment on lines 184 to 190
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,
}));
}}

Copy link
Collaborator

@Marchand-Nicolas Marchand-Nicolas left a comment

Choose a reason for hiding this comment

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

Good job lgtm!

@Marchand-Nicolas Marchand-Nicolas merged commit e00d8e9 into lfglabs-dev:testnet Jan 28, 2025
3 of 4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add a "Mandatory domain" checkbox in QuestDetailsForm.tsx
2 participants