Commit d0304198 authored by Ermolaev Timur's avatar Ermolaev Timur

#159 пофиксил баги с отображением данных в инпуте, а также с вылетами

parent fe9eacab
...@@ -47,6 +47,7 @@ function CalendarModalTaskContent({ title, onChangeCurrentTaskHandler, descripti ...@@ -47,6 +47,7 @@ function CalendarModalTaskContent({ title, onChangeCurrentTaskHandler, descripti
value={project} value={project}
name={'project'} name={'project'}
variant={'outlined'} variant={'outlined'}
renderValue={(project)=>project?.title}
onChange={(e) => { onChangeCurrentTaskHandler(e) }} onChange={(e) => { onChangeCurrentTaskHandler(e) }}
label={'Проект'} label={'Проект'}
id={'project'} id={'project'}
......
...@@ -4,7 +4,7 @@ import MultipleSelect from "../../UI/MultipleSelect/MultipleSelect"; ...@@ -4,7 +4,7 @@ import MultipleSelect from "../../UI/MultipleSelect/MultipleSelect";
import CreateTaskFromButton from "./CreateTaskFromButton/CreateTaskFromButton"; import CreateTaskFromButton from "./CreateTaskFromButton/CreateTaskFromButton";
function MyTasksTableToolbar({ addFormStatus, createTaskFromButtonHandler, projects, onCloseFilterByProjects, projectIdListForTaskSelect, setProjectIdListForTaskSelect, activeTasksOn, setActiveTasksOn }) { function MyTasksTableToolbar({ addFormStatus, createTaskFromButtonHandler, projects, onCloseFilterByProjects, projectIdListForTaskSelect, setProjectIdListForTaskSelect, activeTasksStatus, setActiveTasksStatus }) {
const projectsFilter = useMemo(() => { const projectsFilter = useMemo(() => {
if (Array.isArray(projects)) { if (Array.isArray(projects)) {
...@@ -31,7 +31,7 @@ function MyTasksTableToolbar({ addFormStatus, createTaskFromButtonHandler, proje ...@@ -31,7 +31,7 @@ function MyTasksTableToolbar({ addFormStatus, createTaskFromButtonHandler, proje
Мои задачи Мои задачи
</Typography> </Typography>
<FormControlLabel <FormControlLabel
control={<Switch color='error' checked={activeTasksOn} onChange={() => { setActiveTasksOn(prevState=>!prevState) }} />} control={<Switch color='error' checked={activeTasksStatus} onChange={() => { setActiveTasksStatus(prevState=>!prevState) }} />}
label="Активные задачи" label="Активные задачи"
labelPlacement="end" labelPlacement="end"
/> />
......
import { Button } from "@mui/material"; import { Button, TextField } from "@mui/material";
import { Box } from "@mui/system"; import { Box } from "@mui/system";
import { memo } from "react"; import { memo } from "react";
import FormElement from "../../UI/Form/FormElement/FormElement"
import { isValidate } from "./helpers"; import { isValidate } from "./helpers";
...@@ -9,18 +8,21 @@ const NewProjectModalContent = ({ inputChangeHandler, projectTitle, createNewPro ...@@ -9,18 +8,21 @@ const NewProjectModalContent = ({ inputChangeHandler, projectTitle, createNewPro
return <> return <>
<FormElement <TextField
onChange={(e)=>{inputChangeHandler(e)}} onChange={(e) => { inputChangeHandler(e) }}
name={"title"} name={"title"}
label={"Название"} label={"Название"}
state={projectTitle} value={projectTitle}
id="project-title"
variant="outlined"
sx={{width: '100%'}}
/> />
<Box sx={{ display: 'flex', justifyContent: 'space-between', marginTop: '10px'}}> <Box sx={{ display: 'flex', justifyContent: 'space-between', marginTop: '10px' }}>
<Button <Button
type="submit" type="submit"
color="primary" color="primary"
variant="outlined" variant="outlined"
onClick={()=>{createNewProjectHandler()}} onClick={() => { createNewProjectHandler() }}
disabled={!isValidate(projectTitle)} disabled={!isValidate(projectTitle)}
> >
Создать Создать
...@@ -29,7 +31,7 @@ const NewProjectModalContent = ({ inputChangeHandler, projectTitle, createNewPro ...@@ -29,7 +31,7 @@ const NewProjectModalContent = ({ inputChangeHandler, projectTitle, createNewPro
type="submit" type="submit"
color="primary" color="primary"
variant="outlined" variant="outlined"
onClick={()=>{handleClose()}} onClick={() => { handleClose() }}
> >
Отмена Отмена
</Button> </Button>
......
...@@ -4,7 +4,7 @@ import MultipleSelect from "../../UI/MultipleSelect/MultipleSelect"; ...@@ -4,7 +4,7 @@ import MultipleSelect from "../../UI/MultipleSelect/MultipleSelect";
import CreateTaskFromButton from "./CreateTaskFromButton/CreateTaskFromButton"; import CreateTaskFromButton from "./CreateTaskFromButton/CreateTaskFromButton";
function UsersTasksTableToolbar({ addFormStatus, createTaskFromButtonHandler, projects, onCloseFilterByProjects, projectIdListForTaskSelect, setProjectIdListForTaskSelect, activeTasksOn, setActiveTasksOn}) { function UsersTasksTableToolbar({ addFormStatus, createTaskFromButtonHandler, projects, onCloseFilterByProjects, projectIdListForTaskSelect, setProjectIdListForTaskSelect, activeTasksStatus, setActiveTasksStatus}) {
const projectsFilter = useMemo(() => { const projectsFilter = useMemo(() => {
if (Array.isArray(projects)) { if (Array.isArray(projects)) {
...@@ -31,7 +31,7 @@ return ( ...@@ -31,7 +31,7 @@ return (
Задачи сотрудников Задачи сотрудников
</Typography> </Typography>
<FormControlLabel <FormControlLabel
control={<Switch color='error' checked={activeTasksOn} onChange={() => { setActiveTasksOn(prevState=>!prevState) }} />} control={<Switch color='error' checked={activeTasksStatus} onChange={() => { setActiveTasksStatus(prevState=>!prevState) }} />}
label="Активные задачи" label="Активные задачи"
labelPlacement="end" labelPlacement="end"
/> />
......
...@@ -149,7 +149,7 @@ function MonthCalendar() { ...@@ -149,7 +149,7 @@ function MonthCalendar() {
endHour: hourDue, endHour: hourDue,
startDay: dayNumber startDay: dayNumber
}, },
project: allUserProjects[0].id project: allUserProjects[0]
} }
setCurrentTask((newTask)) setCurrentTask((newTask))
}, [dateNow.month, dateNow.year, hourFormat, allUserProjects]) }, [dateNow.month, dateNow.year, hourFormat, allUserProjects])
......
...@@ -39,7 +39,7 @@ export default function MyTasks() { ...@@ -39,7 +39,7 @@ export default function MyTasks() {
const [rowsPerPage, setRowsPerPage] = useState(10); const [rowsPerPage, setRowsPerPage] = useState(10);
const [addFormStatus, setAddFormStatus] = useState(false); const [addFormStatus, setAddFormStatus] = useState(false);
const [projectIdListForTaskSelect, setProjectIdListForTaskSelect] = useState([]); const [projectIdListForTaskSelect, setProjectIdListForTaskSelect] = useState([]);
const [activeTasksOn, setActiveTasksOn] = useState(false) const [activeTasksStatus, setActiveTasksStatus] = useState(false)
useEffect(() => { useEffect(() => {
dispatch(fetchAllTasks()); dispatch(fetchAllTasks());
...@@ -48,8 +48,8 @@ export default function MyTasks() { ...@@ -48,8 +48,8 @@ export default function MyTasks() {
}, [dispatch]); }, [dispatch]);
useEffect(() => { useEffect(() => {
dispatch(sortTaskByProjects(projectIdListForTaskSelect, activeTasksOn)) dispatch(sortTaskByProjects(projectIdListForTaskSelect, activeTasksStatus))
}, [dispatch, projectIdListForTaskSelect, activeTasksOn, tasks]); }, [dispatch, projectIdListForTaskSelect, activeTasksStatus, tasks]);
const onChangeNewTaskHandler = useCallback((e) => { const onChangeNewTaskHandler = useCallback((e) => {
...@@ -184,8 +184,8 @@ export default function MyTasks() { ...@@ -184,8 +184,8 @@ export default function MyTasks() {
projectIdListForTaskSelect={projectIdListForTaskSelect} projectIdListForTaskSelect={projectIdListForTaskSelect}
setProjectIdListForTaskSelect={setProjectIdListForTaskSelect} setProjectIdListForTaskSelect={setProjectIdListForTaskSelect}
projects={projects.projects} projects={projects.projects}
activeTasksOn={activeTasksOn} activeTasksStatus={activeTasksStatus}
setActiveTasksOn={setActiveTasksOn} setActiveTasksStatus={setActiveTasksStatus}
/> />
<MyTasksTableContainer <MyTasksTableContainer
order={order} order={order}
......
...@@ -4,7 +4,6 @@ import { useDispatch, useSelector } from "react-redux"; ...@@ -4,7 +4,6 @@ import { useDispatch, useSelector } from "react-redux";
import { createProject, deleteProject, fetchProjects } from "../../store/actions/projectsActions"; import { createProject, deleteProject, fetchProjects } from "../../store/actions/projectsActions";
import FullProject from "../FullProject/FullProject"; import FullProject from "../FullProject/FullProject";
import ProjectsWrapper from "../../components/ProjectsComponents/ProjectsWrapper/ProjectsWrapper"; import ProjectsWrapper from "../../components/ProjectsComponents/ProjectsWrapper/ProjectsWrapper";
import { useNavigate } from "react-router-dom";
import DefaultModal from "../../components/UI/DefaultModal/DefaultModal"; import DefaultModal from "../../components/UI/DefaultModal/DefaultModal";
import NewProjectModalContent from "../../components/ProjectsComponents/NewProjectModalContent/NewProjectModalContent"; import NewProjectModalContent from "../../components/ProjectsComponents/NewProjectModalContent/NewProjectModalContent";
...@@ -13,7 +12,6 @@ const Projects = () => { ...@@ -13,7 +12,6 @@ const Projects = () => {
const { user } = useSelector(state => state.users) const { user } = useSelector(state => state.users)
const dispatch = useDispatch(); const dispatch = useDispatch();
const navigate = useNavigate()
const [currentProject, setCurrentProject] = useState(null) const [currentProject, setCurrentProject] = useState(null)
const [projectTitle, setProjectTitle] = useState(''); const [projectTitle, setProjectTitle] = useState('');
...@@ -47,11 +45,10 @@ const Projects = () => { ...@@ -47,11 +45,10 @@ const Projects = () => {
const handleClose = useCallback(() => { const handleClose = useCallback(() => {
setModal(false) setModal(false)
setProjectTitle('')
}, []) }, [])
console.log(currentProject)
return <> return <>
<Grid container justifyContent='space-between'> <Grid container justifyContent='space-between'>
......
...@@ -40,7 +40,7 @@ export default function UsersTasks() { ...@@ -40,7 +40,7 @@ export default function UsersTasks() {
const [rowsPerPage, setRowsPerPage] = useState(10); const [rowsPerPage, setRowsPerPage] = useState(10);
const [addFormStatus, setAddFormStatus] = useState(false); const [addFormStatus, setAddFormStatus] = useState(false);
const [projectIdListForTaskSelect, setProjectIdListForTaskSelect] = useState([]); const [projectIdListForTaskSelect, setProjectIdListForTaskSelect] = useState([]);
const [activeTasksOn, setActiveTasksOn] = useState(false) const [activeTasksStatus, setActiveTasksStatus] = useState(false)
useEffect(() => { useEffect(() => {
dispatch(fetchAllTasksByMembership()); dispatch(fetchAllTasksByMembership());
...@@ -49,8 +49,8 @@ export default function UsersTasks() { ...@@ -49,8 +49,8 @@ export default function UsersTasks() {
}, [dispatch]); }, [dispatch]);
useEffect(() => { useEffect(() => {
dispatch(sortTaskByProjects(projectIdListForTaskSelect, activeTasksOn)) dispatch(sortTaskByProjects(projectIdListForTaskSelect, activeTasksStatus))
}, [dispatch, projectIdListForTaskSelect, activeTasksOn, tasks]); }, [dispatch, projectIdListForTaskSelect, activeTasksStatus, tasks]);
const onChangeNewTaskHandler = useCallback((e) => { const onChangeNewTaskHandler = useCallback((e) => {
...@@ -195,8 +195,8 @@ export default function UsersTasks() { ...@@ -195,8 +195,8 @@ export default function UsersTasks() {
projectIdListForTaskSelect={projectIdListForTaskSelect} projectIdListForTaskSelect={projectIdListForTaskSelect}
setProjectIdListForTaskSelect={setProjectIdListForTaskSelect} setProjectIdListForTaskSelect={setProjectIdListForTaskSelect}
projects={projects.projects} projects={projects.projects}
activeTasksOn={activeTasksOn} activeTasksStatus={activeTasksStatus}
setActiveTasksOn={setActiveTasksOn} setActiveTasksStatus={setActiveTasksStatus}
/> />
<UsersTasksTableContainer <UsersTasksTableContainer
order={order} order={order}
......
...@@ -87,7 +87,7 @@ function WeekCalendar() { ...@@ -87,7 +87,7 @@ function WeekCalendar() {
}, []) }, [])
const onChangeProjectHandler = useCallback((e, value) => { const onChangeProjectHandler = useCallback((e, value) => {
setWorkerInfo((prevState) => { return { ...prevState, project: value.id } }); setWorkerInfo((prevState) => { return { ...prevState, project: value } });
}, []); }, []);
const onChangeWorkerHandler = useCallback((e, value) => { const onChangeWorkerHandler = useCallback((e, value) => {
...@@ -148,7 +148,7 @@ function WeekCalendar() { ...@@ -148,7 +148,7 @@ function WeekCalendar() {
month: month, month: month,
startYear: year, startYear: year,
}, },
project: allUserProjects[0]?.id project: allUserProjects[0]
} }
setCurrentTask((newTask)) setCurrentTask((newTask))
}, [hourFormat, allUserProjects]) }, [hourFormat, allUserProjects])
......
...@@ -135,7 +135,7 @@ export const addTask = (task) => { ...@@ -135,7 +135,7 @@ export const addTask = (task) => {
return async (dispatch) => { return async (dispatch) => {
dispatch(addTaskRequest()); dispatch(addTaskRequest());
try { try {
const response = await axios.post("/tasks", task); await axios.post("/tasks", task);
dispatch(addTaskSuccess()) dispatch(addTaskSuccess())
dispatch(fetchAllTasks()) dispatch(fetchAllTasks())
} catch (error) { } catch (error) {
......
...@@ -48,7 +48,7 @@ const tasksReduсer = (state = initialState, action) => { ...@@ -48,7 +48,7 @@ const tasksReduсer = (state = initialState, action) => {
for (let copy of task.dateTimeTasks) { for (let copy of task.dateTimeTasks) {
newTasksWithoutInfoForCell.push({ newTasksWithoutInfoForCell.push({
...copy, ...copy,
project: task?.project?.id, project: task?.project,
mainTaskId: task.id, mainTaskId: task.id,
executor: task.executor, executor: task.executor,
author: task.author, author: task.author,
......
...@@ -15,15 +15,12 @@ const usersReducer = (state = initialState, action) => { ...@@ -15,15 +15,12 @@ const usersReducer = (state = initialState, action) => {
case REGISTER_USER_REQUEST: case REGISTER_USER_REQUEST:
return {...state, loading: true}; return {...state, loading: true};
case REGISTER_USER_SUCCESS: case REGISTER_USER_SUCCESS:
console.log("register.user " , action)
return {...state, loading: false}; return {...state, loading: false};
case REGISTER_USER_FAILURE: case REGISTER_USER_FAILURE:
return {...state, loading: false, registerError: action.error}; return {...state, loading: false, registerError: action.error};
case LOGIN_USER_SUCCESS: case LOGIN_USER_SUCCESS:
console.log("action.user " , action)
return {...state, user: action.user}; return {...state, user: action.user};
case LOGIN_USER_FAILURE: case LOGIN_USER_FAILURE:
console.log("action.error" , action.error)
return {...state, loginError: action.error}; return {...state, loginError: action.error};
case LOGOUT_USER_SUCCESS: case LOGOUT_USER_SUCCESS:
return {...state, user: null}; return {...state, user: null};
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment