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
Open
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion Backend/app/db/db.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,4 @@

async def get_db():
async with AsyncSessionLocal() as session:
yield session
yield session
38 changes: 38 additions & 0 deletions Backend/app/models/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,44 @@ class Collaboration(Base):
)


class Brand(Base):
__tablename__ = "brands"

user_id = Column(String, ForeignKey("users.id"), primary_key=True, nullable=False)
brand_name = Column(String, nullable=False)
logo_url = Column(Text, nullable=True)
website_url = Column(Text, nullable=True)
industry = Column(String, nullable=True)
company_size = Column(String, nullable=True)
location = Column(String, nullable=True)
description = Column(Text, nullable=True)

# Contact Information
contact_person = Column(String, nullable=True)
contact_email = Column(String, nullable=True)
contact_phone = Column(String, nullable=True)
role = Column(String, nullable=True) # Contact person's role

# Social Media Links
instagram_url = Column(Text, nullable=True)
facebook_url = Column(Text, nullable=True)
twitter_url = Column(Text, nullable=True)
linkedin_url = Column(Text, nullable=True)
youtube_url = Column(Text, nullable=True)

# Brand Preferences (stored as JSON arrays)
collaboration_types = Column(JSON, nullable=True) # ["sponsored_posts", "product_reviews", etc.]
preferred_creator_categories = Column(JSON, nullable=True) # ["lifestyle", "tech", etc.]
brand_values = Column(JSON, nullable=True) # ["sustainability", "innovation", etc.]
preferred_tone = Column(JSON, nullable=True) # ["professional", "casual", etc.]
platforms = Column(JSON, nullable=True) # ["instagram", "youtube", etc.]

created_at = Column(TIMESTAMP, default=datetime.utcnow)
updated_at = Column(TIMESTAMP, default=datetime.utcnow, onupdate=datetime.utcnow)

# Relationships
user = relationship("User", backref="brand_profile")

# Sponsorship Payments Table
class SponsorshipPayment(Base):
__tablename__ = "sponsorship_payments"
Expand Down
24 changes: 24 additions & 0 deletions Frontend/src/components/Onboarding.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -438,6 +438,7 @@ export default function Onboarding() {
setSubmitError("");
setSubmitSuccess("");
setProgress(0);

let profile_image_url = null;
try {
// 1. Upload profile picture if provided
Expand Down Expand Up @@ -937,6 +938,29 @@ export default function Onboarding() {
const [brandSubmitError, setBrandSubmitError] = useState("");
const [brandSubmitSuccess, setBrandSubmitSuccess] = useState("");
const handleBrandSubmit = async () => {
//User added to Users database before creating brand
const { data: existingUser, error: userCheckError } = await supabase
.from('users')
.select('id')
.eq('id', user?.id)
.single();

if (userCheckError && userCheckError.code === 'PGRST116') {
// User doesn't exist, create them first
const { error: userInsertError } = await supabase
.from('users')
.insert({
id: user?.id,
username: user?.user_metadata?.username || user?.email?.split('@')[0],
email: user?.email,
role: 'brand'
});

if (userInsertError) throw userInsertError;
} else if (userCheckError) {
throw userCheckError;
}

setBrandSubmitting(true);
setBrandSubmitError("");
setBrandSubmitSuccess("");
Expand Down