Connect Schedule to Availability screen
This commit is contained in:
parent
017f6e3869
commit
bc245eff51
@ -59,7 +59,7 @@ export default function IntervalSelector({
|
|||||||
});
|
});
|
||||||
|
|
||||||
const handleClick = (eventStart, eventEnd) => {
|
const handleClick = (eventStart, eventEnd) => {
|
||||||
let updatedAvailibility = [];
|
let updatedAvailability = [];
|
||||||
// Create an event object to compare
|
// Create an event object to compare
|
||||||
let currentAvailability = {
|
let currentAvailability = {
|
||||||
start: eventStart,
|
start: eventStart,
|
||||||
@ -73,11 +73,11 @@ export default function IntervalSelector({
|
|||||||
(availability) => currentAvJson === availability,
|
(availability) => currentAvJson === availability,
|
||||||
);
|
);
|
||||||
if (index > -1) {
|
if (index > -1) {
|
||||||
updatedAvailibility = [...availability];
|
updatedAvailability = [...availability];
|
||||||
updatedAvailibility.splice(index, 1);
|
updatedAvailability.splice(index, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
setAvailability([...updatedAvailibility]);
|
setAvailability([...updatedAvailability]);
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleContent = ({ event }) => {
|
const handleContent = ({ event }) => {
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
import React, { useState } from 'react';
|
import React, { useState } from 'react';
|
||||||
|
import { Redirect } from 'react-router-dom';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
Panel,
|
Panel,
|
||||||
Form,
|
Form,
|
||||||
@ -15,7 +17,7 @@ import './styles/Availability.less';
|
|||||||
import './styles/layout.less';
|
import './styles/layout.less';
|
||||||
|
|
||||||
export default function Availability({ possibleDates }) {
|
export default function Availability({ possibleDates }) {
|
||||||
const [availability, setAvailability] = useState([...availabilityList]);
|
const [availability, setAvailability] = useState([]);
|
||||||
|
|
||||||
const handleClear = () => {
|
const handleClear = () => {
|
||||||
setAvailability([]);
|
setAvailability([]);
|
||||||
@ -31,6 +33,10 @@ export default function Availability({ possibleDates }) {
|
|||||||
setAvailability([...availability, ...updatedEvents]);
|
setAvailability([...availability, ...updatedEvents]);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if(!possibleDates) {
|
||||||
|
return <Redirect to='/schedule' />
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<NavBar title='Add your availability' />
|
<NavBar title='Add your availability' />
|
||||||
@ -75,10 +81,10 @@ export default function Availability({ possibleDates }) {
|
|||||||
<Message
|
<Message
|
||||||
showIcon
|
showIcon
|
||||||
type='info'
|
type='info'
|
||||||
description='Select your availibility on the calendar.'
|
description='Select your availability on the calendar.'
|
||||||
/>
|
/>
|
||||||
<IntervalSelector
|
<IntervalSelector
|
||||||
selectedDates={eventsList}
|
selectedDates={possibleDates}
|
||||||
availability={availability}
|
availability={availability}
|
||||||
setAvailability={setAvailability}
|
setAvailability={setAvailability}
|
||||||
handleSelect={handleSelect}
|
handleSelect={handleSelect}
|
||||||
@ -90,70 +96,3 @@ export default function Availability({ possibleDates }) {
|
|||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO Remove fake data
|
|
||||||
const eventsList = [
|
|
||||||
{
|
|
||||||
start: '2020-06-05',
|
|
||||||
display: 'background',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
start: '2020-06-06',
|
|
||||||
display: 'background',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
start: '2020-06-08',
|
|
||||||
display: 'background',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
start: '2020-06-10',
|
|
||||||
display: 'background',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
start: '2020-06-11',
|
|
||||||
display: 'background',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
start: '2020-06-21',
|
|
||||||
display: 'background',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
start: '2020-06-29',
|
|
||||||
display: 'background',
|
|
||||||
},
|
|
||||||
];
|
|
||||||
|
|
||||||
const availabilityList = [
|
|
||||||
{
|
|
||||||
start: '2020-06-08T08:00:00.000Z',
|
|
||||||
end: '2020-06-08T12:00:00.000Z',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
start: '2020-06-10T09:00:00.000Z',
|
|
||||||
end: '2020-06-10T13:00:00.000Z',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
start: '2020-06-11T09:00:00.000Z',
|
|
||||||
end: '2020-06-11T13:00:00.000Z',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
start: '2020-06-11T06:30:00.000Z',
|
|
||||||
end: '2020-06-11T08:30:00.000Z',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
start: '2020-06-21T07:00:00.000Z',
|
|
||||||
end: '2020-06-21T11:30:00.000Z',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
start: '2020-06-21T12:00:00.000Z',
|
|
||||||
end: '2020-06-21T15:30:00.000Z',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
start: '2020-06-06T08:00:00.000Z',
|
|
||||||
end: '2020-06-06T14:00:00.000Z',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
start: '2020-06-05T10:30:00.000Z',
|
|
||||||
end: '2020-06-05T14:30:00.000Z',
|
|
||||||
},
|
|
||||||
];
|
|
||||||
|
@ -40,15 +40,15 @@ export default function Schedule({
|
|||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
// Push the selected dates up the state tree
|
// Push the selected dates up the state tree
|
||||||
// but keep all related logic here
|
// but keep all related logic here
|
||||||
setPossibleDates(datesList)
|
setPossibleDates(eventsList);
|
||||||
}, [datesList, setPossibleDates])
|
}, [eventsList, setPossibleDates]);
|
||||||
|
|
||||||
// EVENTS & DATES
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
let updatedDates = eventsToDates(eventsList).sort();
|
let updatedDates = eventsToDates(eventsList).sort();
|
||||||
setDatesList(updatedDates);
|
setDatesList(updatedDates);
|
||||||
}, [eventsList]);
|
}, [eventsList]);
|
||||||
|
|
||||||
|
// EVENTS & DATES
|
||||||
const handleSelectDates = (info) => {
|
const handleSelectDates = (info) => {
|
||||||
let updatedEvents = [];
|
let updatedEvents = [];
|
||||||
let datesList = new Set();
|
let datesList = new Set();
|
||||||
|
Loading…
Reference in New Issue
Block a user