2023-03-22 21:48:06 +03:00
|
|
|
import React, { useState } from "react";
|
2023-03-23 16:43:37 +03:00
|
|
|
import { useDispatch } from "react-redux";
|
2023-03-27 19:08:01 +03:00
|
|
|
import { setProject } from "../../../redux/projectsTrackerSlice";
|
2023-03-22 21:48:06 +03:00
|
|
|
|
|
|
|
import "./ModalCreate.scss";
|
|
|
|
|
2023-04-03 14:37:27 +03:00
|
|
|
export const ModalCreate = ({ active, setActive, title, desc }) => {
|
2023-03-22 21:48:06 +03:00
|
|
|
const [inputValue, setInputValue] = useState("");
|
|
|
|
const dispatch = useDispatch();
|
|
|
|
|
|
|
|
function createName() {
|
2023-03-27 19:08:01 +03:00
|
|
|
if (inputValue === "") {
|
|
|
|
return;
|
|
|
|
} else {
|
|
|
|
let newItem = {
|
|
|
|
name: inputValue,
|
|
|
|
count: 0,
|
|
|
|
};
|
|
|
|
dispatch(setProject(newItem));
|
|
|
|
setActive(false);
|
|
|
|
setInputValue("");
|
|
|
|
}
|
2023-03-22 21:48:06 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
return (
|
|
|
|
<div
|
|
|
|
className={active ? "modal-project active" : "modal-project"}
|
|
|
|
onClick={() => setActive(false)}
|
|
|
|
>
|
|
|
|
<div
|
|
|
|
className="modal-project__content"
|
|
|
|
onClick={(e) => e.stopPropagation()}
|
|
|
|
>
|
|
|
|
<div className="title-project">
|
|
|
|
<h4>{title}</h4>
|
2023-04-03 14:37:27 +03:00
|
|
|
<p>{desc}</p>
|
2023-03-22 21:48:06 +03:00
|
|
|
<div className="input-container">
|
|
|
|
<input
|
|
|
|
className="name-project"
|
|
|
|
value={inputValue}
|
|
|
|
onChange={(e) => setInputValue(e.target.value)}
|
|
|
|
></input>
|
|
|
|
</div>
|
2023-03-29 19:43:49 +03:00
|
|
|
<button className="create-project" onClick={createName}>
|
|
|
|
Создать
|
|
|
|
</button>
|
2023-03-22 21:48:06 +03:00
|
|
|
</div>
|
2023-03-29 19:43:49 +03:00
|
|
|
<span className="exit" onClick={() => setActive(false)}></span>
|
2023-03-22 21:48:06 +03:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
export default ModalCreate;
|