import { useState } from 'react';
import { Link } from 'react-router-dom';
import { useBrand } from '../context/BrandContext';
import BusinessReviewModal from '../components/BusinessReviewModal';
import RegisterBusinessModal from '../components/RegisterBusinessModal';
import apiClient from '../api/client';
const NAV_CARDS = [
{ to: '/events', label: 'Events', icon: 'β‘', desc: 'Manage order events and generate templates' },
{ to: '/templates', label: 'Templates', icon: 'π', desc: 'Review and configure approved templates' },
{ to: '/providers', label: 'Providers', icon: 'π’', desc: 'Save your SMS provider DLT details' },
];
function DeleteConfirmModal({ brandName, onCancel, onConfirm, deleting }) {
return (
π
Delete Brand?
This will permanently delete {brandName} and all associated events, templates, and images. This cannot be undone.
);
}
export default function Brand() {
const { brand, loading, refetch } = useBrand();
const [showModal, setShowModal] = useState(false);
const [showReviewModal, setShowReviewModal] = useState(false);
const [showDeleteConfirm, setShowDeleteConfirm] = useState(false);
const [deleting, setDeleting] = useState(false);
const [deleteError, setDeleteError] = useState('');
async function handleDelete() {
setDeleting(true);
setDeleteError('');
try {
await apiClient.delete('/api/brand');
setShowDeleteConfirm(false);
await refetch();
} catch (err) {
setDeleteError(err.response?.data?.error || 'Failed to delete brand');
setDeleting(false);
}
}
if (loading) {
return (
);
}
// β WELCOME SCREEN β
if (!brand) {
return (
S
SMS Template Extension
Generate TRAI-compliant SMS templates for your Fynd store. We'll scrape your website and use AI to extract your brand context automatically.
{showModal &&
{ setShowModal(false); refetch(); }} />}
);
}
// β BRAND DETAIL PAGE β
return (
{/* Brand header card */}
{brand.brandName}
{brand.domain}
{brand.tone}
Registered {new Date(brand.scrapedAt).toLocaleDateString('en-IN', { day: 'numeric', month: 'short', year: 'numeric' })}
{/* Navigation cards */}
{NAV_CARDS.map(card => (
{card.icon}
{card.label}
{card.desc}
))}
{deleteError && (
{deleteError}
)}
{showDeleteConfirm && (
setShowDeleteConfirm(false)}
onConfirm={handleDelete}
deleting={deleting}
/>
)}
{showReviewModal && (
setShowReviewModal(false)}
/>
)}
);
}