|
@ -20,19 +20,31 @@ import getPluviometerStation from "./app/hooks/usePluviometricStation"; |
|
|
|
|
|
|
|
|
export default function App() { |
|
|
export default function App() { |
|
|
const [user, setUser] = useState(); |
|
|
const [user, setUser] = useState(); |
|
|
const [pluviometerStation, setPluviometerStation] = useState(); |
|
|
|
|
|
|
|
|
const [pluviometerStation, setPluviometerStation] = useState(undefined); |
|
|
const [isReady, setIsReady] = useState(); |
|
|
const [isReady, setIsReady] = useState(); |
|
|
|
|
|
|
|
|
const netInfo = useNetInfo(); |
|
|
const netInfo = useNetInfo(); |
|
|
|
|
|
|
|
|
useEffect(() => { |
|
|
useEffect(() => { |
|
|
if (user?.username != null) { |
|
|
if (user?.username != null) { |
|
|
|
|
|
if (pluviometerStation == undefined) { |
|
|
getPluviometerStation(user.id, setPluviometerStation); |
|
|
getPluviometerStation(user.id, setPluviometerStation); |
|
|
const pluv = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaah" |
|
|
|
|
|
authStorage.setUser({ ...user, pluviometer: pluviometerStation }); |
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
authStorage.setUser(user); |
|
|
|
|
|
} |
|
|
|
|
|
else{ |
|
|
|
|
|
setPluviometerStation(undefined); |
|
|
} |
|
|
} |
|
|
}, [user]); |
|
|
}, [user]); |
|
|
|
|
|
|
|
|
|
|
|
useEffect(() => { |
|
|
|
|
|
if (user?.username != null) { |
|
|
|
|
|
setUser({ ...user, pluviometer: pluviometerStation }); |
|
|
|
|
|
} |
|
|
|
|
|
}, [pluviometerStation]); |
|
|
|
|
|
|
|
|
|
|
|
console.log(pluviometerStation); |
|
|
|
|
|
|
|
|
const restoreUser = async () => { |
|
|
const restoreUser = async () => { |
|
|
const storageUser = await authStorage.getUser(); |
|
|
const storageUser = await authStorage.getUser(); |
|
|
if (storageUser) setUser(storageUser); |
|
|
if (storageUser) setUser(storageUser); |
|
|