Skip to content

Commit

Permalink
Merge pull request #828 from Health-Informatics-UoN/feat/826/layout-s…
Browse files Browse the repository at this point in the history
…plitting

Organise layouts of Carrot
  • Loading branch information
AndrewThien authored Aug 13, 2024
2 parents 973ae81 + f874af8 commit 10a68c3
Show file tree
Hide file tree
Showing 37 changed files with 254 additions and 87 deletions.
File renamed without changes.
21 changes: 21 additions & 0 deletions app/next-client-app/app/(protected)/layout.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import "../globals.css";
import "../custom.css";
import "react-tooltip/dist/react-tooltip.css";
import { Sidebar } from "../../components/core/sidebar";
import React from "react";
import { getCurrentUser } from "../../api/users";

export default async function ProtectedLayout({
children,
}: Readonly<{
children: React.ReactNode;
}>) {
const user = await getCurrentUser();

return (
<>
<Sidebar userName={user.username} />
<section className="px-10 my-6">{children}</section>
</>
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
FileSpreadsheet,
} from "lucide-react";
import { ScrollArea } from "@/components/ui/scroll-area";
import { GetFile } from "@/app/scanreports/[id]/mapping_rules/get-file";
import { GetFile } from "@/app/(protected)/scanreports/[id]/mapping_rules/get-file";
import {
DropdownMenu,
DropdownMenuContent,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { columns } from "@/app/scanreports/[id]/mapping_rules/columns";
import { columns } from "@/app/(protected)/scanreports/[id]/mapping_rules/columns";
import { getSummaryRules } from "@/api/mapping-rules";
import { DataTable } from "@/components/data-table";
import { FilterParameters } from "@/types/filter";
Expand Down
19 changes: 19 additions & 0 deletions app/next-client-app/app/(public)/layout.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import "../globals.css";
import "../custom.css";
import React from "react";
import { getCurrentUser } from "../../api/users";
import { MenuBar } from "@/components/core/menubar";

export default async function PublicLayout({
children,
}: Readonly<{
children: React.ReactNode;
}>) {
const user = await getCurrentUser();
return (
<>
<MenuBar userName={user.username} />
<section>{children}</section>
</>
);
}
File renamed without changes.
8 changes: 1 addition & 7 deletions app/next-client-app/app/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
import "./globals.css";
import "./custom.css";
import "react-tooltip/dist/react-tooltip.css";
import type { Metadata } from "next";
import { Toaster } from "sonner";
import { Sidebar } from "@/components/core/sidebar";
import { ThemeProvider } from "@/components/theme-provider";
import { getCurrentUser } from "@/api/users";

export const metadata: Metadata = {
title: "Carrot Mapper",
Expand All @@ -22,8 +19,6 @@ export default async function RootLayout({
}: Readonly<{
children: React.ReactNode;
}>) {
const user = await getCurrentUser();

return (
<html lang="en">
<body>
Expand All @@ -33,8 +28,7 @@ export default async function RootLayout({
enableSystem
disableTransitionOnChange
>
<Sidebar userName={user.username} />
<div className="container my-6">{children}</div>
{children}
</ThemeProvider>

<Toaster
Expand Down
40 changes: 40 additions & 0 deletions app/next-client-app/components/core/footer.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import Link from "next/link";
import Image from "next/image";
import { ReceiptText, ShieldQuestion } from "lucide-react";

const Footer = () => {
return (
<div className="sm:flex grid grid-cols-2 items-center justify-between w-full px-5 py-3">
<div className="relative w-[250px] h-[100px] ">
<Image src="/logos/UoN.jpg" alt="Logo UoN" fill />
</div>
<div className="relative w-[125px] h-[125px] ">
<Image src="/logos/coconnect1.png" alt="Logo CCN" fill />
</div>
<div className="relative w-[250px] h-[100px] ">
<Image src="/logos/UKRI.png" alt="Logo UKRI" fill />
</div>
<div className="relative w-[250px] h-[100px] ">
<Image src="/logos/alleviate.jpeg" alt="Logo ALVE" fill />
</div>
<div className="flex flex-col justify-end">
<p className="font-bold">Links</p>
<ul>
<li>
<Link href="#" className="flex items-center">
<ShieldQuestion size={15} className="mr-1" /> Privacy Policy
</Link>
</li>

<li>
<Link href="#" className="flex items-center">
<ReceiptText size={15} className="mr-1" /> Terms and Conditions
</Link>
</li>
</ul>
</div>
</div>
);
};

export default Footer;
57 changes: 57 additions & 0 deletions app/next-client-app/components/core/menuItems.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
import {
BookMarked,
FileScan,
Folders,
Github,
Home,
LogIn,
LucideIcon,
Upload,
} from "lucide-react";

export interface SidebarItems {
links: Array<{
label: string;
href: string;
icon?: LucideIcon;
}>;
routes: Array<{
label: string;
href: string;
icon?: LucideIcon;
}>;
}

export const sidebarItems: SidebarItems = {
links: [
{ label: "Datasets", href: "/datasets/", icon: Folders },
{ label: "Scan Reports", href: "/scanreports/", icon: FileScan },
{
label: "Upload Scan Report",
href: "/scanreports/create/",
icon: Upload,
},
{
href: "https://carrot4omop.ac.uk",
icon: BookMarked,
label: "Documentation",
},
],
routes: [
{
label: "Documentation",
href: "https://carrot4omop.ac.uk",
icon: BookMarked,
},
{
label: "GitHub",
href: "https://github.com/Health-Informatics-UoN/Carrot-Mapper",
icon: Github,
},
{
label: "Login",
href: "/accounts/login/",
icon: LogIn,
},
],
};
49 changes: 49 additions & 0 deletions app/next-client-app/components/core/menubar.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import Link from "next/link";
import Image from "next/image";

import { SidebarButton } from "./sidebar-button";
import { sidebarItems } from "./menuItems";
import { Sidebar } from "./sidebar";
import { ModeToggle } from "./mode-toggle";

export const MenuBar = ({ userName }: { userName: string }) => {
return (
<>
<Sidebar onPublic userName={userName} />

<div className="hidden lg:flex lg:items-center sticky top-0 z-50 backdrop-blur justify-between bg-primary pt-4 px-8 pb-3">
<Link href={"/"}>
<div className="text-2xl flex items-center font-semibold">
<Image
width={22}
height={22}
src="/carrot-logo.png"
alt="carrot-logo"
className="mx-3"
/>
Carrot
</div>
</Link>

<div className="flex items-center gap-3">
<div className="flex">
{(userName === "Unknown User"
? sidebarItems.routes
: sidebarItems.links
).map((link, idx) => (
<Link key={idx} href={link.href}>
<SidebarButton icon={link.icon} className="w-full">
{link.label}
</SidebarButton>
</Link>
))}
</div>
<div>
<ModeToggle />
</div>
{/* TODO: Need a logout button here */}
</div>
</div>
</>
);
};
Loading

0 comments on commit 10a68c3

Please sign in to comment.