Skip to content

Commit

Permalink
Fixed old vote not loading
Browse files Browse the repository at this point in the history
  • Loading branch information
M0ngi committed Mar 16, 2022
1 parent d7feebe commit 2cfdd23
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
4 changes: 3 additions & 1 deletion screens/VoteScreen/VoteScreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,19 @@ import BlueButton from "../../components/BlueButton/BlueButton";

import { CheckBox, Icon } from 'react-native-elements';
import { getParticipantList, voteForParticipant } from "../../services/vote/userFuncs";
import { CurrentUser } from "../../utils/user";


export default function VoteScreen(){

const { dispatchInfo } = useContext(InfoContext);
const [universities, setUniversities] = useState([]); // ["INSAT", "ESPRIT", "MSU"]
const [choosed, setchoosed] = useState(null);
const [voted, setVoted] = useState(null);
const [voted, setVoted] = useState(CurrentUser.votedFor);
const [loading, setLoading] = useState(false);

useEffect(()=>{
console.log(CurrentUser.votedFor)
getParticipantList()
.then((arr)=>{
setUniversities(arr);
Expand Down
4 changes: 2 additions & 2 deletions services/firestore/userFuncs.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,9 @@ export async function getCurrentUserData(){

let userPath = ref(rtdb, USER_PATH + auth.currentUser.uid);
let vote = (await get(userPath));

if(!vote.exists()) return {...data, votedFor: null, phone: phone.phone, email: email};
return {data, votedFor: vote.votedFor, phone: phone.phone, email: email};
return {data, votedFor: vote.toJSON().votedFor, phone: phone.phone, email: email};
}

export async function readDataFromPath(path){
Expand Down

0 comments on commit 2cfdd23

Please sign in to comment.