App directory #4
This commit is contained in:
parent
69706053c6
commit
4d743c5e67
86 changed files with 223 additions and 107 deletions
3
.vscode/settings.json
vendored
Normal file
3
.vscode/settings.json
vendored
Normal file
|
|
@ -0,0 +1,3 @@
|
||||||
|
{
|
||||||
|
"prettier.prettierPath": ""
|
||||||
|
}
|
||||||
|
|
@ -17,6 +17,6 @@ type LayoutProps = {
|
||||||
export default function Layout({ children }: LayoutProps) {
|
export default function Layout({ children }: LayoutProps) {
|
||||||
const allHeaders = headers();
|
const allHeaders = headers();
|
||||||
const embedded = Boolean(allHeaders.get('x-leafcutter-embedded'));
|
const embedded = Boolean(allHeaders.get('x-leafcutter-embedded'));
|
||||||
console.log({embedded})
|
|
||||||
return <InternalLayout embedded={embedded}>{children}</InternalLayout>;
|
return <InternalLayout embedded={embedded}>{children}</InternalLayout>;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,5 @@
|
||||||
|
"use client";
|
||||||
|
|
||||||
import { FC } from "react";
|
import { FC } from "react";
|
||||||
/* eslint-disable no-underscore-dangle */
|
/* eslint-disable no-underscore-dangle */
|
||||||
import { RawDataViewer } from "@/app/_components/RawDataViewer";
|
import { RawDataViewer } from "@/app/_components/RawDataViewer";
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,13 @@
|
||||||
import { getSession } from "next-auth/react";
|
import { getServerSession } from "next-auth";
|
||||||
|
import { authOptions } from "app/_lib/auth";
|
||||||
import { getUserVisualizations } from "@/app/_lib/opensearch";
|
import { getUserVisualizations } from "@/app/_lib/opensearch";
|
||||||
import { Home } from "@/app/_components/Home";
|
import { Home } from "@/app/_components/Home";
|
||||||
|
|
||||||
export default async function Page() {
|
export default async function Page() {
|
||||||
const context = undefined;
|
const session = await getServerSession(authOptions);
|
||||||
const session = (await getSession(context)) ?? null;
|
const { user: { email } }: any = session;
|
||||||
const visualizations = await getUserVisualizations(
|
const visualizations = await getUserVisualizations(
|
||||||
session?.user?.email ?? "none",
|
email ?? "none",
|
||||||
20
|
20
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,5 @@
|
||||||
|
"use client";
|
||||||
|
|
||||||
import { FC, useEffect } from "react";
|
import { FC, useEffect } from "react";
|
||||||
import { CircularProgress, Typography, Grid } from "@mui/material";
|
import { CircularProgress, Typography, Grid } from "@mui/material";
|
||||||
import { signIn, signOut, getSession } from "next-auth/react";
|
import { signIn, signOut, getSession } from "next-auth/react";
|
||||||
|
|
@ -1,7 +1,9 @@
|
||||||
|
"use client";
|
||||||
|
|
||||||
import { FC, PropsWithChildren, useEffect } from "react";
|
import { FC, PropsWithChildren, useEffect } from "react";
|
||||||
import { CircularProgress } from "@mui/material";
|
import { CircularProgress } from "@mui/material";
|
||||||
import { useSession } from "next-auth/react";
|
import { useSession } from "next-auth/react";
|
||||||
import { useRouter } from "next/router";
|
import { useRouter } from "next/navigation";
|
||||||
|
|
||||||
export const Auth: FC<PropsWithChildren> = ({ children }) => {
|
export const Auth: FC<PropsWithChildren> = ({ children }) => {
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
|
|
@ -1,3 +1,5 @@
|
||||||
|
"use client";
|
||||||
|
|
||||||
/* eslint-disable react/display-name */
|
/* eslint-disable react/display-name */
|
||||||
import { forwardRef } from "react";
|
import { forwardRef } from "react";
|
||||||
import useDigitInput, { InputAttributes } from "react-digit-input";
|
import useDigitInput, { InputAttributes } from "react-digit-input";
|
||||||
|
|
@ -1,12 +1,14 @@
|
||||||
|
"use client";
|
||||||
|
|
||||||
import { FC, useEffect, useState } from "react";
|
import { FC, useEffect, useState } from "react";
|
||||||
import { Admin, Resource } from "react-admin";
|
import { Admin, Resource } from "react-admin";
|
||||||
import { useApolloClient } from "@apollo/client";
|
import { useApolloClient } from "@apollo/client";
|
||||||
import polyglotI18nProvider from "ra-i18n-polyglot";
|
import polyglotI18nProvider from "ra-i18n-polyglot";
|
||||||
import { ThemeProvider, createTheme } from "@mui/material";
|
import { ThemeProvider, createTheme } from "@mui/material";
|
||||||
import { metamigoDataProvider } from "../lib/dataprovider";
|
import { metamigoDataProvider } from "../_lib/dataprovider";
|
||||||
import { theme } from "./layout/themes";
|
import { theme } from "./layout/themes";
|
||||||
import { Layout } from "./layout";
|
import { Layout } from "./layout";
|
||||||
import englishMessages from "../i18n/en";
|
import englishMessages from "../_i18n/en";
|
||||||
import users from "./users";
|
import users from "./users";
|
||||||
import accounts from "./accounts";
|
import accounts from "./accounts";
|
||||||
import whatsappBots from "./whatsapp/bots";
|
import whatsappBots from "./whatsapp/bots";
|
||||||
8
apps/metamigo-frontend/app/_components/MultiProvider.tsx
Normal file
8
apps/metamigo-frontend/app/_components/MultiProvider.tsx
Normal file
|
|
@ -0,0 +1,8 @@
|
||||||
|
"use client";
|
||||||
|
|
||||||
|
import { FC, PropsWithChildren } from "react";
|
||||||
|
import { SessionProvider } from "next-auth/react";
|
||||||
|
|
||||||
|
export const MultiProvider: FC<PropsWithChildren> = ({ children }) => (
|
||||||
|
<SessionProvider>{children}</SessionProvider>
|
||||||
|
);
|
||||||
|
|
@ -1,3 +1,5 @@
|
||||||
|
"use client";
|
||||||
|
|
||||||
import { FC } from "react";
|
import { FC } from "react";
|
||||||
import { makeStyles } from "@mui/styles";
|
import { makeStyles } from "@mui/styles";
|
||||||
import {
|
import {
|
||||||
|
|
@ -1,3 +1,5 @@
|
||||||
|
"use client";
|
||||||
|
|
||||||
import { FC } from "react";
|
import { FC } from "react";
|
||||||
import {
|
import {
|
||||||
List,
|
List,
|
||||||
|
|
@ -1,3 +1,5 @@
|
||||||
|
"use client";
|
||||||
|
|
||||||
/* eslint-disable import/no-named-as-default */
|
/* eslint-disable import/no-named-as-default */
|
||||||
/* eslint-disable import/no-anonymous-default-export */
|
/* eslint-disable import/no-anonymous-default-export */
|
||||||
import AccountIcon from "@mui/icons-material/AccountTree";
|
import AccountIcon from "@mui/icons-material/AccountTree";
|
||||||
|
|
@ -1,3 +1,5 @@
|
||||||
|
"use client";
|
||||||
|
|
||||||
import { forwardRef } from "react";
|
import { forwardRef } from "react";
|
||||||
import { AppBar, UserMenu, MenuItemLink, useTranslate } from "react-admin";
|
import { AppBar, UserMenu, MenuItemLink, useTranslate } from "react-admin";
|
||||||
import Typography from "@mui/material/Typography";
|
import Typography from "@mui/material/Typography";
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
/* eslint-disable import/no-named-as-default */
|
"use client";
|
||||||
|
|
||||||
import { Layout as RaLayout, LayoutProps, Sidebar } from "react-admin";
|
import { Layout as RaLayout, LayoutProps, Sidebar } from "react-admin";
|
||||||
import AppBar from "./AppBar";
|
import AppBar from "./AppBar";
|
||||||
import Menu from "./Menu";
|
import Menu from "./Menu";
|
||||||
|
|
@ -6,7 +7,7 @@ import { theme } from "./themes";
|
||||||
|
|
||||||
const CustomSidebar = (props: any) => <Sidebar {...props} size={200} />;
|
const CustomSidebar = (props: any) => <Sidebar {...props} size={200} />;
|
||||||
|
|
||||||
const Layout = (props: LayoutProps) => (
|
export const Layout = (props: LayoutProps) => (
|
||||||
<RaLayout
|
<RaLayout
|
||||||
{...props}
|
{...props}
|
||||||
appBar={AppBar}
|
appBar={AppBar}
|
||||||
|
|
@ -16,5 +17,3 @@ const Layout = (props: LayoutProps) => (
|
||||||
theme={theme}
|
theme={theme}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
|
|
||||||
export default Layout;
|
|
||||||
|
|
@ -1,3 +1,5 @@
|
||||||
|
"use client";
|
||||||
|
|
||||||
import { SVGProps } from "react";
|
import { SVGProps } from "react";
|
||||||
|
|
||||||
const Logo = (props: SVGProps<SVGSVGElement>) => (
|
const Logo = (props: SVGProps<SVGSVGElement>) => (
|
||||||
|
|
@ -1,3 +1,5 @@
|
||||||
|
"use client";
|
||||||
|
|
||||||
/* eslint-disable camelcase */
|
/* eslint-disable camelcase */
|
||||||
import { FC, useState } from "react";
|
import { FC, useState } from "react";
|
||||||
// import { useSelector } from "react-redux";
|
// import { useSelector } from "react-redux";
|
||||||
|
|
@ -1,3 +1,5 @@
|
||||||
|
"use client";
|
||||||
|
|
||||||
import { FC, PropsWithChildren, Fragment, ReactElement } from "react";
|
import { FC, PropsWithChildren, Fragment, ReactElement } from "react";
|
||||||
import ExpandMore from "@mui/icons-material/ExpandMore";
|
import ExpandMore from "@mui/icons-material/ExpandMore";
|
||||||
import List from "@mui/material/List";
|
import List from "@mui/material/List";
|
||||||
|
|
@ -1,3 +1,5 @@
|
||||||
|
"use client";
|
||||||
|
|
||||||
export { default as AppBar } from "./AppBar";
|
export { default as AppBar } from "./AppBar";
|
||||||
export { default as Layout } from "./Layout";
|
export { Layout } from "./Layout";
|
||||||
export { default as Menu } from "./Menu";
|
export { default as Menu } from "./Menu";
|
||||||
|
|
@ -1,3 +1,5 @@
|
||||||
|
"use client";
|
||||||
|
|
||||||
import {
|
import {
|
||||||
SimpleForm,
|
SimpleForm,
|
||||||
Create,
|
Create,
|
||||||
|
|
@ -6,7 +8,7 @@ import {
|
||||||
CreateProps,
|
CreateProps,
|
||||||
} from "react-admin";
|
} from "react-admin";
|
||||||
import { useSession } from "next-auth/react";
|
import { useSession } from "next-auth/react";
|
||||||
import { validateE164Number } from "../../../lib/phone-numbers";
|
import { validateE164Number } from "../../../_lib/phone-numbers";
|
||||||
|
|
||||||
const SignalBotCreate = (props: CreateProps) => {
|
const SignalBotCreate = (props: CreateProps) => {
|
||||||
const { data: session } = useSession();
|
const { data: session } = useSession();
|
||||||
|
|
@ -1,3 +1,5 @@
|
||||||
|
"use client";
|
||||||
|
|
||||||
import { SimpleForm, Edit, TextInput, required, EditProps } from "react-admin";
|
import { SimpleForm, Edit, TextInput, required, EditProps } from "react-admin";
|
||||||
|
|
||||||
const SignalBotEdit = (props: EditProps) => (
|
const SignalBotEdit = (props: EditProps) => (
|
||||||
|
|
@ -1,3 +1,5 @@
|
||||||
|
"use client";
|
||||||
|
|
||||||
import {
|
import {
|
||||||
List,
|
List,
|
||||||
Datagrid,
|
Datagrid,
|
||||||
|
|
@ -1,3 +1,5 @@
|
||||||
|
"use client";
|
||||||
|
|
||||||
import React, { useState } from "react";
|
import React, { useState } from "react";
|
||||||
import {
|
import {
|
||||||
Show,
|
Show,
|
||||||
|
|
@ -28,7 +30,7 @@ import { SixDigitInput } from "../../DigitInput";
|
||||||
import {
|
import {
|
||||||
sanitizeE164Number,
|
sanitizeE164Number,
|
||||||
isValidE164Number,
|
isValidE164Number,
|
||||||
} from "../../../lib/phone-numbers";
|
} from "../../../_lib/phone-numbers";
|
||||||
|
|
||||||
const Sidebar = ({ record }: any) => {
|
const Sidebar = ({ record }: any) => {
|
||||||
const [phoneNumber, setPhoneNumber] = useState("");
|
const [phoneNumber, setPhoneNumber] = useState("");
|
||||||
|
|
@ -1,3 +1,5 @@
|
||||||
|
"use client";
|
||||||
|
|
||||||
import SignalBotIcon from "@mui/icons-material/ChatOutlined";
|
import SignalBotIcon from "@mui/icons-material/ChatOutlined";
|
||||||
import SignalBotList from "./SignalBotList";
|
import SignalBotList from "./SignalBotList";
|
||||||
import SignalBotEdit from "./SignalBotEdit";
|
import SignalBotEdit from "./SignalBotEdit";
|
||||||
|
|
@ -1,3 +1,5 @@
|
||||||
|
"use client";
|
||||||
|
|
||||||
/* eslint-disable react/display-name */
|
/* eslint-disable react/display-name */
|
||||||
import {
|
import {
|
||||||
SelectInput,
|
SelectInput,
|
||||||
|
|
@ -1,3 +1,5 @@
|
||||||
|
"use client";
|
||||||
|
|
||||||
import { FC } from "react";
|
import { FC } from "react";
|
||||||
import {
|
import {
|
||||||
SimpleForm,
|
SimpleForm,
|
||||||
|
|
@ -1,3 +1,5 @@
|
||||||
|
"use client";
|
||||||
|
|
||||||
import { makeStyles } from "@mui/styles";
|
import { makeStyles } from "@mui/styles";
|
||||||
import {
|
import {
|
||||||
SimpleForm,
|
SimpleForm,
|
||||||
|
|
@ -1,3 +1,5 @@
|
||||||
|
"use client";
|
||||||
|
|
||||||
import {
|
import {
|
||||||
List,
|
List,
|
||||||
Datagrid,
|
Datagrid,
|
||||||
|
|
@ -1,3 +1,5 @@
|
||||||
|
"use client";
|
||||||
|
|
||||||
import UserIcon from "@mui/icons-material/People";
|
import UserIcon from "@mui/icons-material/People";
|
||||||
import UserList from "./UserList";
|
import UserList from "./UserList";
|
||||||
import UserEdit from "./UserEdit";
|
import UserEdit from "./UserEdit";
|
||||||
|
|
@ -1,3 +1,5 @@
|
||||||
|
"use client";
|
||||||
|
|
||||||
import { SelectInput, useRecordContext } from "react-admin";
|
import { SelectInput, useRecordContext } from "react-admin";
|
||||||
|
|
||||||
export const UserRoleInput = (props: any) => {
|
export const UserRoleInput = (props: any) => {
|
||||||
|
|
@ -1,3 +1,5 @@
|
||||||
|
"use client";
|
||||||
|
|
||||||
import {
|
import {
|
||||||
SimpleForm,
|
SimpleForm,
|
||||||
TextInput,
|
TextInput,
|
||||||
|
|
@ -1,3 +1,5 @@
|
||||||
|
"use client";
|
||||||
|
|
||||||
import {
|
import {
|
||||||
SimpleForm,
|
SimpleForm,
|
||||||
TextInput,
|
TextInput,
|
||||||
|
|
@ -1,3 +1,5 @@
|
||||||
|
"use client";
|
||||||
|
|
||||||
import { List, Datagrid, DateField, TextField, ListProps } from "react-admin";
|
import { List, Datagrid, DateField, TextField, ListProps } from "react-admin";
|
||||||
|
|
||||||
const ProviderList = (props: ListProps) => (
|
const ProviderList = (props: ListProps) => (
|
||||||
|
|
@ -1,3 +1,5 @@
|
||||||
|
"use client";
|
||||||
|
|
||||||
/* eslint-disable import/no-anonymous-default-export */
|
/* eslint-disable import/no-anonymous-default-export */
|
||||||
import ProviderIcon from "@mui/icons-material/Business";
|
import ProviderIcon from "@mui/icons-material/Business";
|
||||||
import ProviderList from "./ProviderList";
|
import ProviderList from "./ProviderList";
|
||||||
|
|
@ -1,3 +1,5 @@
|
||||||
|
"use client";
|
||||||
|
|
||||||
import { SelectInput } from "react-admin";
|
import { SelectInput } from "react-admin";
|
||||||
|
|
||||||
export const ProviderKindInput = (props: any) => (
|
export const ProviderKindInput = (props: any) => (
|
||||||
|
|
@ -1,3 +1,5 @@
|
||||||
|
"use client";
|
||||||
|
|
||||||
import { useInput } from "react-admin";
|
import { useInput } from "react-admin";
|
||||||
import React, { useState } from "react";
|
import React, { useState } from "react";
|
||||||
import dynamic from "next/dynamic";
|
import dynamic from "next/dynamic";
|
||||||
|
|
@ -1,3 +1,5 @@
|
||||||
|
"use client";
|
||||||
|
|
||||||
import {
|
import {
|
||||||
SimpleForm,
|
SimpleForm,
|
||||||
Create,
|
Create,
|
||||||
|
|
@ -1,3 +1,5 @@
|
||||||
|
"use client";
|
||||||
|
|
||||||
import {
|
import {
|
||||||
SimpleForm,
|
SimpleForm,
|
||||||
TextInput,
|
TextInput,
|
||||||
|
|
@ -1,3 +1,5 @@
|
||||||
|
"use client";
|
||||||
|
|
||||||
import {
|
import {
|
||||||
List,
|
List,
|
||||||
ListProps,
|
ListProps,
|
||||||
|
|
@ -1,3 +1,5 @@
|
||||||
|
"use client";
|
||||||
|
|
||||||
import VoiceLineIcon from "@mui/icons-material/PhoneCallback";
|
import VoiceLineIcon from "@mui/icons-material/PhoneCallback";
|
||||||
import VoiceLineList from "./VoiceLineList";
|
import VoiceLineList from "./VoiceLineList";
|
||||||
import VoiceLineEdit from "./VoiceLineEdit";
|
import VoiceLineEdit from "./VoiceLineEdit";
|
||||||
|
|
@ -1,3 +1,5 @@
|
||||||
|
"use client";
|
||||||
|
|
||||||
/* eslint-disable react/display-name */
|
/* eslint-disable react/display-name */
|
||||||
import React, { useState, useEffect } from "react";
|
import React, { useState, useEffect } from "react";
|
||||||
import PlayIcon from "@mui/icons-material/PlayCircleFilled";
|
import PlayIcon from "@mui/icons-material/PlayCircleFilled";
|
||||||
|
|
@ -12,7 +14,7 @@ import {
|
||||||
TextField,
|
TextField,
|
||||||
} from "react-admin";
|
} from "react-admin";
|
||||||
import { IconButton, CircularProgress } from "@mui/material";
|
import { IconButton, CircularProgress } from "@mui/material";
|
||||||
import absoluteUrl from "../../../lib/absolute-url";
|
import absoluteUrl from "../../../_lib/absolute-url";
|
||||||
import TwilioLanguages from "./twilio-languages";
|
import TwilioLanguages from "./twilio-languages";
|
||||||
|
|
||||||
type TTSProvider = (voice: any, language: any, prompt: any) => Promise<void>;
|
type TTSProvider = (voice: any, language: any, prompt: any) => Promise<void>;
|
||||||
|
|
@ -1,3 +1,5 @@
|
||||||
|
"use client";
|
||||||
|
|
||||||
import {
|
import {
|
||||||
SimpleForm,
|
SimpleForm,
|
||||||
FormDataConsumer,
|
FormDataConsumer,
|
||||||
|
|
@ -1,3 +1,5 @@
|
||||||
|
"use client";
|
||||||
|
|
||||||
import {
|
import {
|
||||||
SimpleForm,
|
SimpleForm,
|
||||||
TextInput,
|
TextInput,
|
||||||
|
|
@ -1,3 +1,5 @@
|
||||||
|
"use client";
|
||||||
|
|
||||||
import { List, Datagrid, DateField, TextField, ListProps } from "react-admin";
|
import { List, Datagrid, DateField, TextField, ListProps } from "react-admin";
|
||||||
import { BackendIdField } from "./shared";
|
import { BackendIdField } from "./shared";
|
||||||
|
|
||||||
|
|
@ -1,3 +1,5 @@
|
||||||
|
"use client";
|
||||||
|
|
||||||
import WebhookIcon from "@mui/icons-material/Send";
|
import WebhookIcon from "@mui/icons-material/Send";
|
||||||
import WebhookList from "./WebhookList";
|
import WebhookList from "./WebhookList";
|
||||||
import WebhookEdit from "./WebhookEdit";
|
import WebhookEdit from "./WebhookEdit";
|
||||||
|
|
@ -1,3 +1,5 @@
|
||||||
|
"use client";
|
||||||
|
|
||||||
import { SelectInput, required } from "react-admin";
|
import { SelectInput, required } from "react-admin";
|
||||||
|
|
||||||
import {
|
import {
|
||||||
|
|
@ -1,3 +1,5 @@
|
||||||
|
"use client";
|
||||||
|
|
||||||
import { List, Datagrid, TextField } from "react-admin";
|
import { List, Datagrid, TextField } from "react-admin";
|
||||||
|
|
||||||
const WhatsappAttachmentList = (props: any) => (
|
const WhatsappAttachmentList = (props: any) => (
|
||||||
|
|
@ -1,3 +1,5 @@
|
||||||
|
"use client";
|
||||||
|
|
||||||
import { Show, ShowProps, SimpleShowLayout, TextField } from "react-admin";
|
import { Show, ShowProps, SimpleShowLayout, TextField } from "react-admin";
|
||||||
|
|
||||||
const WhatsappAttachmentShow = (props: ShowProps) => (
|
const WhatsappAttachmentShow = (props: ShowProps) => (
|
||||||
|
|
@ -1,3 +1,5 @@
|
||||||
|
"use client";
|
||||||
|
|
||||||
import WhatsappAttachmentIcon from "@mui/icons-material/AttachFile";
|
import WhatsappAttachmentIcon from "@mui/icons-material/AttachFile";
|
||||||
import WhatsappAttachmentList from "./WhatsappAttachmentList";
|
import WhatsappAttachmentList from "./WhatsappAttachmentList";
|
||||||
import WhatsappAttachmentShow from "./WhatsappAttachmentShow";
|
import WhatsappAttachmentShow from "./WhatsappAttachmentShow";
|
||||||
|
|
@ -1,7 +1,9 @@
|
||||||
|
"use client";
|
||||||
|
|
||||||
// import dynamic from "next/dynamic";
|
// import dynamic from "next/dynamic";
|
||||||
import { SimpleForm, Create, TextInput, required } from "react-admin";
|
import { SimpleForm, Create, TextInput, required } from "react-admin";
|
||||||
import { useSession } from "next-auth/react";
|
import { useSession } from "next-auth/react";
|
||||||
import { validateE164Number } from "../../../lib/phone-numbers";
|
import { validateE164Number } from "../../../_lib/phone-numbers";
|
||||||
|
|
||||||
const WhatsappBotCreate = (props: any) => {
|
const WhatsappBotCreate = (props: any) => {
|
||||||
// const MuiPhoneNumber = dynamic(() => import("material-ui-phone-number"), {
|
// const MuiPhoneNumber = dynamic(() => import("material-ui-phone-number"), {
|
||||||
|
|
@ -1,3 +1,5 @@
|
||||||
|
"use client";
|
||||||
|
|
||||||
import { SimpleForm, Edit, TextInput, required, EditProps } from "react-admin";
|
import { SimpleForm, Edit, TextInput, required, EditProps } from "react-admin";
|
||||||
|
|
||||||
const WhatsappBotEdit = (props: EditProps) => (
|
const WhatsappBotEdit = (props: EditProps) => (
|
||||||
|
|
@ -1,3 +1,5 @@
|
||||||
|
"use client";
|
||||||
|
|
||||||
import {
|
import {
|
||||||
List,
|
List,
|
||||||
Datagrid,
|
Datagrid,
|
||||||
|
|
@ -1,3 +1,5 @@
|
||||||
|
"use client";
|
||||||
|
|
||||||
import React, { useEffect, useState } from "react";
|
import React, { useEffect, useState } from "react";
|
||||||
import {
|
import {
|
||||||
Card,
|
Card,
|
||||||
|
|
@ -1,3 +1,5 @@
|
||||||
|
"use client";
|
||||||
|
|
||||||
import WhatsappBotIcon from "@mui/icons-material/WhatsApp";
|
import WhatsappBotIcon from "@mui/icons-material/WhatsApp";
|
||||||
import WhatsappBotList from "./WhatsappBotList";
|
import WhatsappBotList from "./WhatsappBotList";
|
||||||
import WhatsappBotEdit from "./WhatsappBotEdit";
|
import WhatsappBotEdit from "./WhatsappBotEdit";
|
||||||
|
|
@ -1,3 +1,5 @@
|
||||||
|
"use client";
|
||||||
|
|
||||||
/* eslint-disable react/display-name */
|
/* eslint-disable react/display-name */
|
||||||
import {
|
import {
|
||||||
SelectInput,
|
SelectInput,
|
||||||
|
|
@ -1,3 +1,5 @@
|
||||||
|
"use client";
|
||||||
|
|
||||||
import {
|
import {
|
||||||
List,
|
List,
|
||||||
ListProps,
|
ListProps,
|
||||||
|
|
@ -1,3 +1,5 @@
|
||||||
|
"use client";
|
||||||
|
|
||||||
import {
|
import {
|
||||||
Show,
|
Show,
|
||||||
ShowProps,
|
ShowProps,
|
||||||
|
|
@ -1,3 +1,5 @@
|
||||||
|
"use client";
|
||||||
|
|
||||||
import WhatsappMessageIcon from "@mui/icons-material/Message";
|
import WhatsappMessageIcon from "@mui/icons-material/Message";
|
||||||
import WhatsappMessageList from "./WhatsappMessageList";
|
import WhatsappMessageList from "./WhatsappMessageList";
|
||||||
import WhatsappMessageShow from "./WhatsappMessageShow";
|
import WhatsappMessageShow from "./WhatsappMessageShow";
|
||||||
16
apps/metamigo-frontend/app/admin/_components/Admin.tsx
Normal file
16
apps/metamigo-frontend/app/admin/_components/Admin.tsx
Normal file
|
|
@ -0,0 +1,16 @@
|
||||||
|
"use client";
|
||||||
|
|
||||||
|
import { FC } from "react";
|
||||||
|
import { ApolloProvider } from "@apollo/client";
|
||||||
|
import { apolloClient } from "app/_lib/apollo-client";
|
||||||
|
import dynamic from "next/dynamic";
|
||||||
|
|
||||||
|
const MetamigoAdmin = dynamic(() => import("app/_components/MetamigoAdmin"), {
|
||||||
|
ssr: false,
|
||||||
|
});
|
||||||
|
|
||||||
|
export const Admin:FC = () => (
|
||||||
|
<ApolloProvider client={apolloClient}>
|
||||||
|
<MetamigoAdmin />
|
||||||
|
</ApolloProvider>
|
||||||
|
);
|
||||||
5
apps/metamigo-frontend/app/admin/page.tsx
Normal file
5
apps/metamigo-frontend/app/admin/page.tsx
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
import { Admin } from "./_components/Admin";
|
||||||
|
|
||||||
|
export default function Home() {
|
||||||
|
return <Admin />
|
||||||
|
}
|
||||||
|
|
@ -1,14 +1,14 @@
|
||||||
import { NextApiRequest, NextApiResponse } from "next";
|
import { NextRequest } from "next/server";
|
||||||
import NextAuth from "next-auth";
|
import NextAuth from "next-auth";
|
||||||
import Google from "next-auth/providers/google";
|
import Google from "next-auth/providers/google";
|
||||||
import GitHub from "next-auth/providers/github";
|
import GitHub from "next-auth/providers/github";
|
||||||
import GitLab from "next-auth/providers/gitlab";
|
import GitLab from "next-auth/providers/gitlab";
|
||||||
import Cognito from "next-auth/providers/cognito";
|
import Cognito from "next-auth/providers/cognito";
|
||||||
import { loadConfig, IAppConfig } from "@digiresilience/metamigo-config";
|
import { loadConfig, IAppConfig } from "@digiresilience/metamigo-config";
|
||||||
import { MetamigoAdapter } from "../../../lib/nextauth-adapter";
|
import { MetamigoAdapter } from "app/_lib/nextauth-adapter";
|
||||||
import { CloudflareAccessProvider } from "../../../lib/cloudflare";
|
import { CloudflareAccessProvider } from "app/_lib/cloudflare";
|
||||||
|
|
||||||
const nextAuthOptions = (config: IAppConfig, req: NextApiRequest) => {
|
const nextAuthOptions = (config: IAppConfig, req: NextRequest) => {
|
||||||
const { nextAuth, cfaccess } = config;
|
const { nextAuth, cfaccess } = config;
|
||||||
const adapter = MetamigoAdapter(config);
|
const adapter = MetamigoAdapter(config);
|
||||||
const providers = [];
|
const providers = [];
|
||||||
|
|
@ -16,7 +16,7 @@ const nextAuthOptions = (config: IAppConfig, req: NextApiRequest) => {
|
||||||
const { audience, domain } = cfaccess;
|
const { audience, domain } = cfaccess;
|
||||||
const cloudflareAccessEnabled = audience && domain;
|
const cloudflareAccessEnabled = audience && domain;
|
||||||
if (cloudflareAccessEnabled)
|
if (cloudflareAccessEnabled)
|
||||||
providers.push(CloudflareAccessProvider(audience, domain, adapter, req));
|
providers.push(CloudflareAccessProvider(audience, domain, adapter, req as any));
|
||||||
else {
|
else {
|
||||||
if (nextAuth.google?.id)
|
if (nextAuth.google?.id)
|
||||||
providers.push(
|
providers.push(
|
||||||
|
|
@ -78,11 +78,11 @@ const nextAuthOptions = (config: IAppConfig, req: NextApiRequest) => {
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
const nextAuth = async (
|
const handler = async (req: NextRequest) => {
|
||||||
req: NextApiRequest,
|
const config = await loadConfig();
|
||||||
res: NextApiResponse
|
const authOptions = nextAuthOptions(config, req);
|
||||||
): Promise<void> =>
|
// @ts-expect-error: non-existent property
|
||||||
// @ts-expect-error: Type mismatch
|
return NextAuth(authOptions)(req);
|
||||||
NextAuth(req, res, nextAuthOptions(await loadConfig(), req));
|
};
|
||||||
|
|
||||||
export default nextAuth;
|
export { handler as GET, handler as POST };
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
import { createProxyMiddleware } from "http-proxy-middleware";
|
import { createProxyMiddleware } from "http-proxy-middleware";
|
||||||
|
|
||||||
export default createProxyMiddleware({
|
export const POST = createProxyMiddleware({
|
||||||
target:
|
target:
|
||||||
process.env.NODE_ENV === "production"
|
process.env.NODE_ENV === "production"
|
||||||
? "http://metamigo-api:3001"
|
? "http://metamigo-api:3001"
|
||||||
|
|
@ -28,9 +28,3 @@ export default createProxyMiddleware({
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
export const config = {
|
|
||||||
api: {
|
|
||||||
bodyParser: false,
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
import { createProxyMiddleware } from "http-proxy-middleware";
|
import { createProxyMiddleware } from "http-proxy-middleware";
|
||||||
|
|
||||||
export default createProxyMiddleware({
|
const handler = createProxyMiddleware({
|
||||||
target:
|
target:
|
||||||
process.env.NODE_ENV === "production"
|
process.env.NODE_ENV === "production"
|
||||||
? "http://metamigo-api:3001"
|
? "http://metamigo-api:3001"
|
||||||
|
|
@ -30,8 +30,4 @@ export default createProxyMiddleware({
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
export const config = {
|
export { handler as GET, handler as POST, handler as PUT, handler as DELETE};
|
||||||
api: {
|
|
||||||
bodyParser: false,
|
|
||||||
},
|
|
||||||
};
|
|
||||||
20
apps/metamigo-frontend/app/layout.tsx
Normal file
20
apps/metamigo-frontend/app/layout.tsx
Normal file
|
|
@ -0,0 +1,20 @@
|
||||||
|
import { ReactNode } from "react";
|
||||||
|
import "app/_styles/globals.css";
|
||||||
|
import { MultiProvider } from "./_components/MultiProvider";
|
||||||
|
|
||||||
|
type LayoutProps = {
|
||||||
|
children: ReactNode;
|
||||||
|
}
|
||||||
|
|
||||||
|
export default function Layout({ children }: LayoutProps) {
|
||||||
|
return (
|
||||||
|
<html lang="en">
|
||||||
|
<body>
|
||||||
|
<MultiProvider>
|
||||||
|
{children}
|
||||||
|
</MultiProvider>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
@ -1,8 +1,10 @@
|
||||||
|
"use client";
|
||||||
|
|
||||||
import { FC } from "react";
|
import { FC } from "react";
|
||||||
import { Button } from "@mui/material";
|
import { Button } from "@mui/material";
|
||||||
import { signIn, signOut, useSession } from "next-auth/react";
|
import { signIn, signOut, useSession } from "next-auth/react";
|
||||||
|
|
||||||
const MyComponent: FC = () => {
|
export const Login: FC = () => {
|
||||||
const { data: session } = useSession();
|
const { data: session } = useSession();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|
@ -26,5 +28,3 @@ const MyComponent: FC = () => {
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
export default MyComponent;
|
|
||||||
5
apps/metamigo-frontend/app/login/page.tsx
Normal file
5
apps/metamigo-frontend/app/login/page.tsx
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
import { Login } from "./_components/Login";
|
||||||
|
|
||||||
|
export default function Page() {
|
||||||
|
return <Login />;
|
||||||
|
}
|
||||||
3
apps/metamigo-frontend/app/page.tsx
Normal file
3
apps/metamigo-frontend/app/page.tsx
Normal file
|
|
@ -0,0 +1,3 @@
|
||||||
|
export default function Page() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
@ -1,13 +0,0 @@
|
||||||
import "../styles/globals.css";
|
|
||||||
import { AppProps } from "next/app";
|
|
||||||
import { SessionProvider } from "next-auth/react";
|
|
||||||
|
|
||||||
function MetamigoStarter({ Component, pageProps }: AppProps) {
|
|
||||||
return (
|
|
||||||
<SessionProvider session={(pageProps as any).session}>
|
|
||||||
<Component {...pageProps} />
|
|
||||||
</SessionProvider>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
export default MetamigoStarter;
|
|
||||||
|
|
@ -1,15 +0,0 @@
|
||||||
import { ApolloProvider } from "@apollo/client";
|
|
||||||
import { apolloClient } from "../lib/apollo-client";
|
|
||||||
import dynamic from "next/dynamic";
|
|
||||||
|
|
||||||
const MetamigoAdmin = dynamic(() => import("../components/MetamigoAdmin"), {
|
|
||||||
ssr: false,
|
|
||||||
});
|
|
||||||
|
|
||||||
export default function Home() {
|
|
||||||
return (
|
|
||||||
<ApolloProvider client={apolloClient}>
|
|
||||||
<MetamigoAdmin />
|
|
||||||
</ApolloProvider>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
@ -1,29 +0,0 @@
|
||||||
import { NextPage } from "next";
|
|
||||||
import { Typography, Box, Button, Grid, Link } from "@mui/material";
|
|
||||||
import { FC, useEffect, PropsWithChildren } from "react";
|
|
||||||
import { useRouter } from "next/router";
|
|
||||||
|
|
||||||
export const RedirectToAdmin: FC<PropsWithChildren> = ({ children }) => {
|
|
||||||
const router = useRouter();
|
|
||||||
useEffect(() => {
|
|
||||||
router.push("/admin");
|
|
||||||
});
|
|
||||||
|
|
||||||
return <>{children}</>;
|
|
||||||
};
|
|
||||||
|
|
||||||
const Home: NextPage = () => (
|
|
||||||
<Box>
|
|
||||||
<Typography variant="h3">Metamigo</Typography>
|
|
||||||
<Grid container justifyContent="space-around" style={{ padding: 60 }}>
|
|
||||||
<Grid item>
|
|
||||||
<Link href="/admin">
|
|
||||||
<Button variant="contained">Admin</Button>
|
|
||||||
<RedirectToAdmin />
|
|
||||||
</Link>
|
|
||||||
</Grid>
|
|
||||||
</Grid>
|
|
||||||
</Box>
|
|
||||||
);
|
|
||||||
|
|
||||||
export default Home;
|
|
||||||
|
|
@ -2,7 +2,11 @@
|
||||||
"extends": "tsconfig-link",
|
"extends": "tsconfig-link",
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"target": "es5",
|
"target": "es5",
|
||||||
"lib": ["dom", "dom.iterable", "esnext"],
|
"lib": [
|
||||||
|
"dom",
|
||||||
|
"dom.iterable",
|
||||||
|
"esnext"
|
||||||
|
],
|
||||||
"allowJs": true,
|
"allowJs": true,
|
||||||
"forceConsistentCasingInFileNames": true,
|
"forceConsistentCasingInFileNames": true,
|
||||||
"noEmit": true,
|
"noEmit": true,
|
||||||
|
|
@ -17,9 +21,24 @@
|
||||||
"strict": true,
|
"strict": true,
|
||||||
"baseUrl": ".",
|
"baseUrl": ".",
|
||||||
"paths": {
|
"paths": {
|
||||||
"@/*": ["./*", "../../node_modules/*"]
|
"@/*": [
|
||||||
}
|
"./*",
|
||||||
|
"../../node_modules/*"
|
||||||
|
]
|
||||||
},
|
},
|
||||||
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx"],
|
"plugins": [
|
||||||
"exclude": ["node_modules"]
|
{
|
||||||
|
"name": "next"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"include": [
|
||||||
|
"next-env.d.ts",
|
||||||
|
"**/*.ts",
|
||||||
|
"**/*.tsx",
|
||||||
|
".next/types/**/*.ts"
|
||||||
|
],
|
||||||
|
"exclude": [
|
||||||
|
"node_modules"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue