27 lines
716 B
TypeScript
27 lines
716 B
TypeScript
import type { IntegrationConfig } from "~/types";
|
|
import { IntegrationConfigType } from "~/types/enums";
|
|
|
|
interface Params {
|
|
integrations?: MaybeRef<IntegrationConfig[] | undefined | null>;
|
|
}
|
|
|
|
export const useIntegrations = (params: Params) => {
|
|
const getIntegration = (type: IntegrationConfigType, method: string) => {
|
|
const integrations = unref(params.integrations);
|
|
return integrations?.find((i) => i.type === type && i.method === method);
|
|
};
|
|
|
|
const simplex = computed(() =>
|
|
getIntegration(IntegrationConfigType.SIMPLEX, "code")
|
|
);
|
|
const signal = computed(() =>
|
|
getIntegration(IntegrationConfigType.SIGNAL, "code")
|
|
);
|
|
|
|
return {
|
|
getIntegration,
|
|
simplex,
|
|
signal,
|
|
};
|
|
};
|