Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 17 additions & 7 deletions screens/visitor/Onboarding.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {reg14, reg16, bold16, bold18} from '../../config/typography.js'
import Ionicons from 'react-native-vector-icons/Ionicons';
import { capitalizeFirstLetter } from 'utils';
import { onAuthStateChanged } from '../../api/auth.js'
import { changeName, changeYear, changeMajor } from 'api/users'
import { Picker } from '@react-native-picker/picker'; /* DOCUMENTATION: https://github.com/react-native-picker/picker */

const SCHOOLOPTIONS = ['UCLA', 'UC Berkeley',]
Expand All @@ -23,20 +24,29 @@ export default ({navigation}) => {
visitorDone, setVisitorDone,
visitorBone, setVisitorBone, hasNotFinishedBareOnboarding} = useContext(UserContext);

useEffect(() => {
if (mode != 'visitor') {
setMode('visitor');
}
return () => {}
}, [])

const [page, setPage] = useState(1);
const [data, setData] = useState(['-','-','-','-']);

/* Picker */
const [dropdown, setDropdown] = useState(false);
const [selectedDropdownItem, setSelectedDropdownItem] = useState('-')
const [ID, setID] = useState()
const pickerRef = useRef();
useEffect(() => {
if (mode != 'visitor') {
setMode('visitor');
}
onAuthStateChanged((user) => {setID(user.uid)})
return () => {}
}, [])

useEffect(() => {
if (page == 5) {
if (data[0] != '-' && data[0] != null) changeName(ID, data[0])
if (data[2] != '-' && data[2] != null) changeYear(ID, data[2])
if (data[3] != '-' && data[3] != null && data[3] != "") changeMajor(ID, data[3])
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do we need to check for '-' and if its null? Can you add a comment in the code why we need to check this?

}
}, [page])

function open() {
pickerRef.current.focus();
Expand Down