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