71 lines
2.5 KiB
JavaScript
71 lines
2.5 KiB
JavaScript
import {Card, Popconfirm, Tooltip} from "antd";
|
||
import PropTypes from "prop-types";
|
||
import {DeleteOutlined, EditOutlined, EyeOutlined} from "@ant-design/icons";
|
||
import {useState} from "react";
|
||
import LensViewModal from "../Pages/LensesSetsPage/Components/LensesTab/Components/LensViewModal/LensViewModal.jsx";
|
||
import {LensPropType} from "../../Types/lensPropType.js";
|
||
|
||
const LensListCard = ({lens, handleEditLens, handleDeleteLens}) => {
|
||
const [showModalInfo, setShowModalInfo] = useState(false);
|
||
|
||
const deleteLens = () => {
|
||
handleDeleteLens(lens.id);
|
||
}
|
||
|
||
const handleViewLens = () => {
|
||
setShowModalInfo(true);
|
||
};
|
||
|
||
const actions = [
|
||
<Tooltip title="Просмотр линзы" key={"viewLens"}>
|
||
<EyeOutlined onClick={handleViewLens}/>
|
||
</Tooltip>,
|
||
<Tooltip title="Редактирование линзы" key={"editLens"}>
|
||
<EditOutlined onClick={() => handleEditLens(lens)}/>
|
||
</Tooltip>,
|
||
<Tooltip title="Удаление линзы" key={"deleteLens"}>
|
||
<Popconfirm
|
||
title="Удаление линзы"
|
||
description="Вы уверены, что хотите удалить линзу?"
|
||
onConfirm={deleteLens}
|
||
okText="Да, удалить"
|
||
cancelText="Отмена"
|
||
>
|
||
<DeleteOutlined
|
||
style={{color: "red"}}
|
||
/>
|
||
</Popconfirm>
|
||
</Tooltip>,
|
||
];
|
||
|
||
return (
|
||
<>
|
||
<Card
|
||
type="inner"
|
||
title={`Линза ${lens.side} ${lens.diameter} мм`}
|
||
actions={actions}
|
||
>
|
||
<p><strong>🔬 Тор:</strong> {lens.tor} D</p>
|
||
<p><strong>📏 Диаметр:</strong> {lens.diameter} мм</p>
|
||
<p><strong>🔄 Пресетная рефракция:</strong> {lens.preset_refraction} D</p>
|
||
<p><strong>⚙️ Периферийная торичность:</strong> {lens.periphery_toricity} D</p>
|
||
{lens.issued && <p><strong>✅ Линза выдана</strong></p>}
|
||
</Card>
|
||
|
||
<LensViewModal
|
||
visible={showModalInfo}
|
||
onCancel={() => setShowModalInfo(false)}
|
||
lens={lens}
|
||
/>
|
||
</>
|
||
);
|
||
};
|
||
|
||
LensListCard.propTypes = {
|
||
lens: LensPropType.isRequired,
|
||
handleEditLens: PropTypes.func.isRequired,
|
||
handleDeleteLens: PropTypes.func.isRequired,
|
||
};
|
||
|
||
export default LensListCard;
|