"use server";

import {
  performLeafcutterQuery,
  performZammadQuery,
  createUserVisualization,
} from "opensearch-common";

export const createUserVisualizationAction = async ({
  visualizationID,
  title,
  description,
  query,
}: any) => {
  const email = "xxx@example.com";
  const id = await createUserVisualization({
    email,
    visualizationID,
    title,
    description,
    query,
  });
  return id;
};

export const searchVisualizationsAction = async (
  kind: string,
  searchQuery: string,
) =>
  kind === "zammad"
    ? performZammadQuery(searchQuery, 1000)
    : performLeafcutterQuery(searchQuery, 1000);
