Browse Source

Merge branch 'main' of github.com:IGSD-UoW/WPD-MobileApp

master
GabrielTrettel 3 years ago
parent
commit
79755b9a18
  1. 23
      src/app/components/DatePicker.js
  2. 22
      src/app/hooks/useFiltering.js

23
src/app/components/DatePicker.js

@ -25,10 +25,21 @@ export default function DatePicker(props) {
const [time, setTime] = useState(moment(defaultDate)); const [time, setTime] = useState(moment(defaultDate));
const validateTimeInput = (selectedDate) => { const validateTimeInput = (selectedDate) => {
if (
!moment().isSameOrAfter(selectedDate) &&
new Date(moment()).getDay() == new Date(date).getDay()
) {
const hour = moment(selectedDate, "HH:mm").format("HH:mm");
const day_month = moment(date, "DD-MM-YYYY").format("DD-MM-YYYY");
const dateTime = moment(
day_month + "T" + hour,
"DD-MM-YYYYTHH:mm"
).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", [ Alert.alert("Horário inválido", "Selecione um horário válido", [
{ text: "OK", onPress: () => renderDatePicker() }, { text: "OK", onPress: () => renderDatePicker() },
]); ]);
@ -59,7 +70,9 @@ export default function DatePicker(props) {
setShow(false); setShow(false);
setMode("date"); setMode("date");
} else { } else {
setTime(moment());
//setTime(moment());
setShow(false);
setMode("date");
} }
} }
} }

22
src/app/hooks/useFiltering.js

@ -4,7 +4,7 @@ import webSocketClient from "../api/Websockets/webSocketClient";
function useFiltering(location) { function useFiltering(location) {
const endpoint = webSocketClient; const endpoint = webSocketClient;
const initialDate = moment().add(1, "days").format("YYYY-MM-DDTHH:mm:ss"); 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')}`); console.log(`Criando sockets do useFiltering: ${moment().format('DD/MM, h:mm:ss:SSS')}`);
@ -12,46 +12,46 @@ function useFiltering(location) {
{ {
name: "floodZones", name: "floodZones",
url: endpoint + 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( socketUrl: new WebSocket(
endpoint + 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", name: "rain",
url: endpoint + 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( socketUrl: new WebSocket(
endpoint + 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", name: "riverFlood",
url: endpoint + 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( socketUrl: new WebSocket(
endpoint + 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", name: "pluviometer",
url: endpoint + 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( socketUrl: new WebSocket(
endpoint + 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", name: "susceptibilityAreas",
url: endpoint + 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( socketUrl: new WebSocket(
endpoint + 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`
), ),
}, },
{ {

Loading…
Cancel
Save