MSP-3172 add AgreementModal
This commit is contained in:
1 parent
c7c56e8e7b
commit
9d3c39befd
3 files changed
+66
No files matched your search
@@ -0,0 +1,8 @@
|
||||
@import "../../constants/style/styleConst";
|
||||
|
||||
.agreement-modal {
|
||||
&__description {
|
||||
display: inline-block;
|
||||
margin-bottom: $basic-margin;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
import { ModalProps } from 'antd'
|
||||
|
||||
export type AgreementModalPropsType = ModalProps & {
|
||||
description: string
|
||||
showTextArea?: boolean
|
||||
onConfirm: (message: string) => void
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
import { Input, Modal } from 'antd'
|
||||
import { ChangeEvent, useState } from 'react'
|
||||
|
||||
import { AgreementModalPropsType } from '@widgets/AgreementModal/agreement-modal.type.ts'
|
||||
|
||||
import './agreement-modal.scss'
|
||||
|
||||
const { TextArea } = Input
|
||||
|
||||
const AgreementModal = ({
|
||||
description,
|
||||
onConfirm,
|
||||
showTextArea = true,
|
||||
...rest
|
||||
}: AgreementModalPropsType) => {
|
||||
const [message, setMessage] = useState('')
|
||||
|
||||
const handleOnChange = (e: ChangeEvent<HTMLTextAreaElement>) => {
|
||||
setMessage(e.target.value)
|
||||
}
|
||||
|
||||
const handleOnOk = () => {
|
||||
onConfirm(message)
|
||||
}
|
||||
|
||||
return (
|
||||
<Modal
|
||||
okText="Отправить"
|
||||
className="agreement-modal"
|
||||
onOk={handleOnOk}
|
||||
{...rest}
|
||||
>
|
||||
<span
|
||||
data-cy="agreement-modal__description"
|
||||
className="agreement-modal__description"
|
||||
>
|
||||
{description}
|
||||
</span>
|
||||
{showTextArea && (
|
||||
<TextArea
|
||||
data-cy="agreement-modal__text-area"
|
||||
className="agreement-modal__text-area"
|
||||
value={message}
|
||||
onChange={handleOnChange}
|
||||
/>
|
||||
)}
|
||||
</Modal>
|
||||
)
|
||||
}
|
||||
|
||||
export default AgreementModal
|
||||
Reference in new issue
Block a user