Bridge integration

This commit is contained in:
Darren Clarke 2024-05-09 07:42:44 +02:00
parent 42a5e09c94
commit 162390008b
56 changed files with 776 additions and 591 deletions

View file

@ -1,18 +1,27 @@
"use server";
import { performLeafcutterQuery, performZammadQuery, createUserVisualization } from "opensearch-common";
import {
performLeafcutterQuery,
performZammadQuery,
createUserVisualization,
} from "opensearch-common";
export const createUserVisualizationAction = async ({visualizationID, title, description, query}: any) => {
const email = "darren@redaranj.com";
const id = await createUserVisualization({
email,
visualizationID,
title,
description,
query
});
return id;
}
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,

View file

@ -3,7 +3,6 @@
import { useEffect, FC } from "react";
import { useRouter, usePathname } from "next/navigation";
import Link from "next/link";
import ReactMarkdown from "react-markdown";
import { Grid, Button } from "@mui/material";
import { useTranslate } from "react-polyglot";
import { useCookies } from "react-cookie";
@ -11,13 +10,18 @@ import { Welcome } from "./Welcome";
import { WelcomeDialog } from "./WelcomeDialog";
import { VisualizationCard } from "./VisualizationCard";
import { useLeafcutterContext } from "./LeafcutterProvider";
import { getBasePath } from "../lib/utils";
type HomeProps = {
visualizations: any;
showWelcome?: boolean;
};
export const Home: FC<HomeProps> = ({ visualizations = [], showWelcome = true }) => {
export const Home: FC<HomeProps> = ({
visualizations = [],
showWelcome = true,
}) => {
console.log("Home", visualizations);
const router = useRouter();
const pathname = usePathname() ?? "";
const cookieName = "homeIntroComplete";
@ -45,7 +49,7 @@ export const Home: FC<HomeProps> = ({ visualizations = [], showWelcome = true })
sx={{ pt: "22px", pb: "22px" }}
direction="row-reverse"
>
<Link href={`${process.env.LEAFCUTTER_BASE_PATH ?? ""}/create`} passHref>
<Link href={`${getBasePath()}/create`} passHref>
<Button
sx={{
fontSize: 14,
@ -81,7 +85,11 @@ export const Home: FC<HomeProps> = ({ visualizations = [], showWelcome = true })
justifyContent="center"
>
<Grid item sx={{ ...h4, width: 450, textAlign: "center" }}>
<ReactMarkdown>{t("noSavedVisualizations")}</ReactMarkdown>
{"You dont have any saved visualizations. Go to "}
<Link href={`${getBasePath()}/create`}>Search and Create</Link>
{" or "}
<Link href={`${getBasePath()}/trends`}>Trends</Link>
{" to get started."}
</Grid>
</Grid>
) : null}

View file

@ -0,0 +1,9 @@
export const getBasePath = (): string => {
const basePath = process.env.LEAFCUTTER_BASE_PATH;
if (basePath && basePath !== "") {
return `${basePath}`;
}
return "";
};

View file

@ -0,0 +1,9 @@
export const getBasePath = (): string => {
const basePath = process.env.NEXT_PUBLIC_LEAFCUTTER_BASE_PATH;
if (basePath && basePath !== "") {
return `${basePath}`;
}
return "";
};

File diff suppressed because one or more lines are too long