From c30422c09f614c02f9cf3c9b31a87f92fc6bdff9 Mon Sep 17 00:00:00 2001 From: analuizaff Date: Tue, 7 Dec 2021 17:31:34 -0300 Subject: [PATCH 1/4] fixing a datetime picker issue --- src/app/components/DatePicker.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/app/components/DatePicker.js b/src/app/components/DatePicker.js index 207adb8..b3feae2 100644 --- a/src/app/components/DatePicker.js +++ b/src/app/components/DatePicker.js @@ -25,9 +25,15 @@ export default function DatePicker(props) { const [time, setTime] = useState(moment(defaultDate)); const validateTimeInput = (selectedDate) => { + const hour = moment(selectedDate, "HH:mm").format("HH:mm"); + const day_month = moment(date, "DD-MM-YYYY").format("DD-MM-YYYY"); + const eventDateTime = moment( + day_month + "T" + hour, + "DD-MM-YYYYTHH:mm" + ).format("DD-MM-YYYYTHH:mm"); if ( - !moment().isSameOrAfter(selectedDate) && - new Date(moment()).getDay() == new Date(date).getDay() + moment(new Date(), "DD-MM-YYYYTHH:mm").format("DD-MM-YYYYTHH:mm") < + eventDateTime ) { Alert.alert("Horário inválido", "Selecione um horário válido", [ { text: "OK", onPress: () => renderDatePicker() }, @@ -99,7 +105,7 @@ export default function DatePicker(props) { mode={mode} is24Hour={true} locale={"pt-br"} - // minimumDate={props.minimumDate} + // minimumDate={props.minimumDate} maximumDate={new Date(moment())} formatChosenDate={(selectedDate) => { if (mode == "date") { From 4a77bcef0bb42491ebb111fba4a3e208eeec1e03 Mon Sep 17 00:00:00 2001 From: analuizaff Date: Tue, 7 Dec 2021 17:35:28 -0300 Subject: [PATCH 2/4] fixing a datetime picker issue --- src/app/components/DatePicker.js | 4 +--- src/app/hooks/useFiltering.js | 2 +- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/src/app/components/DatePicker.js b/src/app/components/DatePicker.js index b3feae2..41fe000 100644 --- a/src/app/components/DatePicker.js +++ b/src/app/components/DatePicker.js @@ -32,9 +32,7 @@ export default function DatePicker(props) { "DD-MM-YYYYTHH:mm" ).format("DD-MM-YYYYTHH:mm"); if ( - moment(new Date(), "DD-MM-YYYYTHH:mm").format("DD-MM-YYYYTHH:mm") < - eventDateTime - ) { + moment(new Date(), "DD-MM-YYYYTHH:mm").format("DD-MM-YYYYTHH:mm") < eventDateTime) { Alert.alert("Horário inválido", "Selecione um horário válido", [ { text: "OK", onPress: () => renderDatePicker() }, ]); diff --git a/src/app/hooks/useFiltering.js b/src/app/hooks/useFiltering.js index 17e718c..cbefbd8 100644 --- a/src/app/hooks/useFiltering.js +++ b/src/app/hooks/useFiltering.js @@ -4,7 +4,7 @@ import webSocketClient from "../api/Websockets/webSocketClient"; function useFiltering(location) { const endpoint = webSocketClient; const initialDate = moment().add(1, "days").format("YYYY-MM-DDTHH:mm:ss"); - const finalDate = moment().subtract(2, "days").format("YYYY-MM-DDTHH:mm:ss"); + const finalDate = moment().subtract(1, "days").format("YYYY-MM-DDTHH:mm:ss"); console.log(`Criando sockets do useFiltering: ${moment().format('DD/MM, h:mm:ss:SSS')}`); From 73060262a074df1697259b30224a72b4d17b6ef4 Mon Sep 17 00:00:00 2001 From: analuizaff Date: Tue, 7 Dec 2021 17:48:40 -0300 Subject: [PATCH 3/4] updating radius filter from 50km to 20km --- src/app/hooks/useFiltering.js | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/app/hooks/useFiltering.js b/src/app/hooks/useFiltering.js index cbefbd8..69d7220 100644 --- a/src/app/hooks/useFiltering.js +++ b/src/app/hooks/useFiltering.js @@ -12,46 +12,46 @@ function useFiltering(location) { { name: "floodZones", url: endpoint + - `type=FLOODZONES_FORM&time=${finalDate}/${initialDate}&lat=${location.lat}&lon=${location.long}&buffer=5000&limit=50`, + `type=FLOODZONES_FORM&time=${finalDate}/${initialDate}&lat=${location.lat}&lon=${location.long}&buffer=20000&limit=50`, socketUrl: new WebSocket( endpoint + - `type=FLOODZONES_FORM&time=${finalDate}/${initialDate}&lat=${location.lat}&lon=${location.long}&buffer=5000&limit=50` + `type=FLOODZONES_FORM&time=${finalDate}/${initialDate}&lat=${location.lat}&lon=${location.long}&buffer=20000&limit=50` ), }, { name: "rain", url: endpoint + - `type=RAIN_FORM&time=${finalDate}/${initialDate}&lat=${location.lat}&lon=${location.long}&buffer=5000&limit=50`, + `type=RAIN_FORM&time=${finalDate}/${initialDate}&lat=${location.lat}&lon=${location.long}&buffer=20000&limit=50`, socketUrl: new WebSocket( endpoint + - `type=RAIN_FORM&time=${finalDate}/${initialDate}&lat=${location.lat}&lon=${location.long}&buffer=5000&limit=50` + `type=RAIN_FORM&time=${finalDate}/${initialDate}&lat=${location.lat}&lon=${location.long}&buffer=20000&limit=50` ), }, { name: "riverFlood", url: endpoint + - `type=RIVERFLOOD_FORM&time=${finalDate}/${initialDate}&lat=${location.lat}&lon=${location.long}&buffer=5000&limit=50`, + `type=RIVERFLOOD_FORM&time=${finalDate}/${initialDate}&lat=${location.lat}&lon=${location.long}&buffer=20000&limit=50`, socketUrl: new WebSocket( endpoint + - `type=RIVERFLOOD_FORM&time=${finalDate}/${initialDate}&lat=${location.lat}&lon=${location.long}&buffer=5000&limit=50` + `type=RIVERFLOOD_FORM&time=${finalDate}/${initialDate}&lat=${location.lat}&lon=${location.long}&buffer=20000&limit=50` ), }, { name: "pluviometer", url: endpoint + - `type=PLUVIOMETER_REGISTRATION&lat=${location.lat}&lon=${location.long}&buffer=5000&limit=50`, + `type=PLUVIOMETER_REGISTRATION&lat=${location.lat}&lon=${location.long}&buffer=20000&limit=50`, socketUrl: new WebSocket( endpoint + - `type=PLUVIOMETER_REGISTRATION&lat=${location.lat}&lon=${location.long}&buffer=5000&limit=50` + `type=PLUVIOMETER_REGISTRATION&lat=${location.lat}&lon=${location.long}&buffer=20000&limit=50` ), }, { name: "susceptibilityAreas", url: endpoint + - `type=FLOODZONES_OFFICIAL&lat=${location.lat}&lon=${location.long}&buffer=50000&limit=20`, + `type=FLOODZONES_OFFICIAL&lat=${location.lat}&lon=${location.long}&buffer=20000&limit=20`, socketUrl: new WebSocket( endpoint + - `type=FLOODZONES_OFFICIAL&lat=${location.lat}&lon=${location.long}&buffer=50000&limit=20` + `type=FLOODZONES_OFFICIAL&lat=${location.lat}&lon=${location.long}&buffer=20000&limit=20` ), }, { From a4520deb758e1965b36392787693b1ff7142928e Mon Sep 17 00:00:00 2001 From: analuizaff Date: Tue, 7 Dec 2021 20:40:31 -0300 Subject: [PATCH 4/4] updating date time picker --- src/app/components/DatePicker.js | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/src/app/components/DatePicker.js b/src/app/components/DatePicker.js index 41fe000..de10ff3 100644 --- a/src/app/components/DatePicker.js +++ b/src/app/components/DatePicker.js @@ -27,12 +27,19 @@ export default function DatePicker(props) { const validateTimeInput = (selectedDate) => { const hour = moment(selectedDate, "HH:mm").format("HH:mm"); const day_month = moment(date, "DD-MM-YYYY").format("DD-MM-YYYY"); - const eventDateTime = moment( + const dateTime = moment( day_month + "T" + hour, "DD-MM-YYYYTHH:mm" - ).format("DD-MM-YYYYTHH:mm"); - if ( - moment(new Date(), "DD-MM-YYYYTHH:mm").format("DD-MM-YYYYTHH:mm") < eventDateTime) { + ).toObject(); + var dateTime_event = new Date( + dateTime.years, + dateTime.months, + dateTime.date, + dateTime.hours, + dateTime.minutes + ); + var today = new Date(); + if (dateTime_event > today) { Alert.alert("Horário inválido", "Selecione um horário válido", [ { text: "OK", onPress: () => renderDatePicker() }, ]); @@ -63,7 +70,9 @@ export default function DatePicker(props) { setShow(false); setMode("date"); } else { - setTime(moment()); + //setTime(moment()); + setShow(false); + setMode("date"); } } }