sign in page ui implemented

This commit is contained in:
Sanidhya Kumar Verma
2024-08-29 16:48:31 +00:00
committed by GitHub
parent 0f18202280
commit 3e4c13d87c
4 changed files with 50 additions and 5 deletions
+33 -4
View File
@@ -1,6 +1,7 @@
import { Link } from "expo-router";
import { useState } from "react";
import { Image, ScrollView, Text, View } from "react-native";
import { useSignIn } from "@clerk/clerk-expo";
import { Link, useRouter } from "expo-router";
import { useCallback, useState } from "react";
import { Alert, Image, ScrollView, Text, View } from "react-native";
import { CustomButton } from "@/components/custom-button";
import { InputField } from "@/components/input-field";
@@ -8,12 +9,40 @@ import { OAuth } from "@/components/oauth";
import { icons, images } from "@/constants";
const SignIn = () => {
const router = useRouter();
const { signIn, setActive, isLoaded } = useSignIn();
const [form, setForm] = useState({
email: "",
password: "",
});
const onSignInPress = async () => {};
const onSignInPress = useCallback(async () => {
if (!isLoaded) return;
try {
const signInAttempt = await signIn.create({
identifier: form.email,
password: form.password,
});
if (signInAttempt.status === "complete") {
await setActive({ session: signInAttempt.createdSessionId });
router.replace("/");
} else {
Alert.alert("Error", "Invalid email or password.");
setForm((prevForm) => ({
...prevForm,
password: "",
}));
}
} catch (err: any) {
Alert.alert("Error", err?.errors[0]?.longMessage);
setForm((prevForm) => ({
...prevForm,
password: "",
}));
}
}, [isLoaded, signIn, form.email, form.password, setActive, router]);
return (
<ScrollView className="flex-1 bg-white">
+4
View File
@@ -45,6 +45,10 @@ const SignUp = () => {
password: "",
}));
} catch (err: any) {
setForm((prevForm) => ({
...prevForm,
password: "",
}));
Alert.alert("Error", err?.errors[0]?.longMessage);
}
};