Функц кнопки убраты
This commit is contained in:
parent
b45991ed26
commit
e040fd5ce6
@ -4,7 +4,7 @@ import {
|
||||
} from 'react-bootstrap-icons';
|
||||
|
||||
const UpdateNew = ({
|
||||
item, onEdit, onDelete,
|
||||
item, onEdit, onDelete, obj,
|
||||
}) => {
|
||||
const handleAnchorClick = (event, action) => {
|
||||
event.preventDefault();
|
||||
@ -16,8 +16,15 @@ const UpdateNew = ({
|
||||
<img src={item.image} width="100%" alt={item.name} />
|
||||
<div className="rectNewsTextBox text-center">
|
||||
<span className="rectNewsText">
|
||||
<a href="#" onClick={(event) => handleAnchorClick(event, onEdit)}><PencilFill /></a>
|
||||
<a href="#" onClick={(event) => handleAnchorClick(event, onDelete)}><Trash3 /></a>
|
||||
{obj === null || obj.role === 'user' ? (
|
||||
<>
|
||||
</>
|
||||
) : (
|
||||
<>
|
||||
<a href="#" onClick={(event) => handleAnchorClick(event, onEdit)}><PencilFill /></a>
|
||||
<a href="#" onClick={(event) => handleAnchorClick(event, onDelete)}><Trash3 /></a>
|
||||
</>
|
||||
)}
|
||||
{item.description}
|
||||
</span>
|
||||
</div>
|
||||
@ -31,6 +38,7 @@ UpdateNew.propTypes = {
|
||||
item: PropTypes.object,
|
||||
onDelete: PropTypes.func,
|
||||
onEdit: PropTypes.func,
|
||||
obj: PropTypes.func,
|
||||
};
|
||||
|
||||
export default UpdateNew;
|
||||
|
@ -18,7 +18,7 @@ import { AuthContext } from '../../logins/login/context/AuthContext.jsx';
|
||||
// должно все перерисовываться
|
||||
|
||||
const UpdateNews = () => {
|
||||
const { state, dispatch } = useContext(AuthContext);
|
||||
const { state } = useContext(AuthContext);
|
||||
|
||||
let obj = null;
|
||||
if (state.user !== null) {
|
||||
@ -64,6 +64,7 @@ const UpdateNews = () => {
|
||||
lines.map((item) => {
|
||||
return <UpdateNew key={item.id}
|
||||
item={item}
|
||||
obj = {obj}
|
||||
/>;
|
||||
})}
|
||||
</div>
|
||||
@ -77,7 +78,7 @@ const UpdateNews = () => {
|
||||
type='text' required />
|
||||
<div className="text-center">
|
||||
<Button variant='info' onClick={() => showFormModal()}>
|
||||
Добавить товар</Button>
|
||||
Добавить Новость</Button>
|
||||
</div>
|
||||
|
||||
<div className="mainDiv row">
|
||||
@ -87,6 +88,7 @@ const UpdateNews = () => {
|
||||
item={item}
|
||||
onDelete={() => showDeleteModal(item.id)}
|
||||
onEdit={() => showFormModal(item.id)}
|
||||
obj = {obj}
|
||||
/>;
|
||||
})}
|
||||
</div>
|
||||
|
Loading…
Reference in New Issue
Block a user