phase 1-6 implemented

This commit is contained in:
dimitar committed 2026-03-10 04:14:03 +01:00
1 parent 22c274bb83
commit 2c4927478a
73 files changed
+9702 -2354

No files matched your search

+4 -3
View File
@@ -12,6 +12,7 @@ import {
import { useUser, useAuth } from "@clerk/clerk-expo";
import { useRouter } from "expo-router";
import { fitnessProfileApi } from "@/api/fitnessProfile";
import log from "../../utils/logger";
export default function OnboardingScreen() {
const { user } = useUser();
@@ -37,7 +38,7 @@ export default function OnboardingScreen() {
setGyms(data);
}
} catch (e) {
console.error("Failed to fetch gyms:", e);
log.error("Failed to fetch gyms", e);
} finally {
setGymsLoading(false);
}
@@ -84,7 +85,7 @@ export default function OnboardingScreen() {
body: JSON.stringify({ gymId: selectedGymId }),
});
} catch (e) {
console.warn("Failed to update gym selection:", e);
log.warn("Failed to update gym selection", { gymId: selectedGymId });
}
const fitnessData = {
@@ -108,7 +109,7 @@ export default function OnboardingScreen() {
await fitnessProfileApi.createFitnessProfile(fitnessData, token);
router.replace("/(tabs)");
} catch (error) {
console.error("Error creating fitness profile:", error);
log.error("Failed to create fitness profile", error);
Alert.alert(
"Error",
"Failed to create fitness profile. Please try again.",
+10 -9
View File
@@ -13,6 +13,8 @@ import {
ScrollView,
} from "react-native";
import { OAuthButtons } from "../../components/auth/OAuthButtons";
import { getErrorMessage, getClerkErrorCode } from "../../utils/error-helpers";
import log from "../../utils/logger";
export default function SignInScreen() {
const { signIn, setActive, isLoaded } = useSignIn();
@@ -47,25 +49,24 @@ export default function SignInScreen() {
await setActive({ session: signInAttempt.createdSessionId });
router.replace("/(tabs)");
} else {
console.error(
"Sign-in incomplete:",
JSON.stringify(signInAttempt, null, 2),
);
log.warn("Sign-in incomplete", { status: signInAttempt.status });
setError("Sign-in incomplete. Please try again.");
}
} catch (err: any) {
console.error("Sign-in error:", JSON.stringify(err, null, 2));
} catch (err: unknown) {
log.error("Sign-in failed", err);
// Handle specific error codes
if (err.errors?.[0]?.code === "session_exists") {
if (getClerkErrorCode(err) === "session_exists") {
// User is already signed in, just redirect
router.replace("/(tabs)");
return;
}
setError(
err.errors?.[0]?.message ||
"Failed to sign in. Please check your credentials.",
getErrorMessage(
err,
"Failed to sign in. Please check your credentials.",
),
);
} finally {
setLoading(false);
+10 -13
View File
@@ -13,6 +13,8 @@ import {
ScrollView,
} from "react-native";
import { OAuthButtons } from "../../components/auth/OAuthButtons";
import { getErrorMessage, getClerkErrorCode } from "../../utils/error-helpers";
import log from "../../utils/logger";
export default function SignUpScreen() {
const { signUp, setActive, isLoaded } = useSignUp();
@@ -53,11 +55,9 @@ export default function SignUpScreen() {
await signUp.prepareEmailAddressVerification({ strategy: "email_code" });
setPendingVerification(true);
} catch (err: any) {
console.error("Sign-up error:", JSON.stringify(err, null, 2));
setError(
err.errors?.[0]?.message || "Failed to sign up. Please try again.",
);
} catch (err: unknown) {
log.error("Failed to sign up", err);
setError(getErrorMessage(err, "Failed to sign up. Please try again."));
} finally {
setLoading(false);
}
@@ -78,23 +78,20 @@ export default function SignUpScreen() {
await setActive({ session: completeSignUp.createdSessionId });
router.replace("/(tabs)");
} else {
console.error(
"Verification incomplete:",
JSON.stringify(completeSignUp, null, 2),
);
log.warn("Verification incomplete", { status: completeSignUp.status });
setError("Verification incomplete. Please try again.");
}
} catch (err: any) {
console.error("Verification error:", JSON.stringify(err, null, 2));
} catch (err: unknown) {
log.error("Verification failed", err);
// Handle specific error codes
if (err.errors?.[0]?.code === "session_exists") {
if (getClerkErrorCode(err) === "session_exists") {
// User is already signed in, just redirect
router.replace("/(tabs)");
return;
}
setError(err.errors?.[0]?.message || "Invalid verification code.");
setError(getErrorMessage(err, "Invalid verification code."));
} finally {
setLoading(false);
}