diff --git a/frontend/occupi-mobile4/screens/Login/SplashScreen.tsx b/frontend/occupi-mobile4/screens/Login/SplashScreen.tsx index 6b9b9309..78e123f5 100644 --- a/frontend/occupi-mobile4/screens/Login/SplashScreen.tsx +++ b/frontend/occupi-mobile4/screens/Login/SplashScreen.tsx @@ -93,7 +93,7 @@ export default function SplashScreen() { useEffect(() => { const timer = setTimeout(() => { setSelectedIndex(1); // Assuming Onboarding1 is at index 1 - router.replace('/profile'); // Navigate to Onboarding1 screen + router.replace('/home'); // Navigate to Onboarding1 screen }, 5000); // 8 seconds return () => clearTimeout(timer); // Clean up timer on component unmount diff --git a/frontend/occupi-mobile4/screens/Settings/Profile.tsx b/frontend/occupi-mobile4/screens/Settings/Profile.tsx index f2606c6e..0f611ced 100644 --- a/frontend/occupi-mobile4/screens/Settings/Profile.tsx +++ b/frontend/occupi-mobile4/screens/Settings/Profile.tsx @@ -100,15 +100,57 @@ const Profile = () => { hideDatePicker(); }; - const onSave = () => { - // Alert.alert( - // 'Profile Saved', - // `Name: ${name}\nDOB: ${date.toLocaleDateString()}\nGender: ${ - // ['Male', 'Female', 'N-Bin'][selectedGenderIndex] - // }\nEmail: ${email}\nEmployee ID: ${employeeId}\nPhone: ${phoneNumber}\nPronouns: ${pronouns}` - // ); + const onSave = async () => { + const body = { + "email" : email, + "details": { + "contactNo": phoneNumber, + "gender": "Male", + "name": name, + "pronouns": pronouns + } + }; + console.log(JSON.stringify(body)); + try { + const response = await fetch('https://dev.occupi.tech/api/update-user', { + method: 'PUT', + headers: { + Accept: 'application/json', + 'Content-Type': 'application/json' + }, + body: JSON.stringify(body), + credentials: "include" + }); + const data = await response.json(); + console.log(data); + if (response.ok) { + console.log(response); + } else { + console.log(data); + } + } catch (error) { + console.error('Error:', error); + // setResponse('An error occurred'); + } + + try { + const response = await fetch(`https://dev.occupi.tech/api/user-details?email=${email}`) + const data = await response.json(); + if (response.ok) { + saveUserData(JSON.stringify(data)); + console.log(data); + } else { + console.log(data); + } + } catch (error) { + console.error('Error:', error); + } }; + async function saveUserData(value) { + await SecureStore.setItemAsync('UserData', value); + } + return ( { name="chevron-left" size="xl" color={colorScheme === 'dark' ? 'white' : 'black'} - onPress={() => router.back()} + onPress={() => router.replace('/settings')} /> My account diff --git a/frontend/occupi-mobile4/screens/Settings/Settings.tsx b/frontend/occupi-mobile4/screens/Settings/Settings.tsx index 39ff6a50..d846c04b 100644 --- a/frontend/occupi-mobile4/screens/Settings/Settings.tsx +++ b/frontend/occupi-mobile4/screens/Settings/Settings.tsx @@ -66,7 +66,7 @@ const Settings = () => { }; const data = [ - { title: 'My account', description: 'Make changes to your account', iconName: 'user', onPress: () => router.push('/profile')}, + { title: 'My account', description: 'Make changes to your account', iconName: 'user', onPress: () => router.replace('/profile')}, { title: 'Notifications', description: 'Manage your notifications',