Commit 2f475e81 authored by Ermolaev Timur's avatar Ermolaev Timur

#130 начал реализацию другого календаря, чуть изменил расположение файлов для удобства

parent a9661e91
import { Grid } from "@mui/material"; import { Grid } from "@mui/material";
import { memo, useMemo } from "react"; import { memo, useMemo } from "react";
import { getHoursInDayNumbers, getAvailableTasks, getLinesInDay, getSortedTasks } from "../../../../../helpers/CalendarHelpers"; import { getHoursInDayNumbers, getAvailableTasks, getLinesInDay, getSortedTasks } from "../../../../../helpers/CalendarHelpers";
import CalendarStandartCell from "../../../CalendarStandartCell/CalendarStandartCell"; import CalendarStandartCell from "../../../UI/CalendarStandartCell/CalendarStandartCell";
import CalendarTask from "../CalendarTask/CalendarTask"; import CalendarTask from "../CalendarTask/CalendarTask";
import EmptyBox from "./EmptyBox/EmptyBox"; import EmptyBox from "./EmptyBox/EmptyBox";
import { getBoxesInLine } from "./Helpers"; import { getBoxesInLine } from "./Helpers";
......
import { Grid } from "@mui/material"; import { Grid } from "@mui/material";
import React, { memo, useEffect, useState } from "react"; import React, { memo, useEffect, useState } from "react";
import DefaultTask from "../../../../DefaultTask/DefaultTask"; import DefaultTask from "../../../../UI/DefaultTask/DefaultTask";
const EmptyBox = ({ hourNumber, handleOpen, dayNumber, xs, dragTaskHandler, modal, createTaskInCellHandler, copyTask, createCopyTask }) => { const EmptyBox = ({ hourNumber, handleOpen, dayNumber, xs, dragTaskHandler, modal, createTaskInCellHandler, copyTask, createCopyTask }) => {
......
import { Box, FormControlLabel, Switch } from "@mui/material"; import { Box, FormControlLabel, Switch } from "@mui/material";
import { useCallback, useState } from "react"; import { useCallback, useState } from "react";
import CalendarRow from "../../CalendarRow/CalendarRow"; import CalendarRow from "../../UI/CalendarRow/CalendarRow";
import CalendarSmallCell from "../../CalendarSmallCell/CalendarSmallCell"; import CalendarSmallCell from "../../UI/CalendarSmallCell/CalendarSmallCell";
import CalendarStandartCell from "../../CalendarStandartCell/CalendarStandartCell"; import CalendarStandartCell from "../../UI/CalendarStandartCell/CalendarStandartCell";
import ModalTask from "../../ModalTask/ModalTask" import ModalTask from "../../UI/ModalTask/ModalTask"
import MonthCalendarModalContent from "../../CalendarModalTaskContent/CalendarModalTaskContent"; import MonthCalendarModalContent from "../../UI/CalendarModalTaskContent/CalendarModalTaskContent";
import CalendarRowDay from "./CalendarRowDay/CalendarRowDay"; import CalendarRowDay from "./CalendarRowDay/CalendarRowDay";
import { useSelector } from "react-redux"; import { useSelector } from "react-redux";
......
import { AppBar, Button, Toolbar, Typography } from '@mui/material'; import { AppBar, Button, Toolbar, Typography } from '@mui/material';
import { Box } from '@mui/system'; import { Box } from '@mui/system';
import CalendarUserDisplayName from '../../UI/CalendarUserDisplayName/CalendarUserDisplayName';
import MonthAndYearInfo from './MonthAndYearInfo/MonthAndYearInfo'; import MonthAndYearInfo from './MonthAndYearInfo/MonthAndYearInfo';
function MonthCalendarHeader({ currentMonthString, decrementMonth, incrementMonth, year, handleOpen, currentCalendarDisplayName, user, userId}) { function MonthCalendarHeader({ currentMonthString, decrementMonth, incrementMonth, year, handleOpen, currentCalendarDisplayName, user, userId}) {
...@@ -11,9 +12,9 @@ function MonthCalendarHeader({ currentMonthString, decrementMonth, incrementMont ...@@ -11,9 +12,9 @@ function MonthCalendarHeader({ currentMonthString, decrementMonth, incrementMont
<Toolbar> <Toolbar>
<Box> <Box>
<Typography variant="h5" sx={{ margin: "20px 0 20px 0" }}> <CalendarUserDisplayName
Календарь: {currentCalendarDisplayName} currentCalendarDisplayName={currentCalendarDisplayName}
</Typography> />
<MonthAndYearInfo <MonthAndYearInfo
currentMonthString={currentMonthString} currentMonthString={currentMonthString}
decrementMonth={decrementMonth} decrementMonth={decrementMonth}
......
import { Button, TextField } from "@mui/material"; import { Button, TextField } from "@mui/material";
import { memo } from "react"; import { memo } from "react";
import { useSelector } from "react-redux"; import { useSelector } from "react-redux";
import { priorities } from "../../../constants"; import { priorities } from "../../../../constants";
import CustomSelect from '../../UI/СustomSelect/СustomSelect' import CustomSelect from '../../../UI/СustomSelect/СustomSelect'
import { isValidate } from "./Helpers"; import { isValidate } from "./Helpers";
......
import { Typography } from '@mui/material';
function CalendarUserDisplayName({currentCalendarDisplayName}) {
return (
<>
<Typography variant="h5" sx={{ margin: "20px 0 20px 0" }}>
Календарь: {currentCalendarDisplayName}
</Typography>
</>
);
}
export default CalendarUserDisplayName;
\ No newline at end of file
import { useMemo } from "react"; import { useMemo } from "react";
import { getHoursInDayNumbers, getAvailableTasks, getLinesInDay, getSortedTasks } from "../../../../../helpers/CalendarHelpers"; import { getHoursInDayNumbers, getAvailableTasks, getLinesInDay, getSortedTasks } from "../../../../../helpers/CalendarHelpers";
import CalendarStandartCell from "../../../CalendarStandartCell/CalendarStandartCell"; import CalendarStandartCell from "../../../UI/CalendarStandartCell/CalendarStandartCell";
import { useEffect, useRef, useState } from "react"; import { useEffect, useRef, useState } from "react";
import { Grid } from "@mui/material"; import { Grid } from "@mui/material";
import CalendarWeekTask from "./CalendarWeekTask/CalendarWeekTask"; import CalendarWeekTask from "./CalendarWeekTask/CalendarWeekTask";
......
import { Grid } from "@mui/material"; import { Grid } from "@mui/material";
import { Box } from "@mui/system"; import { Box } from "@mui/system";
import { useCallback, useState } from "react"; import { useCallback, useState } from "react";
import ModalTask from "../../ModalTask/ModalTask"; import ModalTask from "../../UI/ModalTask/ModalTask";
import CalendarModalTaskContent from "../../CalendarModalTaskContent/CalendarModalTaskContent"; import CalendarModalTaskContent from "../../UI/CalendarModalTaskContent/CalendarModalTaskContent";
import CalendarRow from "../../CalendarRow/CalendarRow"; import CalendarRow from "../../UI/CalendarRow/CalendarRow";
import CalendarSmallCell from "../../CalendarSmallCell/CalendarSmallCell"; import CalendarSmallCell from "../../UI/CalendarSmallCell/CalendarSmallCell";
import CalendarStandartCell from "../../CalendarStandartCell/CalendarStandartCell"; import CalendarStandartCell from "../../UI/CalendarStandartCell/CalendarStandartCell";
import HourFormatSwitch from "../../HourFormatSwitch/HourFormatSwitch"; import HourFormatSwitch from "../../UI/HourFormatSwitch/HourFormatSwitch";
import CalendarColumnDayWeek from "./CalendarColumnDayWeek/CalendarColumnDayWeek"; import CalendarColumnDayWeek from "./CalendarColumnDayWeek/CalendarColumnDayWeek";
import { getCurrentWeekDayString, getMonthToDayColumn } from "./Helpers"; import { getCurrentWeekDayString, getMonthToDayColumn } from "./Helpers";
......
...@@ -6,16 +6,18 @@ import WeekCalendarHeader from '../../components/Calendars/WeekCalendar/WeekCale ...@@ -6,16 +6,18 @@ import WeekCalendarHeader from '../../components/Calendars/WeekCalendar/WeekCale
import { getWeekInfoString, getWeekFromCurrentDate, dateToISOLikeButLocal } from '../../helpers/CalendarHelpers'; import { getWeekInfoString, getWeekFromCurrentDate, dateToISOLikeButLocal } from '../../helpers/CalendarHelpers';
import { fetchAllUserProjects } from '../../store/actions/projectsActions'; import { fetchAllUserProjects } from '../../store/actions/projectsActions';
import { addCalendarTask, addCopyCalendarTask, deleteCalendarTask, editCalendarTask, fetchCalendarTasks } from '../../store/actions/tasksActions'; import { addCalendarTask, addCopyCalendarTask, deleteCalendarTask, editCalendarTask, fetchCalendarTasks } from '../../store/actions/tasksActions';
import { fetchCurrentCalendarDisplayName } from '../../store/actions/usersActions';
function WeekCalendar() { function WeekCalendar() {
const dispatch = useDispatch(); const dispatch = useDispatch();
const { calendarTasks } = useSelector(state => state.tasks); const { calendarTasks } = useSelector(state => state.tasks);
const { allUserProjects } = useSelector(state => state.projects) const { user, currentCalendarDisplayName } = useSelector(state => state.users);
const user = useSelector(state => state.users?.user); const { allUserProjects, project } = useSelector(state => state.projects)
const [copyTask, setCopyTask] = useState(null) const [copyTask, setCopyTask] = useState(null)
const [weekGoal, setWeekGoal] = useState('Наладить режим сна') const [weekGoal, setWeekGoal] = useState('Наладить режим сна')
const [userCalendarId, setUserCalendarId] = useState(null)
const [weekPriorities, setWeekPriorities] = useState({ priorityOne: 'Один', priorityTwo: 'Два', priorityThree: 'Три' }) const [weekPriorities, setWeekPriorities] = useState({ priorityOne: 'Один', priorityTwo: 'Два', priorityThree: 'Три' })
const [dateNow, setDateNow] = useState({ year: '', month: '', currentDay: '' }) const [dateNow, setDateNow] = useState({ year: '', month: '', currentDay: '' })
const [currentTask, setCurrentTask] = useState({ title: '', description: '', priority: null, infoForCell: { startHour: null, endHour: null } }) const [currentTask, setCurrentTask] = useState({ title: '', description: '', priority: null, infoForCell: { startHour: null, endHour: null } })
...@@ -29,9 +31,22 @@ function WeekCalendar() { ...@@ -29,9 +31,22 @@ function WeekCalendar() {
setDateNow({ year: year, month: month, currentDay: currentDay }) setDateNow({ year: year, month: month, currentDay: currentDay })
dispatch(fetchCalendarTasks(user.id)) dispatch(fetchCalendarTasks(user.id))
dispatch(fetchAllUserProjects()) dispatch(fetchAllUserProjects())
setUserId(user.id)
}, [dispatch, user.id]) }, [dispatch, user.id])
useEffect(() => {
if (userCalendarId) {
setUserId(userCalendarId)
dispatch(fetchCalendarTasks(userCalendarId))
dispatch(fetchCurrentCalendarDisplayName(userCalendarId))
dispatch(fetchAllUserProjects())
} else {
setUserId(user.id)
dispatch(fetchCalendarTasks(user.id))
dispatch(fetchCurrentCalendarDisplayName(user.id))
dispatch(fetchAllUserProjects())
}
}, [userCalendarId, dispatch, user.id])
const hoursInDay = useMemo(() => { const hoursInDay = useMemo(() => {
let arr let arr
if (hourFormat) { if (hourFormat) {
......
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