From ea803fbbcb1f36ea4f6845ca34b490b506d5718f Mon Sep 17 00:00:00 2001 From: Han Date: Thu, 28 Nov 2024 12:21:31 +0000 Subject: [PATCH 1/2] TOP-253 update text --- .../FamilyHubsNetworkDetailDialog.jsx | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) 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.

From 044d3af971c055776ce966ed24954e2a3af14b39 Mon Sep 17 00:00:00 2001 From: Han Date: Thu, 28 Nov 2024 12:51:27 +0000 Subject: [PATCH 2/2] TOP-256 don't allow from to be not set --- src/components/Filter/ScheduleFilter.jsx | 46 ++++++++++++++++++++---- 1 file changed, 39 insertions(+), 7 deletions(-) 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 (
@@ -144,8 +176,8 @@ const ScheduleFilter = ({ From setStartDate(e.target.value)} - value={startDate} + onChange={e => setInternalFromDate(e.target.value)} + value={internalFromDate} type="date" /> @@ -153,8 +185,8 @@ const ScheduleFilter = ({ To setEndDate(e.target.value)} - value={endDate} + onChange={e => setInternalToDate(e.target.value)} + value={internalToDate} type="date" />