71 lines
2.5 KiB
JavaScript
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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 "./LensViewModal.jsx";
import {LensPropType} from "../../types/lensPropType.jsx";
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;