Skip to content

Commit

Permalink
feat: fix minor issues
Browse files Browse the repository at this point in the history
  • Loading branch information
d-klotz committed Aug 9, 2024
1 parent 2c86fea commit 47d253d
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 11 deletions.
4 changes: 2 additions & 2 deletions packages/ui/lib/integration/Data.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ const Data = ({ friggBaseUrl, authToken, integrationId }) => {
const fetchData = async () => {
if (authToken) {
const api = new API(friggBaseUrl, authToken);
// let sampleData = await api.getSampleData(integrationId);
let sampleData = getFakeData(); // Uncomment if you need fake data
let sampleData = await api.getSampleData(integrationId);
// let sampleData = getFakeData(); // Uncomment if you need fake data

if (sampleData && sampleData.error) {
toast({
Expand Down
19 changes: 11 additions & 8 deletions packages/ui/lib/integration/IntegrationList.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useEffect, useState } from "react";
import { useEffect, useState, useCallback } from "react";
import IntegrationSkeleton from "./IntegrationSkeleton";
import { getActiveAndPossibleIntegrationsCombined } from "../utils/IntegrationUtils";
import API from "../api/api";
Expand All @@ -10,6 +10,7 @@ import { IntegrationHorizontal, IntegrationVertical } from "../integration";
* @param props.friggBaseUrl - Base URL for Frigg backend
* @param props.componentLayout - Layout for displaying integrations - either 'default-horizontal' or 'default-vertical'
* @param props.authToken - JWT token for authenticated user in Frigg
* @param {string} props.sampleDataRoute - A route to display sample data for the integration
* @returns {JSX.Element} The rendered component
* @constructor
*/
Expand All @@ -18,11 +19,7 @@ const IntegrationList = (props) => {
const [integrations, setIntegrations] = useState([]);
const [isloading, setIsLoading] = useState(true);

const loadIntegrations = async () => {
if (!props.authToken) {
console.log("Authentication token is required to fetch integrations.");
}

const loadIntegrations = useCallback(async () => {
const api = new API(props.friggBaseUrl, props.authToken);
const integrationsData = await api.listIntegrations();

Expand All @@ -37,11 +34,16 @@ const IntegrationList = (props) => {
getActiveAndPossibleIntegrationsCombined(integrationsData);
setIntegrations(activeAndPossibleIntegrations);
}
};
}, [props.authToken, props.friggBaseUrl]);

useEffect(() => {
if (!props.authToken) {
console.log("Authentication token is required to fetch integrations.");
return;
}

loadIntegrations().then(() => setIsLoading(false));
}, []);
}, [loadIntegrations, props.authToken]);

const setInstalled = (data) => {
const items = [data, ...installedIntegrations];
Expand All @@ -58,6 +60,7 @@ const IntegrationList = (props) => {
refreshIntegrations={loadIntegrations}
friggBaseUrl={props.friggBaseUrl}
authToken={props.authToken}
sampleDataRoute={props.sampleDataRoute}
/>
);
}
Expand Down
2 changes: 1 addition & 1 deletion packages/ui/lib/integration/QuickActionsMenu.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ function QuickActionsMenu({

const getSampleData = async () => {
if (sampleDataRoute) {
window.location.href = sampleDataRoute;
window.location.href = `${sampleDataRoute}/${integrationId}`;
return;
}

Expand Down

0 comments on commit 47d253d

Please sign in to comment.