From 2785f5ee96601ec5a816b79657066416cefc6175 Mon Sep 17 00:00:00 2001 From: Ritul Date: Mon, 30 Mar 2026 15:35:07 +0530 Subject: [PATCH] Stepper for the entire process instead of just provider config --- client/src/components/Sidebar.jsx | 157 ++++++++++++++++++++----- client/src/context/BusinessContext.jsx | 65 ++++++++-- client/src/pages/Events.jsx | 10 +- client/src/pages/GlobalSms.jsx | 56 ++++----- 4 files changed, 218 insertions(+), 70 deletions(-) diff --git a/client/src/components/Sidebar.jsx b/client/src/components/Sidebar.jsx index 3bfcd00..726c0ec 100644 --- a/client/src/components/Sidebar.jsx +++ b/client/src/components/Sidebar.jsx @@ -1,12 +1,7 @@ -import { NavLink, useNavigate } from 'react-router-dom'; +import { NavLink, useLocation, useNavigate } from 'react-router-dom'; import { useBusiness } from '../context/BusinessContext'; const SVG_ICONS = { - providers: ( - - - - ), globalSms: ( @@ -24,14 +19,75 @@ const SVG_ICONS = { ), }; -export default function Sidebar() { - const { activeBusiness, activeBusinessId, clearBusiness } = useBusiness(); - const navigate = useNavigate(); +function TopLevelStatus({ done, active }) { + if (done) { + return ( + + + + + + ); + } - const navItems = [ - { id: 'globalSms', to: `/${activeBusinessId}/global-sms`, label: 'Omni-channel SMS' }, - { id: 'events', to: `/${activeBusinessId}/events`, label: 'Events' }, - { id: 'templates', to: `/${activeBusinessId}/templates`, label: 'Templates' }, + if (active) { + return ; + } + + return ; +} + +export default function Sidebar() { + const { + activeBusiness, + activeBusinessId, + clearBusiness, + hasGlobalSms, + isSetupComplete, + hasSelectedTemplates, + } = useBusiness(); + const navigate = useNavigate(); + const location = useLocation(); + + const globalSmsPath = `/${activeBusinessId}/global-sms`; + const eventsPath = `/${activeBusinessId}/events`; + const templatesPath = `/${activeBusinessId}/templates`; + + const isGlobalSmsRoute = location.pathname === globalSmsPath; + const isEventsRoute = location.pathname === eventsPath; + const isTemplatesRoute = location.pathname === templatesPath; + + const omniSubsteps = [ + { id: 'profile', label: 'Add / Select Profile', done: hasGlobalSms, active: isGlobalSmsRoute && !hasGlobalSms }, + { id: 'validate', label: 'Validate cURL', done: hasGlobalSms, active: false }, + { id: 'fields', label: 'Complete Fields', done: isSetupComplete, active: isGlobalSmsRoute && hasGlobalSms && !isSetupComplete }, + { id: 'ready', label: 'Ready', done: isSetupComplete, active: isGlobalSmsRoute && isSetupComplete }, + ]; + + const stepItems = [ + { + id: 'globalSms', + to: globalSmsPath, + label: 'Omni-channel SMS', + done: isSetupComplete && !isGlobalSmsRoute, + active: isGlobalSmsRoute, + expanded: isGlobalSmsRoute, + substeps: omniSubsteps, + }, + { + id: 'events', + to: eventsPath, + label: 'Events', + done: hasSelectedTemplates && !isEventsRoute, + active: isEventsRoute, + }, + { + id: 'templates', + to: templatesPath, + label: 'Templates', + done: false, + active: isTemplatesRoute, + }, ]; function handleSwitch() { @@ -64,22 +120,65 @@ export default function Sidebar() { {/* Nav */} -