Skip to content

Commit

Permalink
feat: Header의 [더보기] 버튼을 클릭하면, modal 창이 나타난다 (#171)
Browse files Browse the repository at this point in the history
  • Loading branch information
aken-you committed Jun 27, 2023
1 parent 4e92ff4 commit 45f7958
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion fe/src/components/ProductDetail/ProductDetailHeader/index.tsx
Original file line number Diff line number Diff line change
@@ -1,22 +1,43 @@
import { useState } from 'react';
import { useNavigate } from 'react-router-dom';

import { ICON_NAME } from '@constants/iconName';

import Icon from '@components/common/Icon';
import Modal from '@components/common/Modal';
import ModalPortal from '@components/ModalPortal';
import * as S from './style';

interface ProductDetailHeaderProps {
isSeller: boolean;
}

const ProductDetailHeader = ({ isSeller }: ProductDetailHeaderProps) => {
const [isModalOpen, setIsModalOpen] = useState(false);

const navigate = useNavigate();

return (
<S.Header>
<button onClick={() => navigate(-1)}>
<Icon name={ICON_NAME.CHEVRON_LEFT} />
</button>
{isSeller && <Icon name={ICON_NAME.ELLIPSIS} />}
{isSeller && (
<button onClick={() => setIsModalOpen(true)}>
<Icon name={ICON_NAME.ELLIPSIS} />
</button>
)}
{isModalOpen && (
<ModalPortal>
<Modal
options={[
{ text: '게시글 수정', colorType: 'default', handler: () => console.log('게시글 수정') },
{ text: '삭제', colorType: 'warning', handler: () => console.log('삭제') },
]}
closeModalHandler={() => setIsModalOpen(false)}
/>
</ModalPortal>
)}
</S.Header>
);
};
Expand Down

0 comments on commit 45f7958

Please sign in to comment.