diff --git a/Backend/app/db/db.py b/Backend/app/db/db.py index ae0f517..bb2b402 100644 --- a/Backend/app/db/db.py +++ b/Backend/app/db/db.py @@ -37,4 +37,4 @@ async def get_db(): async with AsyncSessionLocal() as session: - yield session + yield session \ No newline at end of file diff --git a/Backend/app/models/models.py b/Backend/app/models/models.py index 56681ab..339d877 100644 --- a/Backend/app/models/models.py +++ b/Backend/app/models/models.py @@ -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" diff --git a/Frontend/src/components/Onboarding.tsx b/Frontend/src/components/Onboarding.tsx index 950b09e..9128901 100644 --- a/Frontend/src/components/Onboarding.tsx +++ b/Frontend/src/components/Onboarding.tsx @@ -438,6 +438,7 @@ export default function Onboarding() { setSubmitError(""); setSubmitSuccess(""); setProgress(0); + let profile_image_url = null; try { // 1. Upload profile picture if provided @@ -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("");