Build and type fixes
This commit is contained in:
parent
d5bd58ac3e
commit
656f3fbe71
64 changed files with 1878 additions and 1501 deletions
|
|
@ -22,13 +22,11 @@ import "@fontsource/playfair-display/900.css";
|
|||
import "styles/global.css";
|
||||
import { LicenseInfo } from "@mui/x-data-grid-pro";
|
||||
|
||||
LicenseInfo.setLicenseKey(
|
||||
"fd009c623acc055adb16370731be92e4T1JERVI6NDA3NTQsRVhQSVJZPTE2ODAyNTAwMTUwMDAsS0VZVkVSU0lPTj0x"
|
||||
);
|
||||
LicenseInfo.setLicenseKey(process.env.MUI_LICENSE_KEY ?? "");
|
||||
|
||||
const clientSideEmotionCache: any = createEmotionCache();
|
||||
|
||||
const messages = { en, fr };
|
||||
const messages: any = { en, fr };
|
||||
|
||||
interface LeafcutterWebProps extends AppProps {
|
||||
// eslint-disable-next-line react/require-default-props
|
||||
|
|
@ -36,7 +34,7 @@ interface LeafcutterWebProps extends AppProps {
|
|||
}
|
||||
|
||||
const LeafcutterWeb = (props: LeafcutterWebProps) => {
|
||||
const { locale } = useRouter();
|
||||
const { locale = "en" } = useRouter();
|
||||
const { Component, emotionCache = clientSideEmotionCache, pageProps } = props;
|
||||
|
||||
return (
|
||||
|
|
|
|||
|
|
@ -5,12 +5,12 @@ import Apple from "next-auth/providers/apple";
|
|||
export default NextAuth({
|
||||
providers: [
|
||||
Google({
|
||||
clientId: process.env.GOOGLE_CLIENT_ID,
|
||||
clientSecret: process.env.GOOGLE_CLIENT_SECRET,
|
||||
clientId: process.env.GOOGLE_CLIENT_ID ?? "",
|
||||
clientSecret: process.env.GOOGLE_CLIENT_SECRET ?? "",
|
||||
}),
|
||||
Apple({
|
||||
clientId: process.env.APPLE_CLIENT_ID,
|
||||
clientSecret: process.env.APPLE_CLIENT_SECRET
|
||||
clientId: process.env.APPLE_CLIENT_ID ?? "",
|
||||
clientSecret: process.env.APPLE_CLIENT_SECRET ?? "",
|
||||
}),
|
||||
],
|
||||
secret: process.env.NEXTAUTH_SECRET,
|
||||
|
|
|
|||
|
|
@ -3,8 +3,8 @@ import { NextApiRequest, NextApiResponse } from "next";
|
|||
import { getToken } from "next-auth/jwt";
|
||||
|
||||
const withAuthInfo =
|
||||
(handler) => async (req: NextApiRequest, res: NextApiResponse) => {
|
||||
const session = await getToken({
|
||||
(handler: any) => async (req: NextApiRequest, res: NextApiResponse) => {
|
||||
const session: any = await getToken({
|
||||
req,
|
||||
secret: process.env.NEXTAUTH_SECRET,
|
||||
});
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ const handler = async (req: NextApiRequest, res: NextApiResponse) => {
|
|||
return res.status(500).json({ message: "Only POST requests are allowed" });
|
||||
}
|
||||
|
||||
const { email } = session;
|
||||
const { email }: any = session;
|
||||
const { name, query } = JSON.parse(req.body);
|
||||
const result = await getUserMetadata(email);
|
||||
const { savedSearches } = result;
|
||||
|
|
@ -24,8 +24,8 @@ const handler = async (req: NextApiRequest, res: NextApiResponse) => {
|
|||
savedSearches: [...savedSearches, { name, query }]
|
||||
});
|
||||
const { savedSearches: updatedSavedSearches } = await getUserMetadata(email);
|
||||
return res.json(updatedSavedSearches)
|
||||
}
|
||||
return res.json(updatedSavedSearches);
|
||||
};
|
||||
|
||||
export default handler;
|
||||
|
||||
|
|
|
|||
|
|
@ -16,14 +16,14 @@ const handler = async (req: NextApiRequest, res: NextApiResponse) => {
|
|||
return res.status(500).json({ message: "Only POST requests are allowed" });
|
||||
}
|
||||
|
||||
const { email } = session;
|
||||
const { email }: any = session;
|
||||
const { name } = JSON.parse(req.body);
|
||||
const { savedSearches } = await getUserMetadata(email);
|
||||
const updatedSavedSearches = savedSearches.filter(search => search.name !== name);
|
||||
const result = await saveUserMetadata(email, { savedSearches: updatedSavedSearches })
|
||||
const updatedSavedSearches = savedSearches.filter((search: any) => search.name !== name);
|
||||
const result = await saveUserMetadata(email, { savedSearches: updatedSavedSearches });
|
||||
|
||||
return res.json({ result })
|
||||
}
|
||||
return res.json({ result });
|
||||
};
|
||||
|
||||
export default handler;
|
||||
|
||||
|
|
|
|||
|
|
@ -16,10 +16,10 @@ const handler = async (req: NextApiRequest, res: NextApiResponse) => {
|
|||
return res.status(500).json({ message: "Only GET requests are allowed" });
|
||||
}
|
||||
|
||||
const { email } = session;
|
||||
const { email }: any = session;
|
||||
const { savedSearches } = await getUserMetadata(email);
|
||||
|
||||
return res.json(savedSearches)
|
||||
}
|
||||
return res.json(savedSearches);
|
||||
};
|
||||
|
||||
export default handler;
|
||||
|
|
|
|||
|
|
@ -25,13 +25,14 @@ const handler = async (req: NextApiRequest, res: NextApiResponse) => {
|
|||
const { id } = ticket;
|
||||
try {
|
||||
const country = ticket.country[0] ?? "none";
|
||||
// @ts-expect-error
|
||||
const translatedCountry = taxonomy.country[country]?.display ?? "none";
|
||||
const countryDetails = unRegions.find((c) => c.name === translatedCountry);
|
||||
const countryDetails: any = unRegions.find((c) => c.name === translatedCountry);
|
||||
const augmentedTicket = {
|
||||
...ticket,
|
||||
region: countryDetails['sub-region']?.toLowerCase().replace(" ", "-") ?? null,
|
||||
continent: countryDetails.region?.toLowerCase().replace(" ", "-") ?? null,
|
||||
}
|
||||
};
|
||||
const out = await client.create({
|
||||
id: uuid(),
|
||||
index: "sample_tagged_tickets",
|
||||
|
|
@ -41,13 +42,13 @@ const handler = async (req: NextApiRequest, res: NextApiResponse) => {
|
|||
console.log(out);
|
||||
succeeded.push(id);
|
||||
} catch (e) {
|
||||
console.log(e)
|
||||
console.log(e);
|
||||
failed.push(id);
|
||||
}
|
||||
}
|
||||
|
||||
const results = { succeeded, failed };
|
||||
return res.json(results)
|
||||
return res.json(results);
|
||||
};
|
||||
|
||||
export default handler;
|
||||
|
|
|
|||
|
|
@ -18,14 +18,14 @@ const handler = async (req: NextApiRequest, res: NextApiResponse) => {
|
|||
|
||||
const { visualizationID, title, description, query } = req.body;
|
||||
const id = await createUserVisualization({
|
||||
email: session.email,
|
||||
email: session.email as string,
|
||||
visualizationID,
|
||||
title,
|
||||
description,
|
||||
query
|
||||
});
|
||||
|
||||
return res.json({ id })
|
||||
return res.json({ id });
|
||||
};
|
||||
|
||||
export default handler;
|
||||
|
|
|
|||
|
|
@ -17,9 +17,9 @@ const handler = async (req: NextApiRequest, res: NextApiResponse) => {
|
|||
}
|
||||
|
||||
const { id } = req.body;
|
||||
await deleteUserVisualization(session.email, id);
|
||||
await deleteUserVisualization(session.email as string, id);
|
||||
|
||||
return res.json({ id })
|
||||
return res.json({ id });
|
||||
};
|
||||
|
||||
export default handler;
|
||||
|
|
|
|||
|
|
@ -18,14 +18,14 @@ const handler = async (req: NextApiRequest, res: NextApiResponse) => {
|
|||
|
||||
const { id, title, description, query } = req.body;
|
||||
await updateUserVisualization({
|
||||
email: session.email,
|
||||
email: session.email as string,
|
||||
id,
|
||||
title,
|
||||
description,
|
||||
query
|
||||
});
|
||||
|
||||
return res.json({ id })
|
||||
return res.json({ id });
|
||||
};
|
||||
|
||||
export default handler;
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import { useEffect } from "react";
|
||||
import { FC, useEffect } from "react";
|
||||
import { GetServerSideProps, GetServerSidePropsContext } from "next";
|
||||
import Head from "next/head";
|
||||
import { useTranslate } from "react-polyglot";
|
||||
|
|
@ -12,7 +12,11 @@ import { useAppContext } from "components/AppProvider";
|
|||
import { PageHeader } from "components/PageHeader";
|
||||
import { VisualizationBuilder } from "components/VisualizationBuilder";
|
||||
|
||||
const Create = ({ templates }) => {
|
||||
type CreateProps = {
|
||||
templates: any;
|
||||
};
|
||||
|
||||
const Create: FC<CreateProps> = ({ templates }) => {
|
||||
const t = useTranslate();
|
||||
const {
|
||||
colors: { cdrLinkOrange },
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import { useEffect } from "react";
|
||||
import { GetServerSideProps, GetServerSidePropsContext } from "next";
|
||||
import { NextPage, GetServerSideProps, GetServerSidePropsContext } from "next";
|
||||
import { useRouter } from "next/router";
|
||||
import Head from "next/head";
|
||||
import Link from "next/link";
|
||||
|
|
@ -15,7 +15,13 @@ import { WelcomeDialog } from "components/WelcomeDialog";
|
|||
import { VisualizationCard } from "components/VisualizationCard";
|
||||
import { useAppContext } from "components/AppProvider";
|
||||
|
||||
const MyVisualizations = ({ visualizations }) => {
|
||||
type MyVisualizationsProps = {
|
||||
visualizations: any;
|
||||
};
|
||||
|
||||
const MyVisualizations: NextPage<MyVisualizationsProps> = ({
|
||||
visualizations,
|
||||
}) => {
|
||||
const router = useRouter();
|
||||
const cookieName = "homeIntroComplete";
|
||||
const [cookies, setCookie] = useCookies([cookieName]);
|
||||
|
|
@ -85,7 +91,7 @@ const MyVisualizations = ({ visualizations }) => {
|
|||
</Grid>
|
||||
</Grid>
|
||||
) : null}
|
||||
{visualizations.map((visualization, index) => (
|
||||
{visualizations.map((visualization: any, index: number) => (
|
||||
<VisualizationCard
|
||||
id={visualization.id}
|
||||
key={index}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
import Head from "next/head";
|
||||
import { NextPage } from "next";
|
||||
import Link from "next/link";
|
||||
import Image from "next/image";
|
||||
import { Box, Grid, Container, IconButton } from "@mui/material";
|
||||
|
|
@ -9,7 +10,11 @@ import LeafcutterLogoLarge from "images/leafcutter-logo-large.png";
|
|||
import { signIn, getSession } from "next-auth/react";
|
||||
import { useAppContext } from "components/AppProvider";
|
||||
|
||||
const Login = ({ session }) => {
|
||||
type LoginProps = {
|
||||
session: any;
|
||||
};
|
||||
|
||||
const Login: NextPage<LoginProps> = ({ session }) => {
|
||||
const t = useTranslate();
|
||||
const {
|
||||
colors: { leafcutterElectricBlue, lightGray },
|
||||
|
|
@ -112,7 +117,7 @@ const Login = ({ session }) => {
|
|||
|
||||
export default Login;
|
||||
|
||||
export async function getServerSideProps(context) {
|
||||
export async function getServerSideProps(context: any) {
|
||||
const session = (await getSession(context)) ?? null;
|
||||
|
||||
return {
|
||||
|
|
|
|||
|
|
@ -1,10 +1,12 @@
|
|||
import { FC, useLayoutEffect } from "react";
|
||||
import { useLayoutEffect } from "react";
|
||||
import { NextPage, GetServerSideProps, GetServerSidePropsContext } from "next";
|
||||
import { useRouter } from "next/router";
|
||||
import { Grid, CircularProgress } from "@mui/material";
|
||||
import Iframe from "react-iframe";
|
||||
import { useAppContext } from "components/AppProvider";
|
||||
import { checkAuth } from "lib/checkAuth";
|
||||
|
||||
export const Setup: FC = () => {
|
||||
const Setup: NextPage = () => {
|
||||
const {
|
||||
colors: { leafcutterElectricBlue },
|
||||
} = useAppContext();
|
||||
|
|
@ -44,3 +46,7 @@ export const Setup: FC = () => {
|
|||
};
|
||||
|
||||
export default Setup;
|
||||
|
||||
export const getServerSideProps: GetServerSideProps = async (
|
||||
context: GetServerSidePropsContext
|
||||
) => checkAuth(context);
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import { GetServerSideProps, GetServerSidePropsContext } from "next";
|
||||
import { NextPage, GetServerSideProps, GetServerSidePropsContext } from "next";
|
||||
import Head from "next/head";
|
||||
import { Grid, Box } from "@mui/material";
|
||||
import { useTranslate } from "react-polyglot";
|
||||
|
|
@ -9,7 +9,11 @@ import { PageHeader } from "components/PageHeader";
|
|||
import { VisualizationCard } from "components/VisualizationCard";
|
||||
import { useAppContext } from "components/AppProvider";
|
||||
|
||||
const Trends = ({ visualizations }) => {
|
||||
type TrendsProps = {
|
||||
visualizations: any;
|
||||
};
|
||||
|
||||
const Trends: NextPage<TrendsProps> = ({ visualizations }) => {
|
||||
const t = useTranslate();
|
||||
const {
|
||||
colors: { cdrLinkOrange },
|
||||
|
|
@ -58,7 +62,7 @@ const Trends = ({ visualizations }) => {
|
|||
spacing={3}
|
||||
justifyContent="space-between"
|
||||
>
|
||||
{visualizations.map((visualization, index) => (
|
||||
{visualizations.map((visualization: any, index: number) => (
|
||||
<VisualizationCard
|
||||
key={index}
|
||||
id={visualization.id}
|
||||
|
|
|
|||
|
|
@ -1,12 +1,16 @@
|
|||
/* eslint-disable no-underscore-dangle */
|
||||
import { GetServerSideProps, GetServerSidePropsContext } from "next";
|
||||
import { NextPage, GetServerSideProps, GetServerSidePropsContext } from "next";
|
||||
import { Client } from "@opensearch-project/opensearch";
|
||||
import Head from "next/head";
|
||||
import { Layout } from "components/Layout";
|
||||
import { VisualizationDetail } from "components/VisualizationDetail";
|
||||
import { checkAuth } from "lib/checkAuth";
|
||||
|
||||
const Visualization = ({ visualization }) => (
|
||||
type VisualizationProps = {
|
||||
visualization: any;
|
||||
};
|
||||
|
||||
const Visualization: NextPage<VisualizationProps> = ({ visualization }) => (
|
||||
<Layout>
|
||||
<Head>
|
||||
<title>Digital Threat Dashboard – Leafcutter</title>
|
||||
|
|
@ -43,7 +47,8 @@ export const getServerSideProps: GetServerSideProps = async (
|
|||
const response = rawResponse.body;
|
||||
|
||||
const hits = response.hits.hits.filter(
|
||||
(hit) => hit._id.split(":")[1] === visualizationID[0]
|
||||
// @ts-expect-error
|
||||
(hit: any) => hit._id.split(":")[1] === visualizationID[0]
|
||||
);
|
||||
const hit = hits[0];
|
||||
res.props.visualization = {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue