Skip to content

Commit

Permalink
code review: naming 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
seueooo committed Sep 5, 2024
1 parent 9c5649c commit 3558bd9
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 13 deletions.
13 changes: 8 additions & 5 deletions src/shared/components/CategoryCommonMoribSet.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,13 @@ const CategoryCommonMoribSet = ({ variant, urlInfos, children }: CategoryCommonM
const theadStyle =
' detail-semibold-14 flex h-[4.6rem] items-center border-b-[0.1rem] border-gray-bg-04 text-gray-04';

const renderEmptyRows = (count: number) => {
return Array.from({ length: count }).map((_, index) => (
<div key={`empty-row-${index}`} className="h-[4.6rem] w-full border-b-[0.1rem] border-gray-bg-04" />
));
};

const emptyRowCount = Math.max(sizeVariant[variant].rowCounts - urlInfos.length, 0);
return (
<div
className={`${defaultTableStyle} ${optionalScrollStyle} ${sizeVariant[variant].bgColor} ${sizeVariant[variant].width} ${sizeVariant[variant].height} ${sizeVariant[variant].maxHeight}`}
Expand All @@ -62,11 +69,7 @@ const CategoryCommonMoribSet = ({ variant, urlInfos, children }: CategoryCommonM

<div>
{children}
{Array.from({ length: Math.max(sizeVariant[variant].rowCounts - urlInfos.length, 0) }, (_, index) => (
<div key={`empty-row-${index}`}>
<div className="h-[4.6rem] w-full border-b-[0.1rem] border-gray-bg-04" />
</div>
))}
{renderEmptyRows(emptyRowCount)}
</div>
</div>
</div>
Expand Down
10 changes: 5 additions & 5 deletions src/shared/components/CategoryModalLeft.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ const CategoryModalLeft = ({
isClicked,
selectedOption,
}: ModalProps) => {
const [isSelectedTab, setSelectedTab] = useState(CATEGORY_MODALTABS[0].id);
const [selectedTabId, setSelectedTabId] = useState(CATEGORY_MODALTABS[0].id);

const { data: categoryData } = useCategoryLists();
const categories = categoryData?.data || [];
Expand All @@ -49,18 +49,18 @@ const CategoryModalLeft = ({
};

const handleTabChange = (tab: number) => {
setSelectedTab(tab);
setSelectedTabId(tab);
};

const disabled = isSelectedTab === 2;
const disabled = selectedTabId === 2;

return (
<div className="h-[80rem] w-[68.8rem] rounded-l-[10px] bg-gray-bg-04 py-[2.8rem] pl-[4.4rem] pr-[4.3rem]">
<header className="mb-[3.3rem]">
<h1 className="head-bold-24 text-gray-04">카테고리 추가</h1>
</header>
<aside className="mb-[8px]">
<CategoryTabSelect tabs={CATEGORY_MODALTABS} handleTabChange={handleTabChange} isSelectedTab={isSelectedTab} />
<CategoryTabSelect tabs={CATEGORY_MODALTABS} handleTabChange={handleTabChange} selectedTabId={selectedTabId} />

<div className="relative mt-[0px]">
<DropdownCategory
Expand All @@ -76,7 +76,7 @@ const CategoryModalLeft = ({
</aside>

<CategoryCommonMoribSet variant="smallLeft" urlInfos={msetUrlInfos}>
{isSelectedTab !== 2 &&
{selectedTabId !== 2 &&
msetUrlInfos.map((urlInfo: UrlInfo) => (
<div
key={urlInfo.url}
Expand Down
6 changes: 3 additions & 3 deletions src/shared/components/CategoryTabSelect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ interface Tabs {
interface TabSelectProps {
tabs: Tabs[];
handleTabChange: (number: number) => void;
isSelectedTab: number;
selectedTabId: number;
}

const CategoryTabSelect = ({ tabs, handleTabChange, isSelectedTab }: TabSelectProps) => {
const CategoryTabSelect = ({ tabs, handleTabChange, selectedTabId }: TabSelectProps) => {
return (
<>
{tabs.map((tab) => (
Expand All @@ -21,7 +21,7 @@ const CategoryTabSelect = ({ tabs, handleTabChange, isSelectedTab }: TabSelectPr
onClick={() => {
handleTabChange(tab.id);
}}
activeTab={isSelectedTab}
activeTab={selectedTabId}
>
{tab.name}
</ButtonCategoryTab>
Expand Down

0 comments on commit 3558bd9

Please sign in to comment.