Update Bridge file layout

This commit is contained in:
Darren Clarke 2024-04-23 13:36:51 +02:00
parent 2c43e81436
commit b0fb643b6a
47 changed files with 2488 additions and 2087 deletions

View file

@ -1,7 +1,7 @@
"use client";
import { FC } from "react";
import { Grid, Box } from "@mui/material";
import { Grid, Box, Dialog } from "@mui/material";
import { useRouter } from "next/navigation";
import { typography } from "@/app/_styles/theme";
@ -16,15 +16,20 @@ export const Detail: FC<DetailProps> = ({ title, entity, children }) => {
const { h3 } = typography;
return (
<Box sx={{ height: "100vh", backgroundColor: "#ddd", p: 3 }}>
<Grid container direction="column">
<Grid item>
<Box sx={h3}>{title}</Box>
<Dialog
open={true}
onClose={() => router.push(`/${entity}`)}
fullScreen
sx={{ backgroundColor: "#ddd" }}
>
<Box sx={{ height: "100vh", backgroundColor: "#ddd", p: 3 }}>
<Grid container direction="column">
<Grid item>
<Box sx={h3}>{title}</Box>
</Grid>
<Grid item>{children}</Grid>
</Grid>
<Grid item>
{children}
</Grid>
</Grid>
</Box>
</Box>
</Dialog>
);
};

View file

