From d322008c132dfa30124b07149632d2ae635a75de Mon Sep 17 00:00:00 2001
From: tylerbarna
Date: Thu, 5 Oct 2023 14:26:54 -0500
Subject: [PATCH 01/55] added date range selector dropdown content from
nasa-gcn:#1265 . This will be a new PR due to previous PR being stale
---
app/routes/circulars._archive._index.tsx | 190 ++++++++++++++++++++++-
1 file changed, 188 insertions(+), 2 deletions(-)
diff --git a/app/routes/circulars._archive._index.tsx b/app/routes/circulars._archive._index.tsx
index e6a615820..739b963a0 100644
--- a/app/routes/circulars._archive._index.tsx
+++ b/app/routes/circulars._archive._index.tsx
@@ -17,8 +17,10 @@ import {
import {
Button,
ButtonGroup,
+ DateRangePicker,
Icon,
Label,
+ Radio,
Select,
TextInput,
} from '@trussworks/react-uswds'
@@ -28,6 +30,7 @@ import { useState } from 'react'
import { circularRedirect, search } from './circulars/circulars.server'
import type { action } from './circulars/route'
+import DetailsDropdownContent from '~/components/DetailsDropdownContent'
import Hint from '~/components/Hint'
import { usePagination } from '~/lib/pagination'
import { useFeature } from '~/root'
@@ -239,10 +242,40 @@ export default function () {
if (searchString) searchString = `?${searchString}`
const [inputQuery, setInputQuery] = useState(query)
- const clean = inputQuery === query
+ const [inputDateGte, setInputDateGte] = useState(startDate)
+ const [inputDateLte, setInputDateLte] = useState(endDate)
+ const [showContent, setShowContent] = useState(false) // for the custom date range dropdown
+ const [showDateRange, setShowDateRange] = useState(false)
+ const clean =
+ inputQuery === query &&
+ inputDateGte === startDate &&
+ inputDateLte === endDate
const submit = useSubmit()
+ const setFuzzyTime = (startDate?: string) => {
+ // console.log(startDate)
+ if (startDate === 'custom') {
+ setShowDateRange(true)
+ } else {
+ setShowDateRange(false)
+ setInputDateGte(startDate)
+ }
+ setInputDateLte('now')
+ }
+
+ const setDateRange = () => {
+ // setShowContent(false)
+ if (showDateRange) setShowDateRange(false)
+ const params = new URLSearchParams(location.search)
+ if (inputDateGte) params.set('startDate', inputDateGte)
+ if (inputDateLte) params.set('endDate', inputDateLte)
+ submit(params, {
+ method: 'get',
+ action: '/circulars',
+ })
+ }
+
return (
<>
GCN Circulars
@@ -291,7 +324,160 @@ export default function () {
{featureCircularsFilterByDate && (
-
+ <>
+ setShowContent(!showContent)}
+ expanded={showContent}
+ />
+ {showContent && (
+
+
+
+
+ {
+ setFuzzyTime(e.target.value)
+ }}
+ >
+ {
+ setFuzzyTime(e.target.value)
+ }}
+ >
+ {
+ setFuzzyTime(e.target.value)
+ }}
+ >
+
+
+ {
+ setFuzzyTime(e.target.value)
+ }}
+ >
+ {
+ setFuzzyTime(e.target.value)
+ }}
+ >
+ {
+ setFuzzyTime(e.target.value)
+ }}
+ >
+
+
+
+ {
+ setFuzzyTime(e.target.value)
+ }}
+ >
+ {
+ setFuzzyTime(e.target.value)
+ }}
+ >
+ {
+ setShowDateRange(e.target.checked)
+ }}
+ >
+
+
+
+ {showDateRange && (
+
{
+ setInputDateGte(value)
+ },
+ // style: { height: '15px' }, // Adjust the height as needed
+ }}
+ endDateHint="dd/mm/yyyy"
+ endDateLabel="End Date"
+ endDatePickerProps={{
+ id: 'event-date-end',
+ name: 'event-date-end',
+ defaultValue: 'endDate',
+ onChange: (value) => {
+ setInputDateLte(value)
+ },
+ // style: { height: '15px' },
+ }}
+ />
+ )}
+
+
+
+
+
+ )}
+ >
)}
-
+