Skip to content

Bug fix: Brand On boarding doesn't work #114

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

PinJinx
Copy link

@PinJinx PinJinx commented Jul 23, 2025

Closes #110

📝 Description

This PR fixes the bug :When On boarding as a brand submitting brand results in different error's and not letting user move ahead

🔧 Changes Made

  • Added a logic to check if the user exists in users table before all the other logic in handleBrandSubmit() .If user is not there it creates a new row for the user before making any changes to the brands table.

  • Added the model for brands table for create tables at the startup of the backend.

📷 Screenshots or Visual Changes (if applicable)

nil

🤝 Collaboration

nil

✅ Checklist

  • I have read the contributing guidelines.
  • I have added tests that prove my fix is effective or that my feature works.
  • I have added necessary documentation (if applicable).
  • Any dependent changes have been merged and published in downstream modules.

Summary by CodeRabbit

  • New Features

    • Added support for brand profiles, allowing users with the "brand" role to store detailed brand information, contact details, social media links, and preferences.
  • Bug Fixes

    • Improved brand onboarding to ensure user records are created if missing before submitting brand information.

Copy link
Contributor

coderabbitai bot commented Jul 23, 2025

Walkthrough

A new Brand ORM model was introduced to represent brand profiles linked to users. The onboarding frontend now ensures a user record exists in the database before creating a brand, preventing foreign key errors. Minor formatting changes were made to backend and frontend files, with no impact on logic.

Changes

File(s) Change Summary
Backend/app/db/db.py Removed trailing newline in the get_db async generator; no logic changes.
Backend/app/models/models.py Added new Brand SQLAlchemy ORM model with fields for brand identity, contact, social links, preferences, etc.
Frontend/src/components/Onboarding.tsx Updated handleBrandSubmit to check for and insert user record before creating a brand; minor formatting edit.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant OnboardingComponent
    participant DB

    User->>OnboardingComponent: Submit brand onboarding form
    OnboardingComponent->>DB: Query users table for user_id
    alt User not found (PGRST116)
        OnboardingComponent->>DB: Insert user record (id, username, email, role='brand')
    else Other error
        OnboardingComponent->>OnboardingComponent: Throw error
    end
    OnboardingComponent->>DB: Insert brand record linked to user_id
    DB-->>OnboardingComponent: Confirmation
    OnboardingComponent-->>User: Proceed to dashboard
Loading

Estimated code review effort

2 (~15 minutes)

Poem

In the meadow where brands now bloom,
A rabbit hops with coding zoom!
New models sprout, user checks are keen,
No more errors to be seen.
With every fix, the garden grows—
Onboarding works, as every bunny knows! 🥕✨


📜 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 a3be437 and 6082f00.

📒 Files selected for processing (3)
  • Backend/app/db/db.py (1 hunks)
  • Backend/app/models/models.py (1 hunks)
  • Frontend/src/components/Onboarding.tsx (2 hunks)
🧠 Learnings (1)
Frontend/src/components/Onboarding.tsx (1)

Learnt from: Saahi30
PR: #98
File: Frontend/src/pages/CollaborationDetails.tsx:519-521
Timestamp: 2025-07-12T20:28:05.017Z
Learning: In frontend-only commits that use mock data, hardcoded progress values and similar placeholder data are acceptable and intentional. These values serve as placeholders for UI development and will be replaced with dynamic calculations once backend integration occurs.

🧬 Code Graph Analysis (1)
Frontend/src/components/Onboarding.tsx (1)
Frontend/src/utils/supabase.tsx (1)
  • supabase (11-11)
🧰 Additional context used
🧠 Learnings (1)
Frontend/src/components/Onboarding.tsx (1)

Learnt from: Saahi30
PR: #98
File: Frontend/src/pages/CollaborationDetails.tsx:519-521
Timestamp: 2025-07-12T20:28:05.017Z
Learning: In frontend-only commits that use mock data, hardcoded progress values and similar placeholder data are acceptable and intentional. These values serve as placeholders for UI development and will be replaced with dynamic calculations once backend integration occurs.

🧬 Code Graph Analysis (1)
Frontend/src/components/Onboarding.tsx (1)
Frontend/src/utils/supabase.tsx (1)
  • supabase (11-11)
🔇 Additional comments (4)
Backend/app/db/db.py (1)

40-40: LGTM! Minor formatting change.

The removal of the trailing newline has no functional impact on the database session management.

Frontend/src/components/Onboarding.tsx (2)

441-441: LGTM! Minor formatting improvement.

The blank line addition improves code readability without affecting functionality.


941-963: No additional Supabase inserts found—onboarding logic covers all brand creations

I ran a repo-wide search for every supabase.from(...).insert in all .ts/.tsx files and confirmed that the only brand insertion lives in Frontend/src/components/Onboarding.tsx, immediately guarded by your new user-existence check. There are no other insert calls elsewhere that could trigger foreign-key violations.

This fully addresses issue #110:

  • User lookup and conditional creation precede the sole brands.insert
  • No further checks are needed in other parts of the codebase

Great work!

Backend/app/models/models.py (1)

145-182: Well-designed Brand model that supports the onboarding fix.

The new Brand model is comprehensive and properly structured:

Strengths:

  • Uses user_id as primary key, establishing a clean 1:1 relationship with users
  • Comprehensive field coverage for brand identity, contact info, and preferences
  • Appropriate use of JSON columns for array-type data (collaboration types, creator categories, etc.)
  • Proper nullable field configuration allowing flexible data entry
  • Includes audit timestamps (created_at, updated_at)
  • Clean relationship definition with backref to User model

Integration:
This model perfectly supports the frontend user existence check in handleBrandSubmit(), ensuring referential integrity when creating brand profiles.

✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ 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.
    • Explain this complex logic.
    • 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 explain this code block.
    • @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 explain its main purpose.
    • @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.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

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.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this 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.

@PinJinx PinJinx changed the title Bug fix Bug fix: Brand On boarding doesn't work Jul 23, 2025
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.

BUG:Brand On boarding doesn't work
1 participant