diff --git a/frontend/occupi-mobile4/screens/Login/SetDetails.tsx b/frontend/occupi-mobile4/screens/Login/SetDetails.tsx
index 33b8cfb9..007a9460 100644
--- a/frontend/occupi-mobile4/screens/Login/SetDetails.tsx
+++ b/frontend/occupi-mobile4/screens/Login/SetDetails.tsx
@@ -27,6 +27,8 @@ import { useColorScheme } from 'react-native';
import { heightPercentageToDP as hp } from 'react-native-responsive-screen';
import GradientButton from '@/components/GradientButton';
import LoadingGradientButton from '@/components/LoadingGradientButton';
+import { updateDetails } from '@/utils/user';
+import { extractDateFromTimestamp } from '@/utils/utils';
const COLORS = {
white: '#FFFFFF',
@@ -47,20 +49,14 @@ const SIZES = {
};
const SetDetails = () => {
- const [selectedGenderIndex, setSelectedGenderIndex] = useState(1);
+ const [selectedGenderIndex, setSelectedGenderIndex] = useState('');
const [name, setName] = useState('');
- const [email, setEmail] = useState('');
- const [employeeId, setEmployeeId] = useState('');
const [phoneNumber, setPhoneNumber] = useState('');
const [pronouns, setPronouns] = useState('');
const [date, setDate] = useState('');
const [isLoading, setIsLoading] = useState(false);
const [isDatePickerVisible, setDatePickerVisibility] = useState(false);
let colorScheme = 'light';
- const apiUrl = process.env.EXPO_PUBLIC_DEVELOP_API_URL;
- const getUserDetailsUrl= process.env.EXPO_PUBLIC_GET_USER_DETAILS;
- const updateDetailsUrl = process.env.EXPO_PUBLIC_UPDATE_USER_DETAILS;
- console.log(apiUrl, getUserDetailsUrl, updateDetailsUrl);
const showDatePicker = () => {
setDatePickerVisibility(true);
@@ -70,78 +66,18 @@ const SetDetails = () => {
setDatePickerVisibility(false);
};
- const handleConfirm = (selectedDate) => {
- setDate(selectedDate);
+ const handleConfirm = (selectedDate: string) => {
+ console.log('selected',extractDateFromTimestamp(selectedDate));
+ setDate(extractDateFromTimestamp(selectedDate));
hideDatePicker();
};
const onSave = async () => {
- const body = {
- "email": email,
- "details": {
- "contactNo": phoneNumber,
- "gender": "Male",
- "name": name,
- "pronouns": pronouns
- }
- };
- // console.log(JSON.stringify(body));
setIsLoading(true);
- try {
- let authToken = await SecureStore.getItemAsync('Token');
- const response = await fetch(`${apiUrl}${updateDetailsUrl}`, {
- method: 'PUT',
- headers: {
- Accept: 'application/json',
- 'Content-Type': 'application/json',
- 'Authorization': `${authToken}`
- },
- body: JSON.stringify(body),
- credentials: "include"
- });
- const data = await response.json();
- console.log(data);
- if (response.ok) {
- console.log(response);
- setIsLoading(false);
- alert('Details updated successfully');
- } else {
- console.log(data);
- setIsLoading(false);
- }
- } catch (error) {
- setIsLoading(false);
- console.error('Error:', error);
- // setResponse('An error occurred');
- }
-
- try {
- let authToken = await SecureStore.getItemAsync('Token');
- const response = await fetch(`${apiUrl}${getUserDetailsUrl}?email=${email}`, {
- method: 'GET',
- headers: {
- Accept: 'application/json',
- 'Content-Type': 'application/json',
- 'Authorization': `${authToken}`
- },
- credentials: "include"
- });
- 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);
- }
+ const response = await updateDetails(name,date,selectedGenderIndex,phoneNumber,pronouns)
+ console.log(response);
+ setIsLoading(false);
};
- console.log(selectedGenderIndex);
-
- async function saveUserData(value) {
- await SecureStore.setItemAsync('UserData', value);
- }
return (
{
>
- router.replace('/settings')}
- />
- Account Details
+ My account
{
style={styles.icon}
/>
-
Full name
{
/>
Gender
- setSelectedGenderIndex(index)}>
+ setSelectedGenderIndex(index)}>
{
borderColor="#f2f2f2"
h={hp('5%')}
px="$4"
+
>
Male
@@ -257,11 +186,10 @@ const SetDetails = () => {
) : (
)
}
-
diff --git a/frontend/occupi-mobile4/screens/Login/SplashScreen.tsx b/frontend/occupi-mobile4/screens/Login/SplashScreen.tsx
index 3e0c538a..3cb20b4f 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('/settings'); // Navigate to Onboarding1 screen
+ router.replace('/welcome'); // Navigate to Onboarding1 screen
}, 5000); // 8 seconds
return () => clearTimeout(timer); // Clean up timer on component unmount
diff --git a/frontend/occupi-mobile4/screens/Notifications/Notifications.tsx b/frontend/occupi-mobile4/screens/Notifications/Notifications.tsx
index 59760d0f..fc21b983 100644
--- a/frontend/occupi-mobile4/screens/Notifications/Notifications.tsx
+++ b/frontend/occupi-mobile4/screens/Notifications/Notifications.tsx
@@ -98,7 +98,7 @@ const Notifications = () => {
return (
-
+
Notifications
diff --git a/frontend/occupi-mobile4/screens/Settings/Profile.tsx b/frontend/occupi-mobile4/screens/Settings/Profile.tsx
index 5f3aa403..f322a38e 100644
--- a/frontend/occupi-mobile4/screens/Settings/Profile.tsx
+++ b/frontend/occupi-mobile4/screens/Settings/Profile.tsx
@@ -122,7 +122,7 @@ const Profile = () => {
const onSave = async () => {
- const response = await updateDetails(name,date,selectedGenderIndex,phoneNumber,pronouns, employeeId)
+ const response = await updateDetails(name,date,selectedGenderIndex,phoneNumber,pronouns)
toast.show({
placement: 'top',
render: ({ id }) => {
diff --git a/frontend/occupi-mobile4/utils/auth.ts b/frontend/occupi-mobile4/utils/auth.ts
index f1bbfb9a..603a04ae 100644
--- a/frontend/occupi-mobile4/utils/auth.ts
+++ b/frontend/occupi-mobile4/utils/auth.ts
@@ -75,8 +75,8 @@ export async function verifyUserOtpRegister(email: string, otp: string) {
});
if (response.status === 200) {
console.log('responseee',response);
- setState('logged_out');
router.replace('/set-details');
+ router.replace('/login');
return response.message;
}
else {
diff --git a/frontend/occupi-mobile4/utils/user.ts b/frontend/occupi-mobile4/utils/user.ts
index 0296662e..8b3e70b2 100644
--- a/frontend/occupi-mobile4/utils/user.ts
+++ b/frontend/occupi-mobile4/utils/user.ts
@@ -1,6 +1,6 @@
import { UpdateDetailsReq } from "@/models/requests";
import { getUserDetails, getNotificationSettings, getSecuritySettings, updateSecuritySettings, updateNotificationSettings, updateUserDetails } from "../services/apiservices";
-import { storeUserData, storeNotificationSettings, getUserData, storeSecuritySettings } from "../services/securestore";
+import { storeUserData, storeNotificationSettings, getUserData, storeSecuritySettings, setState } from "../services/securestore";
import { router } from 'expo-router';
import * as SecureStore from 'expo-secure-store';
@@ -112,8 +112,9 @@ export async function updateSecurity(type: string, values: any) {
}
}
-export async function updateDetails(name: string, dob: string, gender: string, cellno: string, pronouns: string, employeeid: string) {
+export async function updateDetails(name: string, dob: string, gender: string, cellno: string, pronouns: string) {
const email = await SecureStore.getItemAsync('Email');
+ const state = await SecureStore.getItemAsync('AppState');
try {
const request : UpdateDetailsReq = {
session_email: email,
@@ -122,11 +123,14 @@ export async function updateDetails(name: string, dob: string, gender: string, c
gender: gender,
number: cellno,
pronouns: pronouns,
- employeeid: employeeid
}
const response = await updateUserDetails(request);
if (response.status === 200) {
console.log(response);
+ if (state === "verify_otp_register") {
+ setState("logged_out");
+ router.replace('login');
+ }
router.replace('/settings')
return "Details updated successfully"
}