added logout function in profile
This commit is contained in:
@@ -8,6 +8,7 @@ import { BASE_URL } from "../utils/ApiUrls";
|
||||
import { useDispatch, useSelector } from "react-redux";
|
||||
import { setUserData } from "../redux/userSlice";
|
||||
import colors from "../components/colors";
|
||||
import { ApiResponse } from "./home/UserProfileStatus";
|
||||
|
||||
const SplashScreen = () => {
|
||||
const dispatch = useDispatch();
|
||||
@@ -15,6 +16,7 @@ const SplashScreen = () => {
|
||||
const navigation = useNavigation<StackNavigationProp<RootStackParamList>>();
|
||||
const fadeAnim = useRef(new Animated.Value(1)).current;
|
||||
|
||||
|
||||
const fetchUserProfile = async () => {
|
||||
try {
|
||||
const credentials = await Keychain.getGenericPassword();
|
||||
@@ -69,6 +71,38 @@ const SplashScreen = () => {
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
const userStatus = async () => {
|
||||
try {
|
||||
const credentials = await Keychain.getGenericPassword();
|
||||
if (!credentials) {
|
||||
Alert.alert("Error", "You are not logged in");
|
||||
return;
|
||||
}
|
||||
const token = credentials.password;
|
||||
|
||||
const response = await fetch(`${BASE_URL}user/profile/status`, {
|
||||
method: "GET",
|
||||
headers: {
|
||||
Accept: "*/*",
|
||||
Authorization: `Bearer ${token}`,
|
||||
},
|
||||
});
|
||||
|
||||
const json: ApiResponse = await response.json();
|
||||
|
||||
console.log("👤 Profile Status Response:", json);
|
||||
if (json.status === "success") {
|
||||
|
||||
} else {
|
||||
// setError(json.message || "Failed to fetch status");
|
||||
}
|
||||
} catch (err) {
|
||||
// setError("Something went wrong. Please try again.");
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
console.log("redux user", user);
|
||||
|
||||
useEffect(() => {
|
||||
|
||||
Reference in New Issue
Block a user