feat: Add No Website button to onboarding Step 2 with business description form
This commit is contained in:
committed by
DikshaDisciplines
parent
f715d3edbb
commit
dca2318235
@@ -42,6 +42,10 @@ from api.onboarding import (
|
||||
get_onboarding_summary,
|
||||
get_website_analysis_data,
|
||||
get_research_preferences_data,
|
||||
save_business_info,
|
||||
get_business_info,
|
||||
get_business_info_by_user,
|
||||
update_business_info,
|
||||
StepCompletionRequest,
|
||||
APIKeyRequest
|
||||
)
|
||||
@@ -433,6 +437,45 @@ async def research_preferences_data():
|
||||
logger.error(f"Error in research_preferences_data: {e}")
|
||||
raise HTTPException(status_code=500, detail=str(e))
|
||||
|
||||
# Business Information endpoints
|
||||
@app.post("/api/onboarding/business-info")
|
||||
async def business_info_save(request: 'BusinessInfoRequest'):
|
||||
"""Save business information for users without websites."""
|
||||
try:
|
||||
from models.business_info_request import BusinessInfoRequest
|
||||
return await save_business_info(request)
|
||||
except Exception as e:
|
||||
logger.error(f"Error in business_info_save: {e}")
|
||||
raise HTTPException(status_code=500, detail=str(e))
|
||||
|
||||
@app.get("/api/onboarding/business-info/{business_info_id}")
|
||||
async def business_info_get(business_info_id: int):
|
||||
"""Get business information by ID."""
|
||||
try:
|
||||
return await get_business_info(business_info_id)
|
||||
except Exception as e:
|
||||
logger.error(f"Error in business_info_get: {e}")
|
||||
raise HTTPException(status_code=500, detail=str(e))
|
||||
|
||||
@app.get("/api/onboarding/business-info/user/{user_id}")
|
||||
async def business_info_get_by_user(user_id: int):
|
||||
"""Get business information by user ID."""
|
||||
try:
|
||||
return await get_business_info_by_user(user_id)
|
||||
except Exception as e:
|
||||
logger.error(f"Error in business_info_get_by_user: {e}")
|
||||
raise HTTPException(status_code=500, detail=str(e))
|
||||
|
||||
@app.put("/api/onboarding/business-info/{business_info_id}")
|
||||
async def business_info_update(business_info_id: int, request: 'BusinessInfoRequest'):
|
||||
"""Update business information."""
|
||||
try:
|
||||
from models.business_info_request import BusinessInfoRequest
|
||||
return await update_business_info(business_info_id, request)
|
||||
except Exception as e:
|
||||
logger.error(f"Error in business_info_update: {e}")
|
||||
raise HTTPException(status_code=500, detail=str(e))
|
||||
|
||||
# Include component logic router
|
||||
app.include_router(component_logic_router)
|
||||
|
||||
|
||||
@@ -2,7 +2,6 @@ import React, { useState, useEffect } from 'react';
|
||||
import { Box, Button, TextField, Typography, Card, CardContent, CircularProgress, Alert } from '@mui/material';
|
||||
import { ArrowBack as ArrowBackIcon, Save as SaveIcon, CheckCircle as CheckCircleIcon } from '@mui/icons-material';
|
||||
import { businessInfoApi, BusinessInfo } from '../../api/businessInfo';
|
||||
import { onboardingCache } from '../../services/onboardingCache';
|
||||
|
||||
interface BusinessDescriptionStepProps {
|
||||
onBack: () => void;
|
||||
@@ -20,17 +19,6 @@ const BusinessDescriptionStep: React.FC<BusinessDescriptionStepProps> = ({ onBac
|
||||
const [error, setError] = useState<string | null>(null);
|
||||
const [success, setSuccess] = useState<string | null>(null);
|
||||
|
||||
useEffect(() => {
|
||||
console.log('🔄 BusinessDescriptionStep mounted. Loading cached data...');
|
||||
const cachedData = onboardingCache.getStepData(2)?.businessInfo;
|
||||
if (cachedData) {
|
||||
setFormData(cachedData);
|
||||
console.log('✅ Loaded cached business info:', cachedData);
|
||||
} else {
|
||||
console.log('ℹ️ No cached business info found.');
|
||||
}
|
||||
}, []);
|
||||
|
||||
const handleChange = (e: React.ChangeEvent<HTMLInputElement | HTMLTextAreaElement>) => {
|
||||
const { name, value } = e.target;
|
||||
setFormData(prev => ({ ...prev, [name]: value }));
|
||||
@@ -51,10 +39,6 @@ const BusinessDescriptionStep: React.FC<BusinessDescriptionStepProps> = ({ onBac
|
||||
console.log('✅ Business info saved to DB:', response);
|
||||
setSuccess('Business information saved successfully!');
|
||||
|
||||
// Also save to cache for consistency with other steps
|
||||
onboardingCache.saveStepData(2, { businessInfo: response, hasWebsite: false });
|
||||
console.log('✅ Business info saved to cache.');
|
||||
|
||||
setTimeout(() => {
|
||||
onContinue();
|
||||
}, 1500); // Give user time to see success message
|
||||
@@ -90,7 +74,7 @@ const BusinessDescriptionStep: React.FC<BusinessDescriptionStepProps> = ({ onBac
|
||||
rows={4}
|
||||
margin="normal"
|
||||
required
|
||||
helperText={`${formData.business_description?.length || 0}/1000 characters`}
|
||||
helperText={`${formData.business_description.length}/1000 characters`}
|
||||
inputProps={{ maxLength: 1000 }}
|
||||
disabled={loading}
|
||||
/>
|
||||
@@ -101,7 +85,7 @@ const BusinessDescriptionStep: React.FC<BusinessDescriptionStepProps> = ({ onBac
|
||||
onChange={handleChange}
|
||||
fullWidth
|
||||
margin="normal"
|
||||
helperText={`${formData.industry?.length || 0}/100 characters`}
|
||||
helperText={`${formData.industry.length}/100 characters`}
|
||||
inputProps={{ maxLength: 100 }}
|
||||
disabled={loading}
|
||||
/>
|
||||
|
||||
Reference in New Issue
Block a user