This commit is contained in:
Николай Полтщук 2023-03-23 16:43:37 +03:00
parent 4d8f7e6c65
commit 6419b9dd97
3 changed files with 23 additions and 25 deletions

View File

@ -1,13 +1,11 @@
import React, { useState } from "react";
import { useDispatch, useSelector } from "react-redux";
import { addProject } from "../../../redux/projectsTrackerSlice";
import { useDispatch } from "react-redux";
import { setProject } from "../../../redux/projectsTrackerSlice";
import "./ModalCreate.scss";
export const ModalCreate = ({ active, setActive, title }) => {
const [inputValue, setInputValue] = useState("");
const projectInfo = useSelector(addProject);
const dispatch = useDispatch();
function createName() {
@ -15,9 +13,9 @@ export const ModalCreate = ({ active, setActive, title }) => {
name: inputValue,
count: 0,
};
dispatch(addProject(newItem));
// console.log(newItem);
dispatch(setProject(newItem));
setActive(false);
setInputValue("")
}
return (

View File

@ -17,24 +17,24 @@ import search from "../../images/search.svg";
import "./tracker.scss";
import { useDispatch, useSelector } from "react-redux";
import { addProject } from "../../redux/projectsTrackerSlice";
import { getProjects } from "../../redux/projectsTrackerSlice";
export const Tracker = () => {
const [toggleTab, setToggleTab] = useState(1);
const [projects] = useState([
{
name: "Разработка трекера",
count: 4,
},
{
name: "Кинотеатр",
count: 4,
},
{
name: "Проект страхование",
count: 4,
},
]);
// const [projects] = useState([
// {
// name: "Разработка трекера",
// count: 4,
// },
// {
// name: "Кинотеатр",
// count: 4,
// },
// {
// name: "Проект страхование",
// count: 4,
// },
// ]);
const [tabTaskMok, setTabTaskMok] = useState([
{
name: "Открытые",
@ -256,8 +256,8 @@ export const Tracker = () => {
false,
]);
// const projectInfo = useSelector(addProject);
// const dispatch = useDispatch();
const projects = useSelector(getProjects);
const dispatch = useDispatch();
const toggleTabs = (index) => {
setToggleTab(index);

View File

@ -21,7 +21,7 @@ export const projectsTrackerSlice = createSlice({
name: "projectsTracker",
initialState,
reducers: {
setProject(state, action) {
setProject: (state, action) => {
state.project.push(action.payload);
},
},
@ -29,6 +29,6 @@ export const projectsTrackerSlice = createSlice({
export const { setProject } = projectsTrackerSlice.actions;
export const addProject = (state) => state.projectsTracker.setProject;
export const getProjects = (state) => state.tracker.project;
export default projectsTrackerSlice.reducer;