calendar routes
This commit is contained in:
parent
4629bc74a9
commit
d4ec833a31
@ -17,7 +17,7 @@ const getDateParamString = ({ paramName, value }) => {
|
|||||||
return value ? `${paramName}=${value}` : ''
|
return value ? `${paramName}=${value}` : ''
|
||||||
}
|
}
|
||||||
|
|
||||||
const Calendar = () => {
|
const Calendar = ({ onSelect }) => {
|
||||||
const dispatch = useDispatch()
|
const dispatch = useDispatch()
|
||||||
const candidateForCalendar = useSelector(selectCurrentCandidate)
|
const candidateForCalendar = useSelector(selectCurrentCandidate)
|
||||||
const role = useSelector(getRole)
|
const role = useSelector(getRole)
|
||||||
@ -28,22 +28,22 @@ const Calendar = () => {
|
|||||||
|
|
||||||
const history = useHistory()
|
const history = useHistory()
|
||||||
|
|
||||||
useEffect(() => {
|
// useEffect(() => {
|
||||||
fetchReportList({
|
// fetchReportList({
|
||||||
link: `${
|
// link: `${
|
||||||
process.env.REACT_APP_API_URL
|
// process.env.REACT_APP_API_URL
|
||||||
}/api/reports/index?user_id=${userId}${getDateParamString({
|
// }/api/reports/index?user_id=${userId}${getDateParamString({
|
||||||
paramName: 'fromDate',
|
// paramName: 'fromDate',
|
||||||
value: fromDate
|
// value: fromDate
|
||||||
})}${getDateParamString({
|
// })}${getDateParamString({
|
||||||
paramName: 'toDate',
|
// paramName: 'toDate',
|
||||||
value: toDate
|
// value: toDate
|
||||||
})}`,
|
// })}`,
|
||||||
history,
|
// history,
|
||||||
role,
|
// role,
|
||||||
logout: () => dispatch(auth(false))
|
// logout: () => {}
|
||||||
})
|
// })
|
||||||
}, [])
|
// }, [])
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setMonth(currentMonth)
|
setMonth(currentMonth)
|
||||||
@ -78,7 +78,7 @@ const Calendar = () => {
|
|||||||
|
|
||||||
<div className='row'>
|
<div className='row'>
|
||||||
<div className='col-12 col-xl-12'>
|
<div className='col-12 col-xl-12'>
|
||||||
<CalendarComponent />
|
<CalendarComponent onSelect={onSelect} />
|
||||||
<p className='calendar__hours'>
|
<p className='calendar__hours'>
|
||||||
{month} : <span> 60 часов </span>
|
{month} : <span> 60 часов </span>
|
||||||
</p>
|
</p>
|
||||||
|
@ -4,11 +4,11 @@ import rectangle from '../../images/rectangle__calendar.png'
|
|||||||
import calendarIcon from '../../images/calendar_icon.png'
|
import calendarIcon from '../../images/calendar_icon.png'
|
||||||
import moment from 'moment'
|
import moment from 'moment'
|
||||||
import 'moment/locale/ru'
|
import 'moment/locale/ru'
|
||||||
import { calendarHelper, currentMonthAndDay } from './calendarHelper'
|
import { calendarHelper, currentMonthAndDay, } from './calendarHelper'
|
||||||
|
|
||||||
import './calendarComponent.scss'
|
import './calendarComponent.scss'
|
||||||
|
|
||||||
const CalendarComponent = () => {
|
const CalendarComponent = ({ onSelect }) => {
|
||||||
const [value, setValue] = useState(moment())
|
const [value, setValue] = useState(moment())
|
||||||
const [calendar, setCalendar] = useState([])
|
const [calendar, setCalendar] = useState([])
|
||||||
|
|
||||||
@ -36,14 +36,7 @@ const CalendarComponent = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function nextMonth() {
|
function nextMonth() {
|
||||||
return value.clone().subtract(2, 'month')
|
return value.clone().add(1, 'month');
|
||||||
}
|
|
||||||
|
|
||||||
const prevMonthFirst = () => {
|
|
||||||
return moment().subtract(1, 'month').format('MMMM')
|
|
||||||
}
|
|
||||||
const prevMonthSecond = () => {
|
|
||||||
return moment().subtract(2, 'month').format('MMMM')
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@ -52,11 +45,11 @@ const CalendarComponent = () => {
|
|||||||
<h3>Мои отчеты</h3>
|
<h3>Мои отчеты</h3>
|
||||||
<div className='calendar-component__header-box'>
|
<div className='calendar-component__header-box'>
|
||||||
<img src={ellipse} alt='' />
|
<img src={ellipse} alt='' />
|
||||||
<span onClick={() => setValue(prevMonth())}>{prevMonthFirst()}</span>
|
<span onClick={() => setValue(prevMonth())}>{prevMonth().format('MMMM')}</span>
|
||||||
</div>
|
</div>
|
||||||
<div className='calendar-component__header-box'>
|
<div className='calendar-component__header-box'>
|
||||||
<img src={ellipse} alt='' />
|
<img src={ellipse} alt='' />
|
||||||
<span onClick={() => setValue(nextMonth())}>{prevMonthSecond()}</span>
|
<span onClick={() => setValue(nextMonth())}>{nextMonth().format('MMMM')}</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@ -79,7 +72,7 @@ const CalendarComponent = () => {
|
|||||||
{calendar.map((week) =>
|
{calendar.map((week) =>
|
||||||
week.map((day) => (
|
week.map((day) => (
|
||||||
<button
|
<button
|
||||||
onClick={() => setValue(day)}
|
onClick={() => { setValue(day); onSelect(day) }}
|
||||||
key={day}
|
key={day}
|
||||||
className={dayStyles(day)}
|
className={dayStyles(day)}
|
||||||
name={day.format('dddd')}
|
name={day.format('dddd')}
|
||||||
|
@ -31,7 +31,7 @@ const Candidate = () => {
|
|||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
fetchGet({
|
fetchGet({
|
||||||
link: `${process.env.REACT_APP_API_URL}/api/profile/`,
|
link: `${process.env.REACT_APP_API_URL}/api/profile/${candidateId}`,
|
||||||
params: Number(candidateId),
|
params: Number(candidateId),
|
||||||
history,
|
history,
|
||||||
role,
|
role,
|
||||||
|
@ -45,6 +45,11 @@ const CandidateSidebar = ({ candidate, position }) => {
|
|||||||
Выбрать к собеседованию
|
Выбрать к собеседованию
|
||||||
</button>
|
</button>
|
||||||
</Link>
|
</Link>
|
||||||
|
<Link to={`/${candidate.id}/calendar`}>
|
||||||
|
<button className='candidate-sidebar__select'>
|
||||||
|
Отчёты
|
||||||
|
</button>
|
||||||
|
</Link>
|
||||||
<div className='candidate-sidebar__achievements'>
|
<div className='candidate-sidebar__achievements'>
|
||||||
{candidate &&
|
{candidate &&
|
||||||
candidate.achievements &&
|
candidate.achievements &&
|
||||||
|
@ -85,7 +85,7 @@
|
|||||||
line-height: normal;
|
line-height: normal;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
margin-top: 20px;
|
margin-top: 20px;
|
||||||
margin-bottom: 40px;
|
margin-bottom: 10px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.candidate-sidebar__select:hover {
|
.candidate-sidebar__select:hover {
|
||||||
|
@ -1,9 +1,11 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
|
import { useHistory } from 'react-router';
|
||||||
import { WithLogout } from '../hoc/withLogout';
|
import { WithLogout } from '../hoc/withLogout';
|
||||||
import Calendar from '../components/Calendar/Calendar';
|
import Calendar from '../components/Calendar/Calendar';
|
||||||
|
|
||||||
const CalendarPage = () => {
|
const CalendarPage = () => {
|
||||||
return <WithLogout><Calendar /></WithLogout>;
|
const history = useHistory();
|
||||||
|
return <WithLogout><Calendar onSelect={() => { history.push('/report/0') }} /></WithLogout>;
|
||||||
};
|
};
|
||||||
|
|
||||||
export default CalendarPage;
|
export default CalendarPage;
|
||||||
|
21
src/redux/reportSlice.js
Normal file
21
src/redux/reportSlice.js
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
import { createSlice } from '@reduxjs/toolkit';
|
||||||
|
|
||||||
|
const initialState = {
|
||||||
|
dateSelected: '',
|
||||||
|
};
|
||||||
|
|
||||||
|
export const reportSlice = createSlice({
|
||||||
|
name: 'report',
|
||||||
|
initialState,
|
||||||
|
reducers: {
|
||||||
|
dateSelected: (state, action) => {
|
||||||
|
state.dateSelected = action.payload;
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
export const { dateSelected, } = reportSlice.actions;
|
||||||
|
|
||||||
|
export const selectDate = (state) => state.report.dateSelected;
|
||||||
|
|
||||||
|
export default reportSlice.reducer;
|
@ -2,11 +2,13 @@ import { configureStore } from '@reduxjs/toolkit';
|
|||||||
import outstaffingReducer from '../redux/outstaffingSlice';
|
import outstaffingReducer from '../redux/outstaffingSlice';
|
||||||
import loaderReducer from '../redux/loaderSlice';
|
import loaderReducer from '../redux/loaderSlice';
|
||||||
import roleReducer from '../redux/roleSlice';
|
import roleReducer from '../redux/roleSlice';
|
||||||
|
import reportReducer from '../redux/reportSlice';
|
||||||
|
|
||||||
export const store = configureStore({
|
export const store = configureStore({
|
||||||
reducer: {
|
reducer: {
|
||||||
outstaffing: outstaffingReducer,
|
outstaffing: outstaffingReducer,
|
||||||
loader: loaderReducer,
|
loader: loaderReducer,
|
||||||
role: roleReducer
|
role: roleReducer,
|
||||||
|
report: reportReducer,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user