Merge branch 'development' of…

Merge branch 'development' of ssh://git.attractor-school.com:30022/apollo64/crm-team-one into task-94-feature/modal_switch_user
parents 381bc083 bd6399d0
......@@ -5,7 +5,7 @@ const CalendarRow = ({children, week}) => {
<Grid
container
align='center'
sx={{borderBottom: week ? null : '1px solid black', borderRight: '1px solid black', borderLeft: '1px solid black'}}
sx={{borderBottom: week ? null : '1px solid black', borderLeft: '1px solid black'}}
>
{children}
</Grid>
......
import { Grid } from "@mui/material";
import CalendarRow from "../../../MonthCalendar/MonthCalendarBody/CalendarRow/CalendarRow";
import CalendarStandartCell from "../../../MonthCalendar/MonthCalendarBody/CalendarStandartCell.js/CalendarStandartCell";
function CalendarRowDayWeek({week, hoursInDay}) {
return ( <>
<Grid item xs={11.005}>
<CalendarRow week={true}>
{week?.map((weekDay, i)=>{
return (
<Grid item key={i} xs={12/week.length}>
{hoursInDay?.map((hour, i)=>{
return (
<CalendarStandartCell key={i} week={true}>
</CalendarStandartCell>)
})}
</Grid>)
})}
</CalendarRow>
</Grid>
</> );
}
export default CalendarRowDayWeek;
\ No newline at end of file
......@@ -3,9 +3,10 @@ import { Box } from "@mui/system";
import CalendarRow from "../../MonthCalendar/MonthCalendarBody/CalendarRow/CalendarRow";
import CalendarSmallCell from "../../MonthCalendar/MonthCalendarBody/CalendarSmallCell/CalendarSmallCell";
import CalendarStandartCell from "../../MonthCalendar/MonthCalendarBody/CalendarStandartCell.js/CalendarStandartCell";
import CalendarRowDayWeek from "./CalendarRowDayWeek/CalendarRowDayWeek";
import { getCurrentWeekDayString } from "./Helpers";
function WeekCalendarBody({week, hoursInDay, hourFormat, setHourFormat}) {
function WeekCalendarBody({week, hoursInDay, hourFormat, setHourFormat,}) {
return (
<>
......@@ -42,21 +43,11 @@ function WeekCalendarBody({week, hoursInDay, hourFormat, setHourFormat}) {
})}
</Grid>
<Grid item xs={11.005}>
<CalendarRow week={true}>
{week?.map((weekDay, i)=>{
return (
<Grid item key={i} xs={12/week.length}>
{hoursInDay?.map((hour, i)=>{
return (
<CalendarStandartCell key={i} week={true}>
<CalendarRowDayWeek
week={week}
hoursInDay={hoursInDay}
/>
</CalendarStandartCell>)
})}
</Grid>)
})}
</CalendarRow>
</Grid>
</CalendarRow>
</Grid>
</Box>
......
......@@ -58,10 +58,17 @@ export const getWeekFromCurrentDate = (year, month, curDay) => {
export const getWeekInfoString = (week, date) => {
if (week[0] > week[6]) {
if (date.currentDay < week[0]) {
if (date.month === 0) {
return getCurrentMonthString(11) + ' - ' + getCurrentMonthString(0) + ' ' + date.year
}
return getCurrentMonthString(date.month - 1) + ' - ' + getCurrentMonthString(date.month) + ' ' + date.year
} else {
if (date.month === 11) {
return getCurrentMonthString(date.month) + ' - ' + getCurrentMonthString(0) + ' ' + date.year
}
return getCurrentMonthString(date.month) + ' - ' + getCurrentMonthString(date.month + 1) + ' ' + date.year
}
} else {
return getCurrentMonthString(date.month) + ' ' + date.year
}
......
import {getDaysInMonth, getCurrentMonthString, dateToISOLikeButLocal} from '../helpers/CalendarHelpers';
import {getAvailableTasks, getSortedTasks} from '../components/MonthCalendarBody/CalendarRowDay/Helpers'
import {getAvailableTasks, getSortedTasks} from '../components/MonthCalendar/MonthCalendarBody/CalendarRowDay/Helpers'
describe('Получение дней в феврале 2022', () => {
test('Всего дней', () => {
......@@ -33,16 +33,16 @@ describe('Получение дней в ноябре 2022', () => {
describe('Получение месяца', () => {
test('Первый месяц', () => {
expect(getCurrentMonthString({month:0})).toBe("Январь");
expect(getCurrentMonthString(0)).toBe("Январь");
})
test('Последний месяц', () => {
expect(getCurrentMonthString({month:11})).toBe("Декабрь");
expect(getCurrentMonthString(11)).toBe("Декабрь");
})
test('Неккоретное значение выше нормы', () => {
expect(getCurrentMonthString({month:12})).toBe(null);
expect(getCurrentMonthString(12)).toBe(null);
})
test('Неккоретное значение ниже нормы', () => {
expect(getCurrentMonthString({month:-1})).toBe(null);
expect(getCurrentMonthString(-1)).toBe(null);
})
})
......@@ -66,3 +66,60 @@ describe('Получение допустимых задач для клетки
expect(getAvailableTasks([{infoForCell: {startYear: 2021, startMonth: 11, startDay: 12}}, {infoForCell: {startYear: 2022, startMonth: 12, startDay: 12}}], 2022, 11, 12).length).toBe(1);
})
})
describe('Получение сортированных задач', () => {
test('Сортировка прошла успешно Вариант№1', () => {
const tasks = [
{
infoForCell: {
startHour: 12,
endHour: 14
}
},
{
infoForCell: {
startHour: 13,
endHour: 14
}
}]
expect(getSortedTasks(tasks)).toEqual(tasks)
})
test('Сортировка прошла успешно Вариант№2', () => {
const tasks = [
{
infoForCell: {
startHour: 12,
endHour: 14
}
},
{
infoForCell: {
startHour: 10,
endHour: 14
}
}]
expect(getSortedTasks(tasks)).toEqual(tasks.reverse())
})
test('Сортировка прошла успешно Вариант№3', () => {
const tasks = [
{
infoForCell: {
startHour: 12,
endHour: 14
}
},
{
infoForCell: {
startHour: 10,
endHour: 14
}
},
{
infoForCell: {
startHour: 11,
endHour: 12
}
}]
expect(getSortedTasks(tasks)).toEqual([tasks[1], tasks[0], tasks[2]])
})
})
\ No newline at end of file
import { getCurrentWeekDayString } from '../components/WeekCalendar/WeekCalendarBody/Helpers';
import {getWeekFromCurrentDate, getWeekInfoString} from '../helpers/CalendarHelpers';
describe('Получение недели в 7дневном формате', () => {
test('Получение недели 10 декабря 2022', () => {
expect(getWeekFromCurrentDate(2022, 11, 10)).toEqual([5,6,7,8,9,10,11]);
})
test('Получение недели 1 декабря 2022', () => {
expect(getWeekFromCurrentDate(2022, 11, 1)).toEqual([28,29,30,1,2,3,4]);
})
test('Получение недели 1 октября 2023', () => {
expect(getWeekFromCurrentDate(2023, 9, 1)).toEqual([25,26,27,28,29,30,1]);
})
})
describe('Получение информации о неделе', () => {
test('Получение информации о недели 10 декабря 2022', () => {
const date = {month: 11, year: 2022, currentDay: 10}
const week = [5,6,7,8,9,10,11]
expect(getWeekInfoString(week, date)).toBe("Декабрь 2022");
})
test('Получение информации о недели 1 декабря 2022', () => {
const date = {month: 11, year: 2022, currentDay: 1}
const week = [28,29,30,1,2,3,4]
expect(getWeekInfoString(week, date)).toBe("Ноябрь - Декабрь 2022");
})
test('Получение информации о недели 30 ноября 2022', () => {
const date = {month: 10, year: 2022, currentDay: 30}
const week = [28,29,30,1,2,3,4]
expect(getWeekInfoString(week, date)).toBe("Ноябрь - Декабрь 2022");
})
test('Получение информации о недели 31 декабря 2022', () => {
const date = {month: 11, year: 2022, currentDay: 31}
const week = [26,27,28,29,30,31,1]
expect(getWeekInfoString(week, date)).toBe("Декабрь - Январь 2022");
})
test('Получение информации о недели 1 января 2023', () => {
const date = {month: 0, year: 2023, currentDay: 1}
const week = [26,27,28,29,30,31,1]
expect(getWeekInfoString(week, date)).toBe("Декабрь - Январь 2023");
})
test('Получение информации о недели 31 января 2023', () => {
const date = {month: 0, year: 2023, currentDay: 31}
const week = [30,31,1,2,3,4,5]
expect(getWeekInfoString(week, date)).toBe("Январь - Февраль 2023");
})
})
describe('Получение дня недели', () => {
test('Понедельник', () => {
expect(getCurrentWeekDayString(0)).toBe('ПН');
})
test('Четверг', () => {
expect(getCurrentWeekDayString(3)).toBe('ЧТ');
})
test('Воскресенье', () => {
expect(getCurrentWeekDayString(6)).toBe('ВС');
})
test('Неккоретное значение выше нормы', () => {
expect(getCurrentWeekDayString(7)).toBe(null);
})
test('Неккоретное значение ниже нормы', () => {
expect(getCurrentWeekDayString(-1)).toBe(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