diff --git a/compass/components/Table/Index.tsx b/compass/components/Table/Index.tsx index 0f9beb3..756c743 100644 --- a/compass/components/Table/Index.tsx +++ b/compass/components/Table/Index.tsx @@ -35,13 +35,13 @@ export const Table = () => { cell: (info) => , }), columnHelper.accessor("role", { - cell: (info) => , + cell: (info) => , }), columnHelper.accessor("email", { cell: (info) => info.renderValue(), }), columnHelper.accessor("program", { - cell: (info) => info.renderValue(), + cell: (info) => , }), ]; diff --git a/compass/components/TagsInput/DropdownAction.tsx b/compass/components/TagsInput/DropdownAction.tsx new file mode 100644 index 0000000..fcddf48 --- /dev/null +++ b/compass/components/TagsInput/DropdownAction.tsx @@ -0,0 +1,41 @@ +import { EllipsisHorizontalIcon } from "@heroicons/react/24/solid"; +import { useState } from "react"; + +export const DropdownAction = ({ tag }) => { + const [isVisible, setVisible] = useState(false); + const [inputValue, setInputValue] = useState(tag); + + const handleBlur = () => { + setVisible(false); + }; + + const handleInputChange = (e: React.ChangeEvent) => { + setInputValue(e.target.value); + }; + + const handleClick = (event: React.MouseEvent) => { + event.stopPropagation(); // This stops the click event from propagating + setVisible(!isVisible); // Toggle visibility + }; + + return ( +
+ {isVisible ? ( +
+ +
+ ) : ( + + )} +
+ ); +}; diff --git a/compass/components/TagsInput/Index.tsx b/compass/components/TagsInput/Index.tsx index 69d5047..28855ec 100644 --- a/compass/components/TagsInput/Index.tsx +++ b/compass/components/TagsInput/Index.tsx @@ -1,29 +1,30 @@ -// In a file TagsInput.tsx - -import { useState } from 'react'; +import React, { useState } from 'react'; import 'tailwindcss/tailwind.css'; -import {TagsArray} from './TagsArray'; // Assuming this is the correct path +import { TagsArray } from './TagsArray'; // Corrected path assumption import { TagDropdown } from './TagDropdown'; -const TagsInput = () => { +interface TagsInputProps { + presetOptions: string[]; +} + +const TagsInput: React.FC = ({ presetValue, presetOptions }) => { const [inputValue, setInputValue] = useState(''); const [cellSelected, setCellSelected] = useState(false); - const [tags, setTags] = useState(['Administrator']); - const [options, setOptions] = useState(["Administrators", "Employees", "Volunteers"]); + const [tags, setTags] = useState([presetValue]); + const [options, setOptions] = useState(presetOptions); const handleInputChange = (e: React.ChangeEvent) => { setInputValue(e.target.value); }; - // Function to handle adding new tags when enter is pressed const handleAddTag = (e: React.KeyboardEvent) => { - if (e.key === 'Enter' && inputValue) { - setTags([...tags, inputValue]); + if (e.key === 'Enter' && inputValue.trim()) { + setTags(prevTags => [...prevTags, inputValue]); + setOptions(prevOptions => [...prevOptions, inputValue]); setInputValue(''); } }; - // Function to handle deleting tags const handleDeleteTag = (tagToDelete: string) => { setTags(tags.filter(tag => tag !== tagToDelete)); }; @@ -33,34 +34,30 @@ const TagsInput = () => { }; return ( -
setCellSelected(true)} - > +
setCellSelected(true)}> {!cellSelected ? ( - + ) : ( -
-
-
- - -
-
- Select an option or create one - +
+
+
+ +
- -
+
+ Select an option or create one + +
+
)}
diff --git a/compass/components/TagsInput/Tag.tsx b/compass/components/TagsInput/Tag.tsx index 3ad97f3..59ede37 100644 --- a/compass/components/TagsInput/Tag.tsx +++ b/compass/components/TagsInput/Tag.tsx @@ -1,6 +1,9 @@ import { XMarkIcon } from "@heroicons/react/24/solid" export const Tag = ({children, active = false}) => { + const handleClick = () => { + + } return ( {children} {active && } diff --git a/compass/components/TagsInput/TagDropdown.tsx b/compass/components/TagsInput/TagDropdown.tsx index 91d8be5..b1b5f9b 100644 --- a/compass/components/TagsInput/TagDropdown.tsx +++ b/compass/components/TagsInput/TagDropdown.tsx @@ -1,15 +1,16 @@ -import { EllipsisHorizontalIcon } from "@heroicons/react/24/solid" -import { Tag } from "./Tag" -export const TagDropdown = ({tags}) => { - return ( -
- - {tags.map((tag) => { - return
{tag}
- })} - - +import { Tag } from "./Tag"; +import { DropdownAction } from "./DropdownAction"; + +export const TagDropdown = ({ tags }) => { + return ( +
+ {tags.map((tag, index) => ( +
+ {tag} +
- ) -} \ No newline at end of file + ))} +
+ ); +};