diff --git a/client/src/App.jsx b/client/src/App.jsx index 55ab51a..5a1814d 100644 --- a/client/src/App.jsx +++ b/client/src/App.jsx @@ -1,5 +1,8 @@ +import { useState } from 'react'; import { BrowserRouter, Routes, Route, Navigate, useLocation } from 'react-router-dom'; import { BusinessProvider, useBusiness } from './context/BusinessContext'; +import apiClient from './api/client'; +import BusinessReviewModal from './components/BusinessReviewModal'; import Sidebar from './components/Sidebar'; import Businesses from './pages/Businesses'; import Providers from './pages/Providers'; @@ -9,27 +12,65 @@ import Templates from './pages/Templates'; import { Link } from 'react-router-dom'; function SubLayout({ children }) { - const { activeBusinessId, hasGlobalSms } = useBusiness(); + const { activeBusiness, activeBusinessId, hasGlobalSms } = useBusiness(); + const [reviewBusiness, setReviewBusiness] = useState(null); + const [reviewLoading, setReviewLoading] = useState(false); + const [reviewError, setReviewError] = useState(''); + + async function handleOpenReview() { + if (!activeBusinessId || reviewLoading) return; + + setReviewError(''); + + if (activeBusiness?.scrapeArtifacts?.json) { + setReviewBusiness(activeBusiness); + return; + } + + setReviewLoading(true); + try { + const response = await apiClient.get(`/api/businesses/${activeBusinessId}`); + setReviewBusiness(response.data); + } catch (error) { + setReviewError(error.response?.data?.error || 'Failed to load brand review.'); + } finally { + setReviewLoading(false); + } + } + return ( -
Business review
++ {domain + ? `Review the captured storefront context for ${domain}.` + : 'Review the captured storefront context before moving on.'} +
+{name}
+ {domain &&{domain}
} + {tagline &&{tagline}
} +About Company
+A concise summary of what the brand is about, what it sells, and its overall vibe.
+{aboutText}
+Taglines
+Short brand lines captured during onboarding.
+"{entry}"
+ ))} +Color Codes
+Detected brand colors used across the storefront.
+Images
+Captured storefront images are available below.
+Captured Data
+Raw storefront data captured during onboarding.
+
+ {prettyJson}
+
+ Links
+Every discovered storefront link is available below.
+{link.label}
+{link.href}
+ + ))} +{url}
+Business created
-- The business has been created and the scraped storefront details are ready for review. + The onboarding job finished successfully and the business is ready for review.
Website URL
@@ -47,69 +132,143 @@ export default function RegisterBusinessModal({ onClose, onSuccess }) {- Enter the storefront website URL and we'll scrape it to detect the brand and set up your business. + {isFailed && ( +
Onboarding failed
++ {errorMessage || 'The onboarding job stopped before the business could be created.'}
+ Enter the storefront website URL and we'll scrape the homepage, about page, and representative product pages to detect the brand and set up your business. +
++ {status === 'error' ? 'Onboarding failed' : 'Onboarding in progress'} +
++ {status === 'error' + ? errorMessage || 'The onboarding job failed.' + : stageMeta.note} +
+Pages
+{progress.pagesProcessed}
+Links
+{progress.linkCount}
+Images
+{progress.imageCount}
+{activeBusiness.brandName}
-{activeBusiness.domain}
+{activeBusiness.brandName}
+{activeBusiness.domain}
+ {activeBusinessId && ( + <> +{reviewError}
+ )} + > + )} +Taglines
-"{t}"
- ))} -Brand Colors
-Brand Images
-{url}
-{url}
-Business created
-- {domain - ? `Scrape completed for ${domain}. Review the captured assets below before moving on.` - : 'Scrape completed. Review the captured assets below before moving on.'} -
-+ {isFailed ? 'Onboarding failed' : isCompleted ? 'Business ready' : 'Setting up business'} +
++ {isFailed + ? 'The onboarding job could not be completed. You can close this dialog and try again.' + : isCompleted + ? 'The storefront crawl and brand analysis finished successfully.' + : stageMeta.note} +
{name}
- {domain &&{domain}
} - {tagline &&{tagline}
} -Pages
+{processedPages}
+Links
+{progress.linkCount}
+Images
+{progress.imageCount}
Images
-Captured storefront images are available below.
-Captured Data
-Raw storefront data captured during onboarding.
-
- {prettyJson}
-
- Links
-Every discovered storefront link is available below.
-{link.label}
-{link.href}
- - ))} -Images
- - {cdnUrls.length} image{cdnUrls.length === 1 ? '' : 's'} - -{showUnifiedSalesChannelView - ? 'View every connected sales channel in one place and scrape the ones that are not onboarded yet.' - : 'Add a storefront URL and we’ll scrape it to set up your business.'} + ? 'View every connected sales channel in one place and onboard the ones that are not scraped yet.' + : 'Add a storefront URL and we’ll scrape the homepage, about page, and representative product pages to set up your business.'}