diff --git a/src/components/robot/pages/RobotIntegrationPage.tsx b/src/components/robot/pages/RobotIntegrationPage.tsx index 2e2c9990..7adfd12a 100644 --- a/src/components/robot/pages/RobotIntegrationPage.tsx +++ b/src/components/robot/pages/RobotIntegrationPage.tsx @@ -72,16 +72,16 @@ export const RobotIntegrationPage = ({ const { t } = useTranslation(); const navigate = useNavigate(); const location = useLocation(); - + const pathSegments = location.pathname.split('/'); const robotsIndex = pathSegments.findIndex(segment => segment === 'robots' || segment === 'prebuilt-robots'); const integrateIndex = pathSegments.findIndex(segment => segment === 'integrate'); - - const robotIdFromUrl = robotsIndex !== -1 && robotsIndex + 1 < pathSegments.length - ? pathSegments[robotsIndex + 1] + + const robotIdFromUrl = robotsIndex !== -1 && robotsIndex + 1 < pathSegments.length + ? pathSegments[robotsIndex + 1] : null; - - const integrationType = integrateIndex !== -1 && integrateIndex + 1 < pathSegments.length + + const integrationType = integrateIndex !== -1 && integrateIndex + 1 < pathSegments.length ? pathSegments[integrateIndex + 1] as "googleSheets" | "airtable" | "webhook" : preSelectedIntegrationType || null; @@ -114,7 +114,7 @@ export const RobotIntegrationPage = ({ const [urlError, setUrlError] = useState(null); const { recordingId: recordingIdFromStore, notify, setRerenderRobots, setRecordingId } = useGlobalInfoStore(); - + const recordingId = robotIdFromUrl || recordingIdFromStore; useEffect(() => { @@ -137,7 +137,7 @@ export const RobotIntegrationPage = ({ const redirectUrl = `${window.location.origin}${basePath}/${recordingId}/integrate/googleSheets`; window.location.href = `${apiUrl}/auth/google?robotId=${recordingId}&redirectUrl=${encodeURIComponent(redirectUrl)}`; }; - + const authenticateWithAirtable = () => { if (!recordingId) { console.error("Cannot authenticate: recordingId is null"); @@ -251,7 +251,7 @@ export const RobotIntegrationPage = ({ const deleteWebhookSetting = async (webhookId: string) => { if (!recordingId) return; try { - setLoading(true); + setLoading(true); const response = await removeWebhook(webhookId, recordingId); if (response.ok) { setSettings((prev) => ({ ...prev, webhooks: (prev.webhooks || []).filter((webhook) => webhook.id !== webhookId) })); @@ -681,36 +681,60 @@ export const RobotIntegrationPage = ({ if (!selectedIntegrationType && !integrationType) { return ( navigate(`/${robotPath}/${recordingId}/integrate`)}> -
-
-
+
+
+
@@ -763,9 +787,9 @@ export const RobotIntegrationPage = ({ {settings.webhooks.map((webhook) => ( {webhook.url} - {webhook.events.map((event) => ())} + {webhook.events.map((event) => ())} {formatLastCalled(webhook.lastCalledAt)} - toggleWebhookStatusSetting(webhook.id)} size="small"/> + toggleWebhookStatusSetting(webhook.id)} size="small" /> testWebhookSetting(webhook.id)} disabled={loading || !webhook.active} title="Test"> editWebhookSetting(webhook)} disabled={loading} title="Edit"> @@ -780,7 +804,7 @@ export const RobotIntegrationPage = ({ {!showWebhookForm && ( - { setNewWebhook({ ...newWebhook, url: e.target.value }); if (urlError) setUrlError(null); }} error={!!urlError} helperText={urlError} required aria-describedby="webhook-url-help"/> + { setNewWebhook({ ...newWebhook, url: e.target.value }); if (urlError) setUrlError(null); }} error={!!urlError} helperText={urlError} required aria-describedby="webhook-url-help" /> setNewWebhook({ ...newWebhook, events: [e.target.value] })} sx={{ minWidth: "200px" }} required> Run finished Run failed @@ -796,13 +820,13 @@ export const RobotIntegrationPage = ({ {editingWebhook ? "Edit Webhook" : "Add New Webhook"} - { setNewWebhook({ ...newWebhook, url: e.target.value }); if (urlError) setUrlError(null); }} sx={{ marginBottom: "15px" }} placeholder="https://your-api.com/webhook/endpoint" required error={!!urlError} helperText={urlError}/> + { setNewWebhook({ ...newWebhook, url: e.target.value }); if (urlError) setUrlError(null); }} sx={{ marginBottom: "15px" }} placeholder="https://your-api.com/webhook/endpoint" required error={!!urlError} helperText={urlError} /> setNewWebhook({ ...newWebhook, events: typeof e.target.value === "string" ? [e.target.value] : e.target.value })} - SelectProps={{ multiple: true, renderValue: (selected) => ({(selected as string[]).map((value) => ())}),}} sx={{ marginBottom: "20px" }} required> + SelectProps={{ multiple: true, renderValue: (selected) => ({(selected as string[]).map((value) => ())}), }} sx={{ marginBottom: "20px" }} required> Run finished Run failed - setNewWebhook({ ...newWebhook, active: e.target.checked })}/>} label="Active" sx={{ marginBottom: "10px" }}/> + setNewWebhook({ ...newWebhook, active: e.target.checked })} />} label="Active" sx={{ marginBottom: "10px" }} />