Skip to content

Commit

Permalink
Profile details update
Browse files Browse the repository at this point in the history
  • Loading branch information
KamogeloMoeketse committed Jul 4, 2024
1 parent 71bbc1c commit 6a74e24
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 10 deletions.
2 changes: 1 addition & 1 deletion frontend/occupi-mobile4/screens/Login/SplashScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
58 changes: 50 additions & 8 deletions frontend/occupi-mobile4/screens/Settings/Profile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
<SafeAreaView
style={colorScheme === 'dark' ? styles.containerdark : styles.containerlight}
Expand All @@ -120,7 +162,7 @@ const Profile = () => {
name="chevron-left"
size="xl"
color={colorScheme === 'dark' ? 'white' : 'black'}
onPress={() => router.back()}
onPress={() => router.replace('/settings')}
/>
<Text style={[styles.headerTitle, colorScheme === 'dark' ? styles.textdark : styles.textlight]}>
My account
Expand Down
2 changes: 1 addition & 1 deletion frontend/occupi-mobile4/screens/Settings/Settings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down

0 comments on commit 6a74e24

Please sign in to comment.