2023-06-26 10:07:12 +00:00
|
|
|
"use client";
|
|
|
|
|
|
2023-02-13 13:46:56 +00:00
|
|
|
import { FC, useState } from "react";
|
|
|
|
|
import { Grid, Card, Box } from "@mui/material";
|
|
|
|
|
import Iframe from "react-iframe";
|
2024-03-20 17:51:21 +01:00
|
|
|
import { useLeafcutterContext } from "./LeafcutterProvider";
|
2023-08-25 07:11:33 +00:00
|
|
|
import { VisualizationDetailDialog } from "./VisualizationDetailDialog";
|
2023-02-13 13:46:56 +00:00
|
|
|
|
|
|
|
|
interface VisualizationCardProps {
|
|
|
|
|
id: string;
|
|
|
|
|
title: string;
|
|
|
|
|
description: string;
|
|
|
|
|
url: string;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export const VisualizationCard: FC<VisualizationCardProps> = ({
|
|
|
|
|
id,
|
|
|
|
|
title,
|
|
|
|
|
description,
|
|
|
|
|
url,
|
|
|
|
|
}) => {
|
|
|
|
|
const [open, setOpen] = useState(false);
|
|
|
|
|
const closeDialog = () => setOpen(false);
|
|
|
|
|
const {
|
|
|
|
|
typography: { h4, p },
|
|
|
|
|
colors: { leafcutterLightBlue, leafcutterElectricBlue },
|
2024-03-20 17:51:21 +01:00
|
|
|
} = useLeafcutterContext();
|
2023-08-25 07:11:33 +00:00
|
|
|
const finalURL = `${process.env.NEXT_PUBLIC_LEAFCUTTER_URL}${url}&_g=(filters%3A!()%2CrefreshInterval%3A(pause%3A!t%2Cvalue%3A0)%2Ctime%3A(from%3Anow-3y%2Cto%3Anow))`;
|
2023-02-13 13:46:56 +00:00
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<>
|
|
|
|
|
<Grid item xs={6}>
|
|
|
|
|
<Card
|
|
|
|
|
elevation={0}
|
|
|
|
|
sx={{
|
|
|
|
|
border: `1px solid ${leafcutterElectricBlue}`,
|
|
|
|
|
borderRadius: "10px",
|
|
|
|
|
backgroundColor: leafcutterLightBlue,
|
|
|
|
|
p: 2,
|
|
|
|
|
cursor: "pointer",
|
|
|
|
|
}}
|
|
|
|
|
onClick={() => setOpen(true)}
|
|
|
|
|
>
|
|
|
|
|
<Box
|
|
|
|
|
sx={{
|
|
|
|
|
backgroundColor: leafcutterLightBlue,
|
|
|
|
|
pointerEvents: "none",
|
|
|
|
|
borderRadius: "8px",
|
|
|
|
|
overflow: "hidden",
|
|
|
|
|
p: 1,
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
<Iframe url={finalURL} height="300" width="100%" frameBorder={0} />
|
|
|
|
|
</Box>
|
|
|
|
|
<Box component="h4" sx={{ ...h4, mt: 2, mb: 2 }}>
|
|
|
|
|
{title}
|
|
|
|
|
</Box>
|
|
|
|
|
<Box component="p" sx={{ ...p, mt: 2, mb: 2 }}>
|
|
|
|
|
{description}
|
|
|
|
|
</Box>
|
|
|
|
|
</Card>
|
|
|
|
|
</Grid>
|
|
|
|
|
{open ? (
|
|
|
|
|
<VisualizationDetailDialog
|
|
|
|
|
id={id}
|
|
|
|
|
title={title}
|
|
|
|
|
description={description}
|
|
|
|
|
url={url}
|
|
|
|
|
closeDialog={closeDialog}
|
|
|
|
|
editing={false}
|
|
|
|
|
/>
|
|
|
|
|
) : null}
|
|
|
|
|
</>
|
|
|
|
|
);
|
|
|
|
|
};
|