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: Onboarding flow for dashboard #825

Merged
merged 3 commits into from
Aug 24, 2024

Conversation

PedroCo3lho
Copy link
Contributor

@PedroCo3lho PedroCo3lho commented Aug 22, 2024

Implemented the new onboarding UI provided in Figma : https://www.figma.com/design/fh0OAvj4AS08kHoSxu3DkE/%F0%9F%9A%80-Starknet-Quest?node-id=5408-11294&t=siYIjELkI3CzUjfH-1

Pull Request type

  • Feature

Resolves: #721

Summary by CodeRabbit

Summary by CodeRabbit

  • New Features

    • Introduced a SuggestedQuests component to guide new users in starting their journey on the Starknet platform.
    • The component fetches and displays personalized onboarding quests, encouraging user engagement.
  • Bug Fixes

    • Streamlined the rendering logic for quest-related content, enhancing clarity and performance.
  • Style

    • Implemented minor formatting adjustments to improve overall layout styling.

Copy link

vercel bot commented Aug 22, 2024

@PedroCo3lho is attempting to deploy a commit to the StarknetID Team on Vercel.

A member of the Team first needs to authorize it.

Copy link
Contributor

coderabbitai bot commented Aug 22, 2024

Walkthrough

The changes introduce a new component, SuggestedQuests, which fetches and displays personalized onboarding quests for users on the Starknet platform. The component uses hooks to manage state and fetch data, rendering a grid of quest cards to guide new users in their journey.

Changes

Files Change Summary
app/[addressOrDomain]/page.tsx Introduced SuggestedQuests component, conditionally rendered based on isOwner. Streamlined rendering logic. Minor formatting adjustments made to the Tab component.
components/dashboard/SuggestedQuests.tsx Created SuggestedQuests component to fetch and display onboarding quests, featuring a title and description, with a grid of QuestCardCustomised components. Styled with CSS modules.

Assessment against linked issues

