From a07cc664c91e9c9b2d9d3d259134d9e45f99fbbe Mon Sep 17 00:00:00 2001 From: developomp Date: Wed, 4 Aug 2021 17:05:32 +0900 Subject: [PATCH] moved meta tags and implemented date range feature --- source/public/index.html | 4 ++- source/src/App.tsx | 12 ++------ source/src/pages/Search.tsx | 59 +++++++++++++++++++++++++++++-------- 3 files changed, 52 insertions(+), 23 deletions(-) diff --git a/source/public/index.html b/source/public/index.html index 76e9f78..b57802c 100644 --- a/source/public/index.html +++ b/source/public/index.html @@ -4,8 +4,10 @@ + - + + { }} > - - - - + { - - diff --git a/source/src/pages/Search.tsx b/source/src/pages/Search.tsx index 293e72e..899718e 100644 --- a/source/src/pages/Search.tsx +++ b/source/src/pages/Search.tsx @@ -44,6 +44,24 @@ const StyledSearchControlContainer = styled.div` } ` +function isDateInRange( + dateToCompare: string, + from: string, + to: string +): boolean { + if (!dateToCompare) throw Error("No date to compare") + + const isFrom = !!from + const isTo = !!to + + if (!isFrom && !isTo) return true + if (!isFrom && isTo) return Date.parse(dateToCompare) < Date.parse(to) + if (!isTo && isFrom) return Date.parse(dateToCompare) > Date.parse(from) + + const compareDate = Date.parse(dateToCompare) + return Date.parse(from) < compareDate && compareDate < Date.parse(to) +} + // todo: find ways to get rid of wrapper component export default function Search() { return <_Search /> @@ -70,7 +88,7 @@ function _Search() { const [dateRange, setDateRange] = useState([ { - startDate: new Date(), + startDate: new Date(0), endDate: null, key: "selection", }, @@ -84,15 +102,6 @@ function _Search() { <> pomp | Search - - - - - - @@ -182,6 +191,20 @@ function _Search() { Search test 2
+ +