Skip to content

Commit

Permalink
refactor/BibimMandu-IssueTacker#146: 드롭다운 인디케이터 리팩토링
Browse files Browse the repository at this point in the history
  • Loading branch information
qkdflrgs committed Aug 10, 2023
1 parent 436b274 commit f1eb0c2
Showing 1 changed file with 1 addition and 45 deletions.
46 changes: 1 addition & 45 deletions FE/src/components/DropdownIndicator/DropdownIndicator.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
import { styled } from "styled-components";
import DropdownPanel from "../DropdownPanel/DropdownPanel";
import { useEffect, useState } from "react";
import { AssigneesProps } from "../../type";

type Props = {
icon?: string;
label: string;
padding?: string;
width?: string;
height?: string;
hasDropdown?: boolean;
};

export default function DropdownIndicator({
Expand All @@ -18,51 +14,11 @@ export default function DropdownIndicator({
padding = "4px 0px",
width = "80px",
height = "32px",
hasDropdown = false,
}: Props) {
const [isOpen, setIsOpen] = useState<boolean>(false);
const [assigneesData, setAssigneesData] = useState<AssigneesProps>();

const openDropdown = () => {
setIsOpen(true);
};

const closeDropdown = () => {
setIsOpen(false);
};

useEffect(() => {
const fetchData = async () => {
try {
const response = await fetch(
"http://3.34.141.196/api/issues/assignees",
);
const data = await response.json();
setAssigneesData(data);
} catch (error) {
console.log("error");
}
};

fetchData();
}, []);

return (
<IndicatorButton
$padding={padding}
$width={width}
$height={height}
onClick={openDropdown}
>
<IndicatorButton $padding={padding} $width={width} $height={height}>
<IndicatorLabel>{label}</IndicatorLabel>
<IndicatorIcon src={`/icons/${icon}.svg`} />
{hasDropdown && isOpen && (
<DropdownPanel
title={label}
assigneesList={assigneesData!}
closeDropdown={closeDropdown}
/>
)}
</IndicatorButton>
);
}
Expand Down

0 comments on commit f1eb0c2

Please sign in to comment.