diff --git a/backend/endpoints/v1/organizations/index.js b/backend/endpoints/v1/organizations/index.js index fcc7d40..1330fa2 100644 --- a/backend/endpoints/v1/organizations/index.js +++ b/backend/endpoints/v1/organizations/index.js @@ -301,7 +301,7 @@ function organizationEndpoints(app) { if (!organization) { response .status(200) - .json({ organization: null, error: "No org by that slug." }); + .json({ connector: null, error: "No org by that slug." }); return; } diff --git a/backend/models/organizationConnection.js b/backend/models/organizationConnection.js index 55bef0e..2c08c09 100644 --- a/backend/models/organizationConnection.js +++ b/backend/models/organizationConnection.js @@ -91,7 +91,7 @@ const OrganizationConnection = { data: validUpdates, }); - if (!success) { + if (!updatedConnector) { console.error(message); return null; } @@ -99,7 +99,7 @@ const OrganizationConnection = { return updatedConnector; } catch (e) { console.error(e.message); - return []; + return null; } }, }; diff --git a/frontend/src/pages/Dashboard/Connector/index.tsx b/frontend/src/pages/Dashboard/Connector/index.tsx index ed0cbb2..aa4c194 100644 --- a/frontend/src/pages/Dashboard/Connector/index.tsx +++ b/frontend/src/pages/Dashboard/Connector/index.tsx @@ -20,7 +20,7 @@ export default function ConnectorCard({ workspaces?: any[]; }) { const [loading, setLoading] = useState(true); - const [connector, setConnector] = useState(null); + const [connector, setConnector] = useState(null); const [canSync, setCanSync] = useState(false); useEffect(() => { @@ -51,6 +51,26 @@ export default function ConnectorCard({ fetchConnector(); }, []); + async function handleNewConnector(connector: object) { + if (!connector) return; + setLoading(true); + + if (SUPPORTED_VECTOR_DBS.includes(connector.type)) { + const { value: result } = await Organization.stats( + organization.slug, + 'vectorCounts' + ); + + if (!!result) { + if (result.remoteCount > 0 && result.remoteCount !== result.localCount) + setCanSync(true); + } + } + + setConnector(connector); + setLoading(false); + } + if (loading) { return (
@@ -93,7 +113,10 @@ export default function ConnectorCard({
- + ); }