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: update karnot form #967

Merged
merged 7 commits into from
Dec 1, 2024
Merged

Feat: update karnot form #967

merged 7 commits into from
Dec 1, 2024

Conversation

Marchand-Nicolas
Copy link
Collaborator

@Marchand-Nicolas Marchand-Nicolas commented Dec 1, 2024

Summary by CodeRabbit

  • New Features

    • Introduced the QuestBanner component in the QuestDetails view to enhance user engagement with quest information.
    • Added a new quest banner with details including a title, description, and call to action.
  • Improvements

    • Enhanced the Task component to utilize the questId for improved domain verification logic.
  • Documentation

    • Updated type definitions to include questId in the Task type for better data management.

Copy link

vercel bot commented Dec 1, 2024

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

Name Status Preview Comments Updated (UTC)
sepolia-starknet-quest ✅ Ready (Inspect) Visit Preview 💬 Add feedback Dec 1, 2024 11:25am
starknet-quest ✅ Ready (Inspect) Visit Preview 💬 Add feedback Dec 1, 2024 11:25am

Copy link
Contributor

coderabbitai bot commented Dec 1, 2024

Walkthrough

This pull request introduces the QuestBanner component into the QuestDetails component and adds a new questId prop to both the Task and QuestBanner components. A new JSON file, questbanners.json, is created to store quest banner data. The questId prop enhances the Task component's logic for domain verification, allowing for conditional rendering based on the questId. The overall functionality and data flow of the components remain unchanged.

Changes

File Change Summary
components/quests/questDetails.tsx Added QuestBanner component and passed questId prop to Task and QuestBanner components.
public/utils/questbanners.json Introduced new JSON file containing quest banner data with properties like questId, title, etc.
components/quests/task.tsx Added questId prop to Task component; modified domain verification logic based on questId.
types/frontTypes.d.ts Updated Task type definition to include optional questId property of type string.

Possibly related PRs

  • feat: karnot quest visuals #965: The main PR introduces the QuestBanner component into QuestDetails, while this retrieved PR also adds a QuestBanner component, indicating a direct relationship in terms of component integration and usage of the questId prop.

Suggested reviewers

  • fricoben

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 /root/.npm/_logs/2024-12-01T11_18_37_480Z-eresolve-report.txt
npm error A complete log of this run can be found in: /root/.npm/_logs/2024-12-01T11_18_37_480Z-debug-0.log


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 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.

@Marchand-Nicolas Marchand-Nicolas added the 🔥 Ready for review This pull request needs a review label Dec 1, 2024
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.

Caution

Inline review comments failed to post. This is likely due to GitHub's limits when posting large numbers of comments.

Actionable comments posted: 1

🧹 Outside diff range and nitpick comments (4)
components/quests/questBanner.tsx (2)

16-19: Add aria-label to improve accessibility

The banner image div should have appropriate ARIA attributes for screen readers.

 <div
   className={styles.questBannerImage}
+  role="img"
+  aria-label={bannerDetails.title}
   style={{ backgroundImage: `url(${bannerDetails.image})` }}
 />

29-35: Add loading and error states to button interaction

The button click handler should handle potential errors when opening URLs.

 <Button
   onClick={() => {
+    try {
       window.open(bannerDetails.href, "_blank");
+    } catch (error) {
+      console.error('Error opening URL:', error);
+    }
   }}
 >
styles/quests.module.css (2)

304-316: Add hover state transitions for better UX

Consider adding smooth transitions for hover states to improve user experience.

 .questBanner {
   max-width: 90%;
   width: 728px;
   margin-top: 1.5rem;
   background-color: var(--menu-background);
   box-shadow: 0px 2px 30px rgba(16, 16, 18, 0.06);
   border-radius: 8px;
   display: flex;
   align-items: stretch;
   height: 201px;
+  transition: transform 0.2s ease-in-out, box-shadow 0.2s ease-in-out;
+}
+
+.questBanner:hover {
+  transform: translateY(-2px);
+  box-shadow: 0px 4px 40px rgba(16, 16, 18, 0.1);
 }

433-444: Improve responsive design for small screens

The current media query could be enhanced for better display on very small screens.

 @media screen and (max-width: 740px) {
   .questBanner {
     height: fit-content;
     flex-direction: column;
     gap: 1rem;
+    margin: 1rem;
   }

   .questBannerImage {
     width: 100%;
-    height: 100px;
+    min-height: 120px;
     border-bottom-left-radius: 0;
     border-top-left-radius: 8px;
+    border-top-right-radius: 8px;
   }
 }
