All files / src/utils fetchAssetModelOptions.ts

0% Statements 0/21
0% Branches 0/12
0% Functions 0/2
0% Lines 0/17

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28                                                       
import { store } from "../store/index.ts";
import { getAssets } from "../store/features/playbook/api/index.ts";
import { playbookSelector } from "../store/features/playbook/playbookSlice.ts";
import getCurrentTask from "./playbook/task/getCurrentTask.ts";
import { connectorsWithoutAssets } from "./integrations/connectorsWithoutAssets.ts";
 
export const fetchData = async (val: any = undefined) => {
  const { currentVisibleTask } = playbookSelector(store.getState());
  const id = val?.id ?? currentVisibleTask;
  const [task, currentId] = getCurrentTask(id);
 
  Iif (task?.source === "API" || val?.connector_type === "API") return;
  Iif (
    connectorsWithoutAssets.includes(task?.source ?? "") ||
    connectorsWithoutAssets.includes(val?.connector_type)
  )
    return;
  Iif (currentId) await getAssetsFunction(currentId);
};
 
export const getAssetsFunction = async (id: string) => {
  try {
    await store.dispatch(getAssets.initiate(id, { forceRefetch: true }));
  } catch (e) {
    console.log("There was an error:", e);
  }
};