diff --git a/compass/app/admin/layout.tsx b/compass/app/admin/layout.tsx
index bb7fddd..035a456 100644
--- a/compass/app/admin/layout.tsx
+++ b/compass/app/admin/layout.tsx
@@ -1,37 +1,44 @@
-"use client"
+"use client";
-import Sidebar from '@/components/resource/Sidebar';
-import React, { useState } from 'react';
-import { ChevronDoubleRightIcon } from '@heroicons/react/24/outline';
+import Sidebar from "@/components/Sidebar/Sidebar";
+import React, { useState } from "react";
+import { ChevronDoubleRightIcon } from "@heroicons/react/24/outline";
export default function RootLayout({
-
- children,
+ children,
}: {
- children: React.ReactNode
+ children: React.ReactNode;
}) {
- const [isSidebarOpen, setIsSidebarOpen] = useState(false);
+ const [isSidebarOpen, setIsSidebarOpen] = useState(false);
- return (
-
- {/* button to open sidebar */}
-
- {/* sidebar */}
-
-
-
- {/* page ui */}
-
- {children}
-
-
- )
-}
\ No newline at end of file
+ return (
+
+ {/* button to open sidebar */}
+
+ {/* sidebar */}
+
+
+
+ {/* page ui */}
+
+ {children}
+
+
+ );
+}
diff --git a/compass/app/resource/layout.tsx b/compass/app/resource/layout.tsx
index bb7fddd..b497878 100644
--- a/compass/app/resource/layout.tsx
+++ b/compass/app/resource/layout.tsx
@@ -1,37 +1,44 @@
-"use client"
+"use client";
-import Sidebar from '@/components/resource/Sidebar';
-import React, { useState } from 'react';
-import { ChevronDoubleRightIcon } from '@heroicons/react/24/outline';
+import Sidebar from "@/components/Sidebar/Sidebar";
+import React, { useState } from "react";
+import { ChevronDoubleRightIcon } from "@heroicons/react/24/outline";
export default function RootLayout({
-
- children,
+ children,
}: {
- children: React.ReactNode
+ children: React.ReactNode;
}) {
- const [isSidebarOpen, setIsSidebarOpen] = useState(false);
+ const [isSidebarOpen, setIsSidebarOpen] = useState(false);
- return (
-
- {/* button to open sidebar */}
-
- {/* sidebar */}
-
-
-
- {/* page ui */}
-
- {children}
-
-
- )
-}
\ No newline at end of file
+ return (
+
+ {/* button to open sidebar */}
+
+ {/* sidebar */}
+
+
+
+ {/* page ui */}
+
+ {children}
+
+
+ );
+}
diff --git a/compass/components/Drawer/Drawer.tsx b/compass/components/Drawer/Drawer.tsx
new file mode 100644
index 0000000..1601453
--- /dev/null
+++ b/compass/components/Drawer/Drawer.tsx
@@ -0,0 +1,246 @@
+import { FunctionComponent, ReactNode } from "react";
+import React, { useState } from "react";
+import { ChevronDoubleLeftIcon } from "@heroicons/react/24/solid";
+import {
+ StarIcon as SolidStarIcon,
+ EnvelopeIcon,
+ UserIcon,
+} from "@heroicons/react/24/solid";
+import {
+ ArrowsPointingOutIcon,
+ ArrowsPointingInIcon,
+ StarIcon as OutlineStarIcon,
+ ListBulletIcon,
+} from "@heroicons/react/24/outline";
+import TagsInput from "../TagsInput/Index";
+
+type DrawerProps = {
+ title: string;
+ children: ReactNode;
+ onClick?: (event: React.MouseEvent) => void;
+ type?: "button" | "submit" | "reset"; // specify possible values for type
+ disabled?: boolean;
+ editableContent?: any;
+ onSave?: (content: any) => void;
+ rowContent?: any;
+ onRowUpdate?: (content: any) => void;
+};
+
+interface EditContent {
+ content: string;
+ isEditing: boolean;
+}
+
+const Drawer: FunctionComponent = ({
+ title,
+ children,
+ onSave,
+ editableContent,
+ rowContent,
+ onRowUpdate,
+}) => {
+ const [isOpen, setIsOpen] = useState(false);
+ const [isFull, setIsFull] = useState(false);
+ const [isFavorite, setIsFavorite] = useState(false);
+ const [tempRowContent, setTempRowContent] = useState(rowContent);
+
+ const handleTempRowContentChange = (e) => {
+ const { name, value } = e.target;
+ console.log(name);
+ console.log(value);
+ setTempRowContent((prevContent) => ({
+ ...prevContent,
+ [name]: value,
+ }));
+ };
+
+ const handleEnterPress = (e) => {
+ if (e.key === "Enter") {
+ e.preventDefault();
+ // Update the rowContent with the temporaryRowContent
+ if (onRowUpdate) {
+ onRowUpdate(tempRowContent);
+ }
+ }
+ };
+
+ const toggleDrawer = () => {
+ setIsOpen(!isOpen);
+ if (isFull) {
+ setIsFull(!isFull);
+ }
+ };
+
+ const toggleDrawerFullScreen = () => setIsFull(!isFull);
+
+ const toggleFavorite = () => setIsFavorite(!isFavorite);
+
+ const drawerClassName = `fixed top-0 right-0 w-1/2 h-full bg-white transform ease-in-out duration-300 z-20 ${
+ isOpen ? "translate-x-0 shadow-xl" : "translate-x-full"
+ } ${isFull ? "w-full" : "w-1/2"}`;
+
+ const iconComponent = isFull ? (
+
+ ) : (
+
+ );
+
+ const favoriteIcon = isFavorite ? (
+
+ ) : (
+
+ );
+
+ const [presetOptions, setPresetOptions] = useState([
+ "administrator",
+ "volunteer",
+ "employee",
+ ]);
+ const [rolePresetOptions, setRolePresetOptions] = useState([
+ "domestic",
+ "community",
+ "economic",
+ ]);
+ const [tagColors, setTagColors] = useState(new Map());
+
+ const getTagColor = (tag: string) => {
+ if (!tagColors.has(tag)) {
+ const colors = [
+ "bg-cyan-100",
+ "bg-blue-100",
+ "bg-green-100",
+ "bg-yellow-100",
+ "bg-purple-100",
+ ];
+ const randomColor = colors[Math.floor(Math.random() * colors.length)];
+ setTagColors(new Map(tagColors).set(tag, randomColor));
+ }
+ return tagColors.get(tag);
+ };
+
+ return (
+
+
+
+
+
+
+
+
+
+
+ {rowContent.username}
+
+
+
+
+
+
+
+
+
+
+
+ );
+};
+
+export default Drawer;
diff --git a/compass/components/PageLayout.tsx b/compass/components/PageLayout.tsx
index c655296..45a733d 100644
--- a/compass/components/PageLayout.tsx
+++ b/compass/components/PageLayout.tsx
@@ -15,7 +15,7 @@ export const PageLayout: React.FC = ({ icon, title, children })
{/* data */}
-
diff --git a/compass/components/Sidebar/Sidebar.tsx b/compass/components/Sidebar/Sidebar.tsx
new file mode 100644
index 0000000..6eab9fa
--- /dev/null
+++ b/compass/components/Sidebar/Sidebar.tsx
@@ -0,0 +1,67 @@
+import React from "react";
+import {
+ HomeIcon,
+ ChevronDoubleLeftIcon,
+ BookmarkIcon,
+ ClipboardIcon,
+ BookOpenIcon,
+ UserGroupIcon,
+} from "@heroicons/react/24/solid";
+import { SidebarItem } from "./SidebarItem";
+import { UserProfile } from "../resource/UserProfile";
+
+interface SidebarProps {
+ setIsSidebarOpen: React.Dispatch>;
+ isAdmin: boolean;
+}
+
+const Sidebar: React.FC = ({ setIsSidebarOpen, isAdmin }) => {
+ return (
+
+ {/* button to close sidebar */}
+
+
+
+
+ {/* user + logout button */}
+
+
+
+ {/* navigation menu */}
+
+
Pages
+
+
+
+
+ );
+};
+
+export default Sidebar;
diff --git a/compass/components/resource/SidebarItem.tsx b/compass/components/Sidebar/SidebarItem.tsx
similarity index 100%
rename from compass/components/resource/SidebarItem.tsx
rename to compass/components/Sidebar/SidebarItem.tsx
diff --git a/compass/components/Table.tsx b/compass/components/Table.tsx
deleted file mode 100644
index ac55a42..0000000
--- a/compass/components/Table.tsx
+++ /dev/null
@@ -1,45 +0,0 @@
-import { Component } from "react"
-
-// interface TableHeader {
-// title: string,
-// type: string
-// }
-
-// interface TableRow {
-// [key: string]: any,
-// }
-interface TableProps {
- headersData: string[];
- data: { [key: string]: any }[];
-}
-
-const Table: React.FC = ({ headersData, data }) => {
- const headers = headersData.map((header, i) => {
- return {header} |
- })
-
- console.log(data);
-
- const rows = data.map((item) => {
- const row = headersData.map(key => {
- return {item[key]} |
- });
- return {row}
- })
-
- return (<>
-
-
-
- {headers}
-
-
-
- {rows}
-
-
- >);
-
-}
-
-export default Table
diff --git a/compass/components/Table/PrimaryTableCell.tsx b/compass/components/Table/PrimaryTableCell.tsx
index a6e265f..1c94990 100644
--- a/compass/components/Table/PrimaryTableCell.tsx
+++ b/compass/components/Table/PrimaryTableCell.tsx
@@ -1,11 +1,11 @@
/* An extension of TableCell.tsx that includes an "open" button and the drawer.
For cells in the "primary" (or first) column of the table. */
-import Drawer from "@/components/page/Drawer";
+import Drawer from "@/components/Drawer/Drawer";
import { TableCell } from "./TableCell";
import { SetStateAction, useState } from "react";
export const PrimaryTableCell = ({ getValue, row, column, table }) => {
- const [pageContent, setPageContent] = useState("")
+ const [pageContent, setPageContent] = useState("");
const handleDrawerContentChange = (newContent: SetStateAction) => {
setPageContent(newContent);
@@ -15,7 +15,13 @@ export const PrimaryTableCell = ({ getValue, row, column, table }) => {
- {pageContent}
+
+ {pageContent}
+
);
diff --git a/compass/components/Table/RowOpenAction.tsx b/compass/components/Table/RowOpenAction.tsx
index a38ff51..2f013b0 100644
--- a/compass/components/Table/RowOpenAction.tsx
+++ b/compass/components/Table/RowOpenAction.tsx
@@ -1,22 +1,27 @@
-import Drawer from "@/components/page/Drawer";
-import {ChangeEvent, useState} from "react";
+import Drawer from "@/components/Drawer/Drawer";
+import { ChangeEvent, useState } from "react";
export const RowOpenAction = ({ title, rowData, onRowUpdate }) => {
- const [pageContent, setPageContent] = useState("")
-
- const handleDrawerContentChange = (newContent) => {
- setPageContent(newContent);
- };
+ const [pageContent, setPageContent] = useState("");
+ const handleDrawerContentChange = (newContent) => {
+ setPageContent(newContent);
+ };
return (
{title}
-
+
{/* Added OnRowUpdate to drawer */}
- {pageContent}
-
+
+
);
};
diff --git a/compass/components/Table/RowOption.tsx b/compass/components/Table/RowOption.tsx
index 0514c64..e022868 100644
--- a/compass/components/Table/RowOption.tsx
+++ b/compass/components/Table/RowOption.tsx
@@ -3,7 +3,7 @@ import { TrashIcon, DocumentDuplicateIcon, ArrowUpRightIcon, EyeSlashIcon } from
export const RowOption = ({ icon: Icon, label, onClick }) => {
return (
-