From 69706053c616da5fe23f5f6f83ca63b48c9fdfbe Mon Sep 17 00:00:00 2001 From: Darren Clarke Date: Wed, 28 Jun 2023 10:52:23 +0000 Subject: [PATCH] App directory #3 --- .../{ => (login)}/login/_components/Login.tsx | 0 .../app/{ => (login)}/login/page.tsx | 0 .../{ => (main)}/about/_components/About.tsx | 4 ++-- .../about}/_components/AboutBox.tsx | 2 +- .../about}/_components/AboutFeature.tsx | 2 +- .../app/{ => (main)}/about/page.tsx | 0 .../create/_components/Create.tsx | 3 +-- .../app/{ => (main)}/create/page.tsx | 3 +-- .../app/{ => (main)}/faq/_components/FAQ.tsx | 0 apps/leafcutter/app/{ => (main)}/faq/page.tsx | 0 apps/leafcutter/app/(main)/layout.tsx | 22 ++++++++++++++++++ .../_components/Preview.tsx | 21 +++++++++++++++++ .../preview/[...visualizationID]/page.tsx | 23 +++---------------- .../setup/_components/Setup.tsx} | 6 +++-- apps/leafcutter/app/(main)/setup/page.tsx | 6 +++++ .../trends/_components/Trends.tsx | 0 .../app/{ => (main)}/trends/page.tsx | 0 .../[...visualizationID]/page.tsx | 0 .../app/_components/VisualizationDetail.tsx | 2 +- .../api/trends/recent/{route.ts => _route.ts} | 0 .../app/api/visualizations/create/route.ts | 2 +- .../app/api/visualizations/update/route.ts | 3 +-- apps/leafcutter/app/layout.tsx | 6 +---- .../_components/LabelStudioWrapper.tsx | 2 ++ .../[id]/@detail/_components/TicketDetail.tsx | 2 +- 25 files changed, 69 insertions(+), 40 deletions(-) rename apps/leafcutter/app/{ => (login)}/login/_components/Login.tsx (100%) rename apps/leafcutter/app/{ => (login)}/login/page.tsx (100%) rename apps/leafcutter/app/{ => (main)}/about/_components/About.tsx (97%) rename apps/leafcutter/app/{ => (main)/about}/_components/AboutBox.tsx (89%) rename apps/leafcutter/app/{ => (main)/about}/_components/AboutFeature.tsx (96%) rename apps/leafcutter/app/{ => (main)}/about/page.tsx (100%) rename apps/leafcutter/app/{ => (main)}/create/_components/Create.tsx (95%) rename apps/leafcutter/app/{ => (main)}/create/page.tsx (68%) rename apps/leafcutter/app/{ => (main)}/faq/_components/FAQ.tsx (100%) rename apps/leafcutter/app/{ => (main)}/faq/page.tsx (100%) create mode 100644 apps/leafcutter/app/(main)/layout.tsx create mode 100644 apps/leafcutter/app/(main)/preview/[...visualizationID]/_components/Preview.tsx rename apps/leafcutter/app/{ => (main)}/preview/[...visualizationID]/page.tsx (80%) rename apps/leafcutter/app/{setup/page.tsx => (main)/setup/_components/Setup.tsx} (93%) create mode 100644 apps/leafcutter/app/(main)/setup/page.tsx rename apps/leafcutter/app/{ => (main)}/trends/_components/Trends.tsx (100%) rename apps/leafcutter/app/{ => (main)}/trends/page.tsx (100%) rename apps/leafcutter/app/{ => (main)}/visualizations/[...visualizationID]/page.tsx (100%) rename apps/leafcutter/app/api/trends/recent/{route.ts => _route.ts} (100%) diff --git a/apps/leafcutter/app/login/_components/Login.tsx b/apps/leafcutter/app/(login)/login/_components/Login.tsx similarity index 100% rename from apps/leafcutter/app/login/_components/Login.tsx rename to apps/leafcutter/app/(login)/login/_components/Login.tsx diff --git a/apps/leafcutter/app/login/page.tsx b/apps/leafcutter/app/(login)/login/page.tsx similarity index 100% rename from apps/leafcutter/app/login/page.tsx rename to apps/leafcutter/app/(login)/login/page.tsx diff --git a/apps/leafcutter/app/about/_components/About.tsx b/apps/leafcutter/app/(main)/about/_components/About.tsx similarity index 97% rename from apps/leafcutter/app/about/_components/About.tsx rename to apps/leafcutter/app/(main)/about/_components/About.tsx index f132f53..b88c3c6 100644 --- a/apps/leafcutter/app/about/_components/About.tsx +++ b/apps/leafcutter/app/(main)/about/_components/About.tsx @@ -7,8 +7,8 @@ import Link from "next/link"; import { Grid, Container, Box, Button } from "@mui/material"; import { useAppContext } from "@/app/_components/AppProvider"; import { PageHeader } from "@/app/_components/PageHeader"; -import { AboutFeature } from "@/app/_components/AboutFeature"; -import { AboutBox } from "@/app/_components/AboutBox"; +import { AboutFeature } from "./AboutFeature"; +import { AboutBox } from "./AboutBox"; import AbstractDiagram from "images/abstract-diagram.png"; import AboutHeader from "images/about-header.png"; import Globe from "images/globe.png"; diff --git a/apps/leafcutter/app/_components/AboutBox.tsx b/apps/leafcutter/app/(main)/about/_components/AboutBox.tsx similarity index 89% rename from apps/leafcutter/app/_components/AboutBox.tsx rename to apps/leafcutter/app/(main)/about/_components/AboutBox.tsx index b90f1a5..1bba679 100644 --- a/apps/leafcutter/app/_components/AboutBox.tsx +++ b/apps/leafcutter/app/(main)/about/_components/AboutBox.tsx @@ -2,7 +2,7 @@ import { FC, PropsWithChildren } from "react"; import { Box } from "@mui/material"; -import { useAppContext } from "./AppProvider"; +import { useAppContext } from "../../../_components/AppProvider"; type AboutBoxProps = PropsWithChildren<{ backgroundColor: string; diff --git a/apps/leafcutter/app/_components/AboutFeature.tsx b/apps/leafcutter/app/(main)/about/_components/AboutFeature.tsx similarity index 96% rename from apps/leafcutter/app/_components/AboutFeature.tsx rename to apps/leafcutter/app/(main)/about/_components/AboutFeature.tsx index ca46fc9..4503625 100644 --- a/apps/leafcutter/app/_components/AboutFeature.tsx +++ b/apps/leafcutter/app/(main)/about/_components/AboutFeature.tsx @@ -4,7 +4,7 @@ import { FC } from "react"; import Image from "next/legacy/image"; import { Grid, Box, GridSize } from "@mui/material"; import AboutDots from "images/about-dots.png"; -import { useAppContext } from "./AppProvider"; +import { useAppContext } from "app/_components/AppProvider"; interface AboutFeatureProps { title: string; diff --git a/apps/leafcutter/app/about/page.tsx b/apps/leafcutter/app/(main)/about/page.tsx similarity index 100% rename from apps/leafcutter/app/about/page.tsx rename to apps/leafcutter/app/(main)/about/page.tsx diff --git a/apps/leafcutter/app/create/_components/Create.tsx b/apps/leafcutter/app/(main)/create/_components/Create.tsx similarity index 95% rename from apps/leafcutter/app/create/_components/Create.tsx rename to apps/leafcutter/app/(main)/create/_components/Create.tsx index aabb0a3..fb5363c 100644 --- a/apps/leafcutter/app/create/_components/Create.tsx +++ b/apps/leafcutter/app/(main)/create/_components/Create.tsx @@ -11,10 +11,9 @@ import { VisualizationBuilder } from "@/app/_components/VisualizationBuilder"; type CreateProps = { templates: any; - embedded: boolean; }; -export const Create: FC = ({ templates, embedded }) => { +export const Create: FC = ({ templates }) => { const t = useTranslate(); const { colors: { cdrLinkOrange }, diff --git a/apps/leafcutter/app/create/page.tsx b/apps/leafcutter/app/(main)/create/page.tsx similarity index 68% rename from apps/leafcutter/app/create/page.tsx rename to apps/leafcutter/app/(main)/create/page.tsx index ab0329d..3841e0b 100644 --- a/apps/leafcutter/app/create/page.tsx +++ b/apps/leafcutter/app/(main)/create/page.tsx @@ -3,7 +3,6 @@ import { Create } from "./_components/Create"; export default async function Page() { const templates = await getTemplates(100); - console.log({templates}); - return ; + return ; }; diff --git a/apps/leafcutter/app/faq/_components/FAQ.tsx b/apps/leafcutter/app/(main)/faq/_components/FAQ.tsx similarity index 100% rename from apps/leafcutter/app/faq/_components/FAQ.tsx rename to apps/leafcutter/app/(main)/faq/_components/FAQ.tsx diff --git a/apps/leafcutter/app/faq/page.tsx b/apps/leafcutter/app/(main)/faq/page.tsx similarity index 100% rename from apps/leafcutter/app/faq/page.tsx rename to apps/leafcutter/app/(main)/faq/page.tsx diff --git a/apps/leafcutter/app/(main)/layout.tsx b/apps/leafcutter/app/(main)/layout.tsx new file mode 100644 index 0000000..c9a7d3b --- /dev/null +++ b/apps/leafcutter/app/(main)/layout.tsx @@ -0,0 +1,22 @@ +import { ReactNode } from "react"; +import "app/_styles/global.css"; +import "@fontsource/poppins/400.css"; +import "@fontsource/poppins/700.css"; +import "@fontsource/roboto/400.css"; +import "@fontsource/roboto/700.css"; +import "@fontsource/playfair-display/900.css"; +// import getConfig from "next/config"; +// import { LicenseInfo } from "@mui/x-data-grid-pro"; +import { InternalLayout } from "app/_components/InternalLayout"; +import { headers } from 'next/headers' + +type LayoutProps = { + children: ReactNode; +}; + +export default function Layout({ children }: LayoutProps) { + const allHeaders = headers(); + const embedded = Boolean(allHeaders.get('x-leafcutter-embedded')); +console.log({embedded}) + return {children}; +} diff --git a/apps/leafcutter/app/(main)/preview/[...visualizationID]/_components/Preview.tsx b/apps/leafcutter/app/(main)/preview/[...visualizationID]/_components/Preview.tsx new file mode 100644 index 0000000..eb0eab3 --- /dev/null +++ b/apps/leafcutter/app/(main)/preview/[...visualizationID]/_components/Preview.tsx @@ -0,0 +1,21 @@ +import { FC } from "react"; +/* eslint-disable no-underscore-dangle */ +import { RawDataViewer } from "@/app/_components/RawDataViewer"; +import { VisualizationDetail } from "@/app/_components/VisualizationDetail"; + +interface PreviewProps { + visualization: any; + visualizationType: string; + data: any[]; +} + +export const Preview: FC = ({ + visualization, + visualizationType, + data, +}) => + visualizationType === "rawData" ? ( + + ) : ( + + ); diff --git a/apps/leafcutter/app/preview/[...visualizationID]/page.tsx b/apps/leafcutter/app/(main)/preview/[...visualizationID]/page.tsx similarity index 80% rename from apps/leafcutter/app/preview/[...visualizationID]/page.tsx rename to apps/leafcutter/app/(main)/preview/[...visualizationID]/page.tsx index c26032d..bac4dad 100644 --- a/apps/leafcutter/app/preview/[...visualizationID]/page.tsx +++ b/apps/leafcutter/app/(main)/preview/[...visualizationID]/page.tsx @@ -1,29 +1,12 @@ -import { FC } from "react"; /* eslint-disable no-underscore-dangle */ // import { Client } from "@opensearch-project/opensearch"; -import { RawDataViewer } from "@/app/_components/RawDataViewer"; -import { VisualizationDetail } from "@/app/_components/VisualizationDetail"; +import { Preview } from "./_components/Preview"; // import { createVisualization } from "lib/opensearch"; -interface PreviewProps { - visualization: any; - visualizationType: string; - data: any[]; +export default function Page() { + return ; } -const Preview: FC = ({ - visualization, - visualizationType, - data, -}) => - visualizationType === "rawData" ? ( - - ) : ( - - ); - -export default Preview; - /* export const getServerSideProps: GetServerSideProps = async ( context: GetServerSidePropsContext diff --git a/apps/leafcutter/app/setup/page.tsx b/apps/leafcutter/app/(main)/setup/_components/Setup.tsx similarity index 93% rename from apps/leafcutter/app/setup/page.tsx rename to apps/leafcutter/app/(main)/setup/_components/Setup.tsx index 0f13284..cea9277 100644 --- a/apps/leafcutter/app/setup/page.tsx +++ b/apps/leafcutter/app/(main)/setup/_components/Setup.tsx @@ -1,11 +1,13 @@ +"use client"; + +import { FC } from "react"; import { useLayoutEffect } from "react"; -import { NextPage } from "next"; import { useRouter } from "next/navigation"; import { Grid, CircularProgress } from "@mui/material"; import Iframe from "react-iframe"; import { useAppContext } from "@/app/_components/AppProvider"; -const Setup: NextPage = () => { +export const Setup:FC = () => { const { colors: { leafcutterElectricBlue }, } = useAppContext(); diff --git a/apps/leafcutter/app/(main)/setup/page.tsx b/apps/leafcutter/app/(main)/setup/page.tsx new file mode 100644 index 0000000..544b40c --- /dev/null +++ b/apps/leafcutter/app/(main)/setup/page.tsx @@ -0,0 +1,6 @@ +import { Setup } from './_components/Setup'; + +export default function Page() { + return ; +} + diff --git a/apps/leafcutter/app/trends/_components/Trends.tsx b/apps/leafcutter/app/(main)/trends/_components/Trends.tsx similarity index 100% rename from apps/leafcutter/app/trends/_components/Trends.tsx rename to apps/leafcutter/app/(main)/trends/_components/Trends.tsx diff --git a/apps/leafcutter/app/trends/page.tsx b/apps/leafcutter/app/(main)/trends/page.tsx similarity index 100% rename from apps/leafcutter/app/trends/page.tsx rename to apps/leafcutter/app/(main)/trends/page.tsx diff --git a/apps/leafcutter/app/visualizations/[...visualizationID]/page.tsx b/apps/leafcutter/app/(main)/visualizations/[...visualizationID]/page.tsx similarity index 100% rename from apps/leafcutter/app/visualizations/[...visualizationID]/page.tsx rename to apps/leafcutter/app/(main)/visualizations/[...visualizationID]/page.tsx diff --git a/apps/leafcutter/app/_components/VisualizationDetail.tsx b/apps/leafcutter/app/_components/VisualizationDetail.tsx index 2ede259..b374f27 100644 --- a/apps/leafcutter/app/_components/VisualizationDetail.tsx +++ b/apps/leafcutter/app/_components/VisualizationDetail.tsx @@ -26,7 +26,7 @@ export const VisualizationDetail: FC = ({ typography: { h4, p }, } = useAppContext(); const finalURL = `${process.env.NEXT_PUBLIC_NEXTAUTH_URL}${url}&_g=(filters%3A!()%2CrefreshInterval%3A(pause%3A!t%2Cvalue%3A0)%2Ctime%3A(from%3Anow-3y%2Cto%3Anow))`; - +console.log({finalURL}) return ( {!editing ? ( diff --git a/apps/leafcutter/app/api/trends/recent/route.ts b/apps/leafcutter/app/api/trends/recent/_route.ts similarity index 100% rename from apps/leafcutter/app/api/trends/recent/route.ts rename to apps/leafcutter/app/api/trends/recent/_route.ts diff --git a/apps/leafcutter/app/api/visualizations/create/route.ts b/apps/leafcutter/app/api/visualizations/create/route.ts index c0b1a95..2e37509 100644 --- a/apps/leafcutter/app/api/visualizations/create/route.ts +++ b/apps/leafcutter/app/api/visualizations/create/route.ts @@ -3,7 +3,7 @@ import { getServerSession } from "next-auth"; import { authOptions } from "@/app/_lib/auth"; import { createUserVisualization } from "@/app/_lib/opensearch"; -export const POSt = async (req: NextRequest) => { +export const POST = async (req: NextRequest) => { const session = await getServerSession(authOptions); const { user: { email } }: any = session; const { visualizationID, title, description, query } = await req.json(); diff --git a/apps/leafcutter/app/api/visualizations/update/route.ts b/apps/leafcutter/app/api/visualizations/update/route.ts index ec4807a..4ffa08d 100644 --- a/apps/leafcutter/app/api/visualizations/update/route.ts +++ b/apps/leafcutter/app/api/visualizations/update/route.ts @@ -3,7 +3,7 @@ import { getServerSession } from "next-auth"; import { authOptions } from "@/app/_lib/auth"; import { updateUserVisualization } from "@/app/_lib/opensearch"; -const handler = async (req: NextRequest) => { +export const POST = async (req: NextRequest) => { const session = await getServerSession(authOptions); const { user: { email } }: any = session; const { id, title, description, query } = await req.json(); @@ -18,5 +18,4 @@ const handler = async (req: NextRequest) => { return NextResponse.json({ id }); }; -export default handler; diff --git a/apps/leafcutter/app/layout.tsx b/apps/leafcutter/app/layout.tsx index f317ecd..f9cc156 100644 --- a/apps/leafcutter/app/layout.tsx +++ b/apps/leafcutter/app/layout.tsx @@ -9,8 +9,6 @@ import "@fontsource/playfair-display/900.css"; // import getConfig from "next/config"; // import { LicenseInfo } from "@mui/x-data-grid-pro"; import { MultiProvider } from "app/_components/MultiProvider"; -import { InternalLayout } from "app/_components/InternalLayout"; -import { headers } from 'next/headers' export const metadata: Metadata = { title: "Leafcutter", @@ -21,8 +19,6 @@ type LayoutProps = { }; export default function Layout({ children }: LayoutProps) { - const allHeaders = headers(); - const embedded = Boolean(allHeaders.get('x-leafcutter-embedded')); // const { publicRuntimeConfig } = getConfig(); // LicenseInfo.setLicenseKey(publicRuntimeConfig.muiLicenseKey); @@ -30,7 +26,7 @@ export default function Layout({ children }: LayoutProps) { - {children} + {children} diff --git a/apps/link/app/admin/label-studio/_components/LabelStudioWrapper.tsx b/apps/link/app/admin/label-studio/_components/LabelStudioWrapper.tsx index e355132..369bb2a 100644 --- a/apps/link/app/admin/label-studio/_components/LabelStudioWrapper.tsx +++ b/apps/link/app/admin/label-studio/_components/LabelStudioWrapper.tsx @@ -1,3 +1,5 @@ +"use client"; + import { FC } from "react"; import { Grid } from "@mui/material"; import Iframe from "react-iframe"; diff --git a/apps/link/app/tickets/[id]/@detail/_components/TicketDetail.tsx b/apps/link/app/tickets/[id]/@detail/_components/TicketDetail.tsx index 74c3e9c..e424cb6 100644 --- a/apps/link/app/tickets/[id]/@detail/_components/TicketDetail.tsx +++ b/apps/link/app/tickets/[id]/@detail/_components/TicketDetail.tsx @@ -23,7 +23,7 @@ import { import { ArticleCreateDialog } from "./ArticleCreateDialog"; interface TicketDetailProps { - id: number; + id: string; } export const TicketDetail: FC = ({ id }) => {