From 7479369abd3ad4c8a4ce2df668a229efe5b7bda0 Mon Sep 17 00:00:00 2001 From: winzlieb Date: Wed, 9 Mar 2022 17:19:45 +0100 Subject: [PATCH] enable date filtering --- backend/data/sample-data/example.edn | 20 +++++++++---------- .../components/ngo/HostOfferLookupTable.tsx | 8 +++++--- 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/backend/data/sample-data/example.edn b/backend/data/sample-data/example.edn index 3495b6c..b795f7b 100644 --- a/backend/data/sample-data/example.edn +++ b/backend/data/sample-data/example.edn @@ -9,7 +9,7 @@ :place_city "", :contact_phone nil, :place_zip "", - :time_from_str "", + :time_from_str "10/04/2022", :place_country "", :animals_present false, :languages (), @@ -26,7 +26,7 @@ :place_city "", :contact_phone nil, :place_zip "", - :time_from_str "", + :time_from_str "03/04/2022", :place_country nil, :animals_present true, :languages (), @@ -43,7 +43,7 @@ :place_city nil, :contact_phone "Q", :place_zip "RD", - :time_from_str "q", + :time_from_str "03/04/2022", :place_country nil, :animals_present true, :languages (), @@ -60,7 +60,7 @@ :place_city "1bh", :contact_phone nil, :place_zip "PG4", - :time_from_str "8az", + :time_from_str "03/04/2022", :place_country "I7", :animals_present false, :languages ("x" "ni"), @@ -77,7 +77,7 @@ :place_city "x", :contact_phone "w8l", :place_zip "1E", - :time_from_str "6", + :time_from_str "01/01/2022", :place_country "8", :animals_present nil, :languages (), @@ -94,7 +94,7 @@ :place_city "6", :contact_phone "OI", :place_zip "1", - :time_from_str "hS192", + :time_from_str "03/04/2022", :place_country "", :animals_present false, :languages ("DX" "E" "G3wuv"), @@ -111,7 +111,7 @@ :place_city "cj1A2", :contact_phone "r", :place_zip "cJ9z7", - :time_from_str "", + :time_from_str "03/04/2022", :place_country "5", :animals_present true, :languages nil, @@ -128,7 +128,7 @@ :place_city "4ML4yG", :contact_phone "7uQ3Px", :place_zip "kp5IS", - :time_from_str "Y5lSe", + :time_from_str "03/04/2022", :place_country nil, :animals_present true, :languages (), @@ -145,7 +145,7 @@ :place_city "u6k41v", :contact_phone "354VW", :place_zip "DI19", - :time_from_str "Z0QGzI8", + :time_from_str "09/04/2022", :place_country nil, :animals_present true, :languages nil, @@ -162,7 +162,7 @@ :place_city "f", :contact_phone "sQdB", :place_zip "cid1", - :time_from_str "KSAFC", + :time_from_str "03/05/2022", :place_country "toTz5B", :animals_present false, :languages ("vMR0zyECr"), diff --git a/frontend/search/components/ngo/HostOfferLookupTable.tsx b/frontend/search/components/ngo/HostOfferLookupTable.tsx index dc8d237..0d8ee01 100644 --- a/frontend/search/components/ngo/HostOfferLookupTable.tsx +++ b/frontend/search/components/ngo/HostOfferLookupTable.tsx @@ -8,6 +8,9 @@ import BoolFilter from '@inovua/reactdatagrid-community/BoolFilter' import {GetOffersQuery} from "../../codegen/generates"; import {TypeColumn, TypeFilterValue, TypeSingleFilterValue} from "@inovua/reactdatagrid-community/types"; import NumberFilter from "@inovua/reactdatagrid-community/NumberFilter"; +import moment from "moment"; + +global.moment = moment type HostOfferLookupTableProps = { data: GetOffersQuery @@ -111,7 +114,7 @@ const operatorsForType = { const columns: TypeColumn[] = columnsRaw .map(c => ({ ...c, - filterEditor: filterMappings[c.type as 'string' | 'number' | 'boolean'] + filterEditor: filterMappings[c.type as 'string' | 'number' | 'boolean' | 'date'] })) const defaultFilterValue: TypeFilterValue = columns @@ -132,8 +135,7 @@ const makeColumnDefinition = (data: any ) => Object.keys(data) type: typeof data[k]})) const HostOfferLookupTable = ({ data }: HostOfferLookupTableProps) => { - console.log({columns}) - const dataSource = data.get_offers?.map((d, index) => ({...d, id: index})) || [] + const dataSource = data.get_offers || [] return <>