Skip to content

Commit

Permalink
Merge pull request #186 from wearefuturegov/develop
Browse files Browse the repository at this point in the history
Staging deployment
  • Loading branch information
apricot13 authored Nov 28, 2024
2 parents 79be04c + 8fdcb3f commit 8db9326
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,14 @@ export const FamilyHubsNetworkDetailDialog = () => {
<Body>
<FamilyHubsNetworkLogo />
<p>
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).
</p>
<p>
The network involves professionals and community groups working
together to ensure that families and residents receive the early help
and support they need.
</p>
</Body>
</>
Expand Down
46 changes: 39 additions & 7 deletions src/components/Filter/ScheduleFilter.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useState } from "react"
import React, { useEffect, useState } from "react"
import styled from "styled-components"
import {
Outer,
Expand Down Expand Up @@ -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 (
<Outer>
<Header>
Expand Down Expand Up @@ -144,17 +176,17 @@ const ScheduleFilter = ({
<LabelWithMargin htmlFor="from_date">From</LabelWithMargin>
<Input
id={`from_date`}
onChange={e => setStartDate(e.target.value)}
value={startDate}
onChange={e => setInternalFromDate(e.target.value)}
value={internalFromDate}
type="date"
/>
</ColumnField>
<ColumnField>
<LabelWithMargin htmlFor="to_date">To</LabelWithMargin>
<Input
id={`to_date`}
onChange={e => setEndDate(e.target.value)}
value={endDate}
onChange={e => setInternalToDate(e.target.value)}
value={internalToDate}
type="date"
/>
</ColumnField>
Expand Down

0 comments on commit 8db9326

Please sign in to comment.