Files
operationSystem-front/src/components/common/modal/DynamicModal.js
bcjang 9be5bb388a data 정보 수정
우편 내용 복사 기능
우편 코드 정리
유저 인벤토리 아이템 삭제 제거
2025-05-15 17:49:45 +09:00

82 lines
2.2 KiB
JavaScript

import { BtnWrapper, ButtonClose, ModalText } from '../../../styles/Components';
import Button from '../button/Button';
import Modal from './Modal';
import { modalTypes } from '../../../assets/data';
const DynamicModal = ({modalType, view, handleSubmit, handleCancel, modalText, children, ChildView}) => {
if (!view) return null;
const OkButton = ({handleClick}) => {
return <Button
text="확인"
theme="primary"
type="submit"
size="large"
width="100%"
handleClick={handleClick}
/>
}
const CancelButton = ({handleClick}) => {
return <Button text="취소" theme="line" size="large" width="100%" handleClick={handleClick} />
}
const ModalWrapper = ({children , modalText, handleCancel, view}) => {
return (
<Modal min="440px" $padding="40px" $bgcolor="transparent" $view={view}>
<BtnWrapper $justify="flex-end">
<ButtonClose onClick={handleCancel} />
</BtnWrapper>
<ModalText $align="center">
{modalText && modalText}
</ModalText>
<BtnWrapper $gap="10px">
{children}
</BtnWrapper>
</Modal>
)
}
switch (modalType) {
case modalTypes.confirmOkCancel:
return (
<ModalWrapper view={view} modalText={modalText} handleCancel={handleCancel} >
<CancelButton handleClick={handleCancel} />
<OkButton handleClick={handleSubmit} />
</ModalWrapper>
);
case modalTypes.completed:
return (
<ModalWrapper view={view} modalText={modalText} handleCancel={handleSubmit} >
<OkButton handleClick={handleSubmit} />
</ModalWrapper>
);
case modalTypes.childOkCancel:
return (
<Modal min="440px" $padding="40px" $bgcolor="transparent" $view={view}>
<BtnWrapper $justify="flex-end">
<ButtonClose onClick={handleCancel} />
</BtnWrapper>
<ModalText $align="center">
{children && children}
{ChildView && <ChildView />}
</ModalText>
<BtnWrapper $gap="10px">
<Button text="취소" theme="line" size="large" width="100%" handleClick={handleCancel} />
<Button
text="확인"
theme="primary"
type="submit"
size="large"
width="100%"
handleClick={handleSubmit}
/>
</BtnWrapper>
</Modal>
);
default:
return null;
}
}
export default DynamicModal;