@ -2,14 +2,10 @@
import { FC, PropsWithChildren, useState } from "react";
import { Grid } from "@mui/material";
import { Sidebar } from "./Sidebar";
import { CssBaseline } from "@mui/material";
import { css, Global } from "@emotion/react";
import { fonts } from "@/app/_styles/theme";
type LayoutProps = PropsWithChildren<{
docs?: any;
}>;
import { Sidebar } from "./Sidebar";
export const InternalLayout: FC<PropsWithChildren> = ({ children }) => {
const [open, setOpen] = useState(true);
@ -28,7 +24,7 @@ export const InternalLayout: FC<PropsWithChildren> = ({ children }) => {
<Sidebar open={open} setOpen={setOpen} />
<Grid
item
sx={{ ml: open ? "270px" : "100px", width: "100%", height: "100vh" }}
sx={{ ml: open ? "270px" : "70px", width: "100%", height: "100vh" }}
>
{children as any}
</Grid>

View file

@ -1,10 +1,9 @@
"use client";
import { FC } from "react";
import { Grid, Box } from "@mui/material";
import { DataGridPro, GridColDef } from "@mui/x-data-grid-pro";
import { GridColDef } from "@mui/x-data-grid-pro";
import { useRouter } from "next/navigation";
import { typography } from "@/app/_styles/theme";
import { List as InternalList } from "ui";
interface ListProps {
title: string;
@ -15,72 +14,17 @@ interface ListProps {
export const List: FC<ListProps> = ({ title, entity, rows, columns }) => {
const router = useRouter();
const { h3 } = typography;
const onRowClick = (id: string) => {
router.push(`/${entity}/${id}`);
};
return (
<Box sx={{ height: "100vh", backgroundColor: "#ddd", p: 3 }}>
<Grid container direction="column">
<Grid item>
<Box sx={h3}>{title}</Box>
</Grid>
<Grid item>
<Box
sx={{
backgroundColor: "#ddd",
border: 0,
width: "100%",
height: "100vh",
".MuiDataGrid-row": {
cursor: "pointer",
"&:hover": {
backgroundColor: "#1982fc33 !important",
fontWeight: "bold",
},
},
".MuiDataGrid-row:nth-of-type(1n)": {
backgroundColor: "#f3f3f3",
},
".MuiDataGrid-row:nth-of-type(2n)": {
backgroundColor: "#fff",
},
".MuiDataGrid-columnHeaderTitle": {
color: "#333",
fontWeight: "bold",
fontSize: 11,
margin: "0 auto",
},
".MuiDataGrid-columnHeader": {
backgroundColor: "#ccc",
border: 0,
borderBottom: "3px solid #ddd",
},
}}
>
<DataGridPro
rows={rows}
columns={columns}
density="compact"
pagination
initialState={{
pagination: { paginationModel: { pageSize: 25 } },
}}
pageSizeOptions={[5, 10, 25]}
paginationMode="client"
sx={{ height: "100vh" }}
// rowBuffer={30}
rowHeight={46}
scrollbarSize={0}
disableVirtualization
disableColumnMenu
onRowClick={(row: any) => onRowClick(row.id)}
/>
</Box>
</Grid>
</Grid>
</Box>
<InternalList
title={title}
rows={rows}
columns={columns}
onRowClick={onRowClick}
/>
);
};

View file

@ -0,0 +1,184 @@
"use client";
import { FC, useState } from "react";
import {
Box,
Grid,
Container,
IconButton,
Typography,
TextField,
} from "@mui/material";
import {
Apple as AppleIcon,
Google as GoogleIcon,
Key as KeyIcon,
} from "@mui/icons-material";
import { signIn } from "next-auth/react";
import Image from "next/image";
import LinkLogo from "@/app/../public/link-logo-small.png";
import { colors } from "@/app/_styles/theme";
import { useSearchParams } from "next/navigation";
type LoginProps = {
session: any;
};
export const Login: FC<LoginProps> = ({ session }) => {
const origin =
typeof window !== "undefined" && window.location.origin
? window.location.origin
: "";
const [email, setEmail] = useState("");
const [password, setPassword] = useState("");
const params = useSearchParams();
const error = params.get("error");
const { darkGray, cdrLinkOrange, white } = colors;
const buttonStyles = {
borderRadius: 500,
width: "100%",
fontSize: "16px",
fontWeight: "bold",
backgroundColor: white,
"&:hover": {
color: white,
backgroundColor: cdrLinkOrange,
},
};
const fieldStyles = {
"& label.Mui-focused": {
color: cdrLinkOrange,
},
"& .MuiInput-underline:after": {
borderBottomColor: cdrLinkOrange,
},
"& .MuiFilledInput-underline:after": {
borderBottomColor: cdrLinkOrange,
},
"& .MuiOutlinedInput-root": {
"&.Mui-focused fieldset": {
borderColor: cdrLinkOrange,
},
},
};
return (
<Box sx={{ backgroundColor: darkGray, height: "100vh" }}>
<Container maxWidth="md" sx={{ p: 10 }}>
<Grid container spacing={2} direction="column" alignItems="center">
<Grid
item
container
direction="row"
justifyContent="center"
alignItems="center"
>
<Grid item>
<Box
sx={{
width: "70px",
height: "70px",
margin: "0 auto",
}}
>
<Image
src={LinkLogo}
alt="Link logo"
width={70}
height={70}
style={{
objectFit: "cover",
filter: "grayscale(100) brightness(100)",
}}
/>
</Box>
</Grid>
<Grid item>
<Typography
variant="h2"
sx={{
fontSize: 36,
color: "white",
fontWeight: 700,
mt: 1,
ml: 0.5,
fontFamily: "Poppins",
}}
>
CDR Bridge
</Typography>
</Grid>
</Grid>
<Grid item sx={{ width: "100%" }}>
{!session ? (
<Container
maxWidth="xs"
sx={{
p: 3,
mt: 3,
}}
>
<Grid
container
spacing={3}
direction="column"
alignItems="center"
>
{error ? (
<Grid item sx={{ width: "100%" }}>
<Box sx={{ backgroundColor: "red", p: 3 }}>
<Typography
variant="body1"
sx={{
fontSize: 18,
color: "white",
textAlign: "center",
}}
>
{`${error} error`}
</Typography>
</Box>
</Grid>
) : null}
<Grid item sx={{ width: "100%" }}>
<IconButton
sx={buttonStyles}
onClick={() =>
signIn("google", {
callbackUrl: `${origin}`,
})
}
>
<GoogleIcon sx={{ mr: 1 }} />
Sign in with Google
</IconButton>
</Grid>
<Grid item sx={{ width: "100%" }}>
<IconButton
aria-label="Sign in with Apple"
sx={buttonStyles}
onClick={() =>
signIn("apple", {
callbackUrl: `${window.location.origin}`,
})
}
>
<AppleIcon sx={{ mr: 1 }} />
Sign in with Apple
</IconButton>
</Grid>
</Grid>
</Container>
) : null}
{session ? (
<Box component="h4">
{` ${session.user.name ?? session.user.email}.`}
</Box>
) : null}
</Grid>
</Grid>
</Container>
</Box>
);
};

View file

@ -19,6 +19,7 @@ import {
PermPhoneMsg as PhoneIcon,
WhatsApp as WhatsAppIcon,
Facebook as FacebookIcon,
AirlineStops as AirlineStopsIcon,
} from "@mui/icons-material";
import { usePathname } from "next/navigation";
import Link from "next/link";
@ -28,7 +29,7 @@ import LinkLogo from "@/public/link-logo-small.png";
// import { useSession, signOut } from "next-auth/react";
const openWidth = 270;
const closedWidth = 100;
const closedWidth = 70;
const MenuItem = ({
name,
@ -180,7 +181,7 @@ export const Sidebar: FC<SidebarProps> = ({ open, setOpen }) => {
<Box
sx={{
position: "absolute",
top: 20,
top: 24,
right: open ? -8 : -16,
color: "#1C75FD",
rotate: open ? "90deg" : "-90deg",
@ -191,8 +192,8 @@ export const Sidebar: FC<SidebarProps> = ({ open, setOpen }) => {
>
<ExpandCircleDownIcon
sx={{
width: 30,
height: 30,
width: 24,
height: 24,
background: "white",
borderRadius: 500,
}}
@ -308,7 +309,7 @@ export const Sidebar: FC<SidebarProps> = ({ open, setOpen }) => {
}}
>
<MenuItem
name="Whatsapp"
name="WhatsApp"
href="/whatsapp"
selected={pathname.endsWith("/whatsapp")}
Icon={WhatsAppIcon}
@ -335,6 +336,13 @@ export const Sidebar: FC<SidebarProps> = ({ open, setOpen }) => {
Icon={PhoneIcon}
iconSize={20}
/>
<MenuItem
name="Webhooks"
href="/webhooks"
selected={pathname.startsWith("/webhooks")}
Icon={AirlineStopsIcon}
iconSize={20}
/>
<MenuItem
name="Users"
href="/users"