From 232d734c9823207175846b0452305a821e5f398f Mon Sep 17 00:00:00 2001 From: Ritul Date: Thu, 9 Apr 2026 15:30:14 +0530 Subject: [PATCH] Setting provider name auto --- client/src/components/Sidebar.jsx | 23 +-- client/src/pages/GlobalSms.jsx | 42 +++--- client/src/pages/Providers.jsx | 9 +- client/src/utils/businessProfile.js | 19 ++- server/routes/businesses.js | 214 ++++++++++++++++++++++++---- server/services/crawlSummary.js | 86 ++++++++++- server/services/openai2.js | 5 + 7 files changed, 326 insertions(+), 72 deletions(-) diff --git a/client/src/components/Sidebar.jsx b/client/src/components/Sidebar.jsx index cd3d57b..7c18236 100644 --- a/client/src/components/Sidebar.jsx +++ b/client/src/components/Sidebar.jsx @@ -1,5 +1,6 @@ import { NavLink, useLocation, useNavigate } from 'react-router-dom'; import { useBusiness } from '../context/BusinessContext'; +import { getBusinessImage } from '../utils/businessProfile'; const SVG_ICONS = { analytics: ( @@ -64,26 +65,6 @@ function StageMarker({ done, active, enabled }) { return ; } -function normalizeText(value) { - return typeof value === 'string' ? value.trim() : ''; -} - -function getSidebarBusinessImage(business) { - const brandingLogos = business?.scrapeArtifacts?.json?.branding?.logos; - const primaryLogo = Array.isArray(brandingLogos) - ? brandingLogos.find((entry) => normalizeText(entry)) - : ''; - if (primaryLogo) return primaryLogo; - - return ( - normalizeText(business?.logoUrl) - || normalizeText(business?.imageUrl) - || (Array.isArray(business?.relevantImagePaths) - ? business.relevantImagePaths.find((entry) => normalizeText(entry)) || '' - : '') - ); -} - export default function Sidebar({ onOpenReview, reviewLoading = false, reviewError = '' }) { const { activeBusiness, @@ -95,7 +76,7 @@ export default function Sidebar({ onOpenReview, reviewLoading = false, reviewErr } = useBusiness(); const navigate = useNavigate(); const location = useLocation(); - const businessImage = getSidebarBusinessImage(activeBusiness); + const businessImage = getBusinessImage(activeBusiness); const analyticsPath = `/${activeBusinessId}/analytics`; const globalSmsPath = `/${activeBusinessId}/global-sms`; diff --git a/client/src/pages/GlobalSms.jsx b/client/src/pages/GlobalSms.jsx index 05e897c..260eb98 100644 --- a/client/src/pages/GlobalSms.jsx +++ b/client/src/pages/GlobalSms.jsx @@ -4,6 +4,7 @@ import apiClient from '../api/client'; import { useBusiness } from '../context/BusinessContext'; const BASE_PROFILE_KEYS = new Set(['providerName', 'senderId', 'dltEntityId']); +const PENDING_SENDER_ID_PROFILE_NAME = 'Pending Sender ID'; function formatUpdatedAt(value) { if (!value) return 'Not updated yet'; @@ -57,6 +58,12 @@ function getProfileSummary(profile) { return parts.join(' • ') || 'Profile saved. Complete the remaining setup fields to continue.'; } +function isPendingSenderIdProfile(profile) { + const normalizedName = String(profile?.name || '').trim(); + const senderId = String(profile?.provider?.senderId || '').trim(); + return (profile?.isAutoNamed === true && !senderId) || normalizedName === PENDING_SENDER_ID_PROFILE_NAME; +} + function DeleteProfileModal({ preview, deleting, onCancel, onConfirm }) { if (!preview) return null; @@ -133,7 +140,6 @@ export default function GlobalSms() { const [savingInputs, setSavingInputs] = useState(false); const [error, setError] = useState(''); const [success, setSuccess] = useState(''); - const [formName, setFormName] = useState(''); const [formCurl, setFormCurl] = useState(''); const [formSetActive, setFormSetActive] = useState(true); const [inputForm, setInputForm] = useState({}); @@ -146,10 +152,12 @@ export default function GlobalSms() { () => profiles.find((profile) => profile.id === activeProfileId) || null, [profiles, activeProfileId], ); - const missingInputs = activeProfile?.executionReadiness?.missingProfileInputs || []; + const missingInputs = useMemo( + () => activeProfile?.executionReadiness?.missingProfileInputs || [], + [activeProfile?.executionReadiness?.missingProfileInputs], + ); const hasProfiles = profiles.length > 0; const eventsPath = `/${businessId}/events`; - const analyticsPath = `/${businessId}/analytics`; const loadProfiles = useCallback(async () => { try { @@ -198,7 +206,7 @@ export default function GlobalSms() { async function handleSubmit(event) { event.preventDefault(); - if (!formName.trim() || !formCurl.trim()) return; + if (!formCurl.trim()) return; setSaving(true); setError(''); @@ -207,12 +215,10 @@ export default function GlobalSms() { try { await apiClient.post(`/api/businesses/${businessId}/global-sms/profiles`, { - name: formName.trim(), rawCurl: formCurl.trim(), setActive: formSetActive, }); - setFormName(''); setFormCurl(''); setFormSetActive(true); setSuccess('Profile created successfully.'); @@ -387,7 +393,12 @@ export default function GlobalSms() { {activeProfile ? (
-

Active Setup: {activeProfile.name}

+

+ Active Setup:{' '} + + {activeProfile.name} + +

{activeProfile.executionReadiness?.isSetupComplete ? 'Setup Complete' : 'Missing Information'} @@ -490,7 +501,7 @@ export default function GlobalSms() {
-

{profile.name}

+

{profile.name}

{isActive && ( Active Profile @@ -572,18 +583,6 @@ export default function GlobalSms() { )}
-
- - setFormName(event.target.value)} - placeholder="e.g. Production SMS" - className="w-full rounded-lg border border-border-main bg-white px-4 py-2 text-sm text-text-primary transition focus:outline-none focus:ring-2 focus:ring-primary-blue" - required - /> -
-