Objective Addressed Explanation
Onboarding flow for dashboard on SQ (#721)

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>.
    • 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 generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @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 as 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.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

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

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 3b1cecf and 50f4115.

Files selected for processing (2)
  • app/[addressOrDomain]/page.tsx (3 hunks)
  • components/dashboard/SuggestedQuests.tsx (1 hunks)
Additional comments not posted (2)
app/[addressOrDomain]/page.tsx (2)

378-379: Conditional rendering of SuggestedQuests is appropriate.

The use of conditional rendering based on isOwner is a good approach to personalize the user experience.


356-369: Streamlined logic and formatting adjustments are beneficial.

The streamlined logic and formatting adjustments enhance code readability and maintainability.

components/dashboard/SuggestedQuests.tsx Outdated Show resolved Hide resolved
@PedroCo3lho PedroCo3lho marked this pull request as draft August 22, 2024 23:50
@PedroCo3lho PedroCo3lho marked this pull request as ready for review August 23, 2024 10:40
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

Files that changed from the base of the PR and between 50f4115 and c266e33.

Files selected for processing (1)
  • components/dashboard/SuggestedQuests.tsx (1 hunks)
Additional context used
Biome
components/dashboard/SuggestedQuests.tsx

[error] 15-15: Change to an optional chain.

Unsafe fix: Change to an optional chain.

(lint/complexity/useOptionalChain)

Additional comments not posted (3)
components/dashboard/SuggestedQuests.tsx (3)

1-7: Imports and type declarations are well-structured.

The imports are relevant and necessary for the component's functionality.


23-33: JSX rendering logic is clear and effective.

The component structure aligns with the intended UI design and follows best practices.


36-36: Component export is correctly implemented.

The export statement follows common conventions for React components.

components/dashboard/SuggestedQuests.tsx Outdated Show resolved Hide resolved
Copy link

vercel bot commented Aug 23, 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 Aug 24, 2024 3:19pm
starknet-quest ✅ Ready (Inspect) Visit Preview 💬 Add feedback Aug 24, 2024 3:19pm

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.

Your PR looks really really great (the front is good and responsive, and it works very well, so gg!). I just added a little comment to optimize the quests fetching. Great PR thanks for your work!

Comment on lines 12 to 21
useEffect(() => {
const fetchQuests = async () => {
const res = await getQuests();
if (res && res.onboarding) {
setQuests(res.onboarding.slice(0, 3));
}
};

fetchQuests();
}, []);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Just a little optimization here:
As we use quests a lot in the website, it would involve a lot of requests if we had to fetch them everywhere we use them. Instead, we just fetch them once and store them in a shared state.
You can use

  const { quests } =
    useContext(QuestsContext);

to access it (and them simply keep the 3 firsts).
Tell me if it makes sense to you!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@Marchand-Nicolas Yeah, that makes total sense. Does the new commit 08880e9 solve the problem? I wasn't clear if you wanted me to display the first 3 quests from the entire array or just those from the onboarding category.

@Marchand-Nicolas Marchand-Nicolas added the ❌ Change request Change requested from reviewer label Aug 23, 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.

Actionable comments posted: 1

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between c266e33 and 08880e9.

Files selected for processing (1)
  • components/dashboard/SuggestedQuests.tsx (1 hunks)
Additional comments not posted (2)
components/dashboard/SuggestedQuests.tsx (2)

1-7: Imports are appropriate and necessary.

The imports align with the functionality of the component, ensuring type safety and context usage.


18-29: Rendering logic is clear and effective.

The component effectively renders the title, description, and quest cards using the mapped quests.

Comment on lines +9 to +16
const SuggestedQuests: React.FC = () => {
const { quests: contextQuests } = useContext(QuestsContext);
const [quests, setQuests] = useState<QuestDocument[]>([]);

useEffect(() => {
const onboardingQuests = contextQuests.filter((quest) => quest.category === "onboarding");
setQuests(onboardingQuests);
}, [contextQuests]);
Copy link
Contributor

@coderabbitai coderabbitai bot Aug 24, 2024

Choose a reason for hiding this comment

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

Optimize filtering logic.

The filtering logic is clear, but you can optimize it by directly setting the filtered quests in the state initialization.

Apply this diff to optimize the filtering logic:

 const SuggestedQuests: React.FC = () => {
     const { quests: contextQuests } = useContext(QuestsContext);
-    const [quests, setQuests] = useState<QuestDocument[]>([]);
+    const [quests, setQuests] = useState<QuestDocument[]>(contextQuests.filter((quest) => quest.category === "onboarding"));

     useEffect(() => {
-        const onboardingQuests = contextQuests.filter((quest) => quest.category === "onboarding");
-        setQuests(onboardingQuests);
+        setQuests(contextQuests.filter((quest) => quest.category === "onboarding"));
     }, [contextQuests]);
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
const SuggestedQuests: React.FC = () => {
const { quests: contextQuests } = useContext(QuestsContext);
const [quests, setQuests] = useState<QuestDocument[]>([]);
useEffect(() => {
const onboardingQuests = contextQuests.filter((quest) => quest.category === "onboarding");
setQuests(onboardingQuests);
}, [contextQuests]);
const SuggestedQuests: React.FC = () => {
const { quests: contextQuests } = useContext(QuestsContext);
const [quests, setQuests] = useState<QuestDocument[]>(contextQuests.filter((quest) => quest.category === "onboarding"));
useEffect(() => {
setQuests(contextQuests.filter((quest) => quest.category === "onboarding"));
}, [contextQuests]);

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@Marchand-Nicolas, would it be good to make this changes?

Copy link
Contributor

Choose a reason for hiding this comment

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

Seems like the humans are having a chat. I'll hop back into my burrow for now. If you need me again, just tag @coderabbitai in a new comment, and I'll come hopping out!

Copy link
Collaborator

Choose a reason for hiding this comment

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

Not necessary imo


return (
<div>
<div className="text-center">
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed the rendering order, it now renders directly in the middle.

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.

Lgtm!

@Marchand-Nicolas Marchand-Nicolas merged commit cef78db into lfglabs-dev:testnet Aug 24, 2024
1 of 3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
❌ Change request Change requested from reviewer
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Onboarding flow for dashboard on SQ
2 participants