+
+@media screen and (max-width: 380px) {
+  .questBanner {
+    margin: 0.5rem;
+  }
+  .questBannerImage {
+    min-height: 100px;
+  }
+}
🛑 Comments failed to post (1)
components/quests/questDetails.tsx (1)

433-433: 🛠️ Refactor suggestion

Add loading state handling for QuestBanner

The QuestBanner component should respect the loading state like other components in the file.

-            <QuestBanner questId={questId} />
+            {quest.rewards_title === "loading" ? null : (
+              <QuestBanner questId={questId} />
+            )}

Committable suggestion skipped: line range outside the PR's diff.

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

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 924ffd4 and 956e48e.

📒 Files selected for processing (3)
  • components/quests/questDetails.tsx (1 hunks)
  • components/quests/task.tsx (2 hunks)
  • types/frontTypes.d.ts (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • components/quests/questDetails.tsx
🔇 Additional comments (3)
components/quests/task.tsx (1)

36-36: LGTM: questId prop addition

The questId prop is correctly added to the Task component interface.

types/frontTypes.d.ts (2)

38-38: LGTM: questId type definition

The questId property is correctly typed as an optional string, maintaining backward compatibility.


Line range hint 186-187: Verify Task component usage and quest 224 behavior

Let's verify that:

  1. All Task components are properly updated with questId where needed
  2. Quest 224's special domain verification bypass works as intended
✅ Verification successful

Domain verification bypass for quest 224 is correctly implemented

The verification confirms that:

  1. The Task component correctly implements the domain verification bypass for quest 224
  2. The implementation is straightforward and contained within the Task component:
    • Domain verification is skipped only when questId === "224"
    • For all other quests, users without a root domain will see the domain popup
  3. The Task interface in types/frontTypes.d.ts properly includes all necessary props including questId

The special case handling for quest 224 is working as intended, and no issues were found in the implementation.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for Task component usage to ensure questId is properly passed
echo "Checking Task component usage:"
rg -l "Task" | xargs rg "<Task"

# Search for any other occurrences of quest 224 to understand its significance
echo -e "\nChecking for other references to quest 224:"
rg "224" --type ts --type tsx

Length of output: 907


Script:

#!/bin/bash
# Search for Task component usage with better context
echo "Checking Task component usage with context:"
rg -A 5 "<Task" --type tsx

# Search for quest 224 with proper file type
echo -e "\nChecking for references to quest 224:"
rg "224" . --type-add "tsx:*.tsx" --type-add "ts:*.ts" --type tsx --type ts

Length of output: 14466


Script:

#!/bin/bash
# Search for Task component implementation and props
echo "Checking Task component implementation:"
ast-grep --pattern 'const Task = $_' -f components/quests/task.tsx

# Search for questId usage in Task component
echo -e "\nChecking questId usage in Task component:"
rg -A 10 "questId.*224" components/quests/task.tsx

Length of output: 930


Script:

#!/bin/bash
# Search for Task component implementation without -f flag
echo "Checking Task component implementation:"
ast-grep --pattern 'const Task = $_'

# Search for hasRootDomain usage context
echo -e "\nChecking hasRootDomain context:"
rg -B 10 "hasRootDomain" components/quests/task.tsx

# Search for Task props interface
echo -e "\nChecking Task props interface:"
rg -A 10 "type Task = {" --type ts

Length of output: 1038


Script:

#!/bin/bash
# Search for Task interface with escaped braces
echo "Checking Task interface:"
rg "type Task = \{" --type ts -A 10

# Search for domain verification related code
echo -e "\nChecking domain verification context:"
rg -B 5 -A 5 "setShowDomainPopup" components/quests/task.tsx

# Search for any other quest 224 references in task component
echo -e "\nChecking other quest 224 references:"
rg "224" components/quests/task.tsx

Length of output: 1581

Comment on lines 186 to 187
if (!hasRootDomain && questId !== "224")
return setShowDomainPopup(true);
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Replace magic number "224" with a named constant

The hardcoded quest ID "224" makes the code less maintainable and its purpose unclear. Consider extracting this to a named constant that explains its significance.

+ // At the top of the file with other constants
+ const QUEST_BYPASS_DOMAIN_CHECK = "224"; // Add a comment explaining why this quest bypasses domain check

- if (!hasRootDomain && questId !== "224")
+ if (!hasRootDomain && questId !== QUEST_BYPASS_DOMAIN_CHECK)

Committable suggestion skipped: line range outside the PR's diff.

Copy link
Contributor

@fricoben fricoben left a comment

Choose a reason for hiding this comment

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

lgtm

@fricoben fricoben merged commit a164448 into testnet Dec 1, 2024
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🔥 Ready for review This pull request needs a review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants