diff --git a/src/components/FamilyHubsNetwork/FamilyHubsNetworkDetailDialog.jsx b/src/components/FamilyHubsNetwork/FamilyHubsNetworkDetailDialog.jsx index 97c3616..ae3df8d 100644 --- a/src/components/FamilyHubsNetwork/FamilyHubsNetworkDetailDialog.jsx +++ b/src/components/FamilyHubsNetwork/FamilyHubsNetworkDetailDialog.jsx @@ -10,11 +10,14 @@ export const FamilyHubsNetworkDetailDialog = () => {
- The Family Hub Network helps families with babies, children, and young - people from birth until they turn 19 (or up to 25 for those with - special educational needs and disabilities). As part of the Family Hub - Network in Buckinghamshire, we are committed to making it easier for - families to get the help and support they need. + The Family Hub Network is a one stop shop for advice, support and + services to help throughout your family journey, from birth to 19, or + up to 25 with special educational needs and disabilities (SEND). +
++ The network involves professionals and community groups working + together to ensure that families and residents receive the early help + and support they need.
> diff --git a/src/components/Filter/ScheduleFilter.jsx b/src/components/Filter/ScheduleFilter.jsx index 3dd0858..ea04832 100644 --- a/src/components/Filter/ScheduleFilter.jsx +++ b/src/components/Filter/ScheduleFilter.jsx @@ -1,4 +1,4 @@ -import React, { useState } from "react" +import React, { useEffect, useState } from "react" import styled from "styled-components" import { Outer, @@ -95,18 +95,50 @@ const ScheduleFilter = ({ foldable, }) => { const [unfolded, setUnfolded] = useState(schedule) + const [internalFromDate, setInternalFromDate] = useState(startDate) + const [internalToDate, setInternalToDate] = useState(endDate) + // handle the presets - sets internal values const handleScheduleChange = e => { const selectedSchedule = e.target.value setSchedule(selectedSchedule) const scheduleValues = scheduleOptionValues[selectedSchedule] if (scheduleValues) { - setStartDate(scheduleValues.startDate.toISOString().split("T")[0]) - setEndDate(scheduleValues.endDate.toISOString().split("T")[0]) + setInternalFromDate(scheduleValues.startDate.toISOString().split("T")[0]) + setInternalToDate(scheduleValues.endDate.toISOString().split("T")[0]) } setPage(1) } + // when only end date is set - set start date to today or the same as from date end date is on or before today + useEffect(() => { + if (internalToDate && !internalFromDate) { + const today = new Date() + const toDate = new Date(internalToDate) + + if (toDate <= today) { + setInternalFromDate(internalToDate) + } else { + setInternalFromDate(today.toISOString().split("T")[0]) + } + } + }, [internalFromDate, internalToDate]) + + // when internal from and to values are set - update the global state + useEffect(() => { + if (internalFromDate && internalToDate) { + setStartDate(internalFromDate) + setEndDate(internalToDate) + setPage(1) + } + }, [internalFromDate, internalToDate, setEndDate, setPage, setStartDate]) + + // clear internal value when global value is cleared + useEffect(() => { + setInternalFromDate(startDate) + setInternalToDate(endDate) + }, [endDate, startDate]) + return (