diff --git a/compass/components/NewDrawer/NewDrawer.tsx b/compass/components/NewDrawer/NewDrawer.tsx new file mode 100644 index 0000000..680acb9 --- /dev/null +++ b/compass/components/NewDrawer/NewDrawer.tsx @@ -0,0 +1,112 @@ +import React, { useState, FunctionComponent } from "react"; +import { + ChevronDoubleLeftIcon, + StarIcon as SolidStarIcon, + UserIcon, +} from "@heroicons/react/24/solid"; +import { + ArrowsPointingOutIcon, + ArrowsPointingInIcon, + StarIcon as OutlineStarIcon, + ListBulletIcon, +} from "@heroicons/react/24/outline"; +import TagsInput from "../TagsInput/Index"; + +type Field = { + icon: JSX.Element; + name: JSX.Element; + input: JSX.Element; +} + +type DrawerProps = { + header: string; + fields: Field[]; + onSubmit: (e: React.FormEvent) => void; +}; + +function NewDrawer({ header, fields, onSubmit }: DrawerProps) { + const [isOpen, setIsOpen] = useState(false); + const [isFull, setIsFull] = useState(false); + const [isFavorite, setIsFavorite] = useState(false); + + const toggleDrawer = () => setIsOpen(!isOpen); + const toggleDrawerFullScreen = () => setIsFull(!isFull); + const toggleFavorite = () => setIsFavorite(!isFavorite); + + const drawerClassName = `fixed top-0 right-0 ${ + isFull ? "w-full" : "w-1/2" + } h-full bg-white transform ease-in-out duration-300 z-20 ${ + isOpen ? "translate-x-0 shadow-xl" : "translate-x-full" + }`; + + return ( +
+ +
+
+

+ {header} +

+
+ + + +
+
+
+
+ + + { + fields.map((field, index) => ( + +
+
+ + + + + )) + } + + +
{field.icon}{field.name} + {field.input} +
+
+
+
+
+
+ ); +}; + +export default NewDrawer; diff --git a/compass/components/NewDrawer/NewResourceDrawer.tsx b/compass/components/NewDrawer/NewResourceDrawer.tsx new file mode 100644 index 0000000..61839ce --- /dev/null +++ b/compass/components/NewDrawer/NewResourceDrawer.tsx @@ -0,0 +1,86 @@ +import { FunctionComponent, useState } from "react"; +import NewDrawer from "./NewDrawer"; +import Resource from "@/utils/models/Resource"; +import { + ChevronDoubleLeftIcon, + StarIcon as SolidStarIcon, + UserIcon, +} from "@heroicons/react/24/solid"; +import { + ArrowsPointingOutIcon, + ArrowsPointingInIcon, + StarIcon as OutlineStarIcon, + ListBulletIcon, +} from "@heroicons/react/24/outline"; +import TagsInput from "../TagsInput/Index"; +import useTagsHandler from "../TagsInput/TagsHandler"; + +type NewResourceDrawerProps = { + rowContent: Resource; + updateData: (input: any) => void +}; + +const NewResourceDrawer: FunctionComponent = ({ rowContent, updateData }) => { + const [input, setInput] = useState({ + name: rowContent.name, + link: rowContent.link, + summary: rowContent.summary + }) + + const tagProps = useTagsHandler([ + "domestic", + "economic", + "community", + ]); + + const handleChange = (field: string, change: string) => { + setInput(prev => ({ ...prev, [field]: change})) + } + + const handleSubmit = (e: React.FormEvent) => { + e.preventDefault(); + updateData(input); + } + + const fields = [ + { + icon: , + name: <>Name, + input: ( + handleChange('name', e.target.value)} + value={input.name} + /> + ) + }, + { + icon: , + name: <>Link, + input: ( + handleChange('link', e.target.value)} + value={input.link} + /> + ) + }, + { + icon: , + name: <>Program, + input: + }, + { + icon: , + name: <>Summary, + input: ( + handleChange('summary', e.target.value)} + value={input.summary} + /> + ) + } + ] + + return +} + +export default NewResourceDrawer; \ No newline at end of file diff --git a/compass/components/Sidebar/Sidebar.tsx b/compass/components/Sidebar/Sidebar.tsx index d82ab69..a027d06 100644 --- a/compass/components/Sidebar/Sidebar.tsx +++ b/compass/components/Sidebar/Sidebar.tsx @@ -104,7 +104,7 @@ const Sidebar: React.FC = ({ icon={} text="Training Manuals" active={true} - redirect="/training-manuals" + redirect="/training-manual" /> diff --git a/compass/components/Table/NewRowOpenAction.tsx b/compass/components/Table/NewRowOpenAction.tsx new file mode 100644 index 0000000..ea2424c --- /dev/null +++ b/compass/components/Table/NewRowOpenAction.tsx @@ -0,0 +1,27 @@ +import { Dispatch, SetStateAction, useState } from "react"; +import NewResourceDrawer from "../NewDrawer/NewResourceDrawer"; +import Resource from "@/utils/models/Resource"; + +type RowOpenActionProps = { + title: string; + rowData: Resource; + setData: Dispatch>; +}; + +export default function ResourceRowOpenAction({ + title, + rowData, + setData, +}: RowOpenActionProps) { + return ( +
+ {title} + + {alert(JSON.stringify(i))}} + /> + +
+ ); +} \ No newline at end of file diff --git a/compass/components/Table/ResourceTable.tsx b/compass/components/Table/ResourceTable.tsx index 6979498..f747302 100644 --- a/compass/components/Table/ResourceTable.tsx +++ b/compass/components/Table/ResourceTable.tsx @@ -2,10 +2,10 @@ import { Bars2Icon } from "@heroicons/react/24/solid"; import { Dispatch, SetStateAction, useState } from "react"; import useTagsHandler from "@/components/TagsInput/TagsHandler"; import { ColumnDef, createColumnHelper } from "@tanstack/react-table"; -import { RowOpenAction } from "@/components/Table/RowOpenAction"; import Table from "@/components/Table/Table"; import TagsInput from "@/components/TagsInput/Index"; import Resource from "@/utils/models/Resource"; +import ResourceRowOpenAction from "./NewRowOpenAction"; type ResourceTableProps = { data: Resource[]; @@ -32,7 +32,7 @@ export default function ResourceTable({ data, setData }: ResourceTableProps) { ), cell: (info) => ( -