Skip to content

Commit

Permalink
diable buttons in no board
Browse files Browse the repository at this point in the history
  • Loading branch information
sasanqc committed Jun 24, 2023
1 parent b9aa1ed commit db601f6
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
12 changes: 9 additions & 3 deletions components/UI/Dropdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@ import React, { useRef, useState, useEffect } from "react";
import VerticalElipsisIcon from "@/icons/icon-vertical-ellipsis.svg";
interface DropdownProps {
items: { label: string; className: string; onClick: () => void }[];
disable?: boolean;
}
const Dropdown: React.FC<DropdownProps> = ({ items }) => {
const Dropdown: React.FC<DropdownProps> = ({ items, disable = false }) => {
const menuRef = useRef<HTMLDivElement>(null);
const [menuIsOpoen, setMenuIsOpen] = useState(false);
const handleClickedOnBackdrop = (e: MouseEvent) => {
Expand All @@ -23,8 +24,13 @@ const Dropdown: React.FC<DropdownProps> = ({ items }) => {
return (
<div className="relative z-30" ref={menuRef}>
<div
className="cursor-pointer p-2 dark:hover:bg-black1 hover:bg-gray1 rounded-md transition"
onClick={() => setMenuIsOpen(true)}
className={`${
disable ? "cursor-not-allowed" : "cursor-pointer"
} p-2 dark:hover:bg-black1 hover:bg-gray1 rounded-md transition`}
onClick={() => {
if (disable) return;
setMenuIsOpen(true);
}}
>
<VerticalElipsisIcon />
</div>
Expand Down
2 changes: 2 additions & 0 deletions layout/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ const Header = () => {
onClick={() => dispatch(setActiveModal(ModalEnum.CREATE_TASK))}
/>
<Dropdown
disable={data?.boards.length === 0}
items={[
{
label: "Edit Board",
Expand Down Expand Up @@ -77,6 +78,7 @@ const Header = () => {
<AddIcon />
</button>
<Dropdown
disable={data?.boards.length === 0}
items={[
{
label: "Edit Board",
Expand Down

0 comments on commit db601f6

Please sign in to comment.