Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

readd completeOnboarding call #43

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion frontend/pages/Login.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,15 @@ import { useSignIn } from '@clerk/clerk-expo';
import { useNavigation } from '@react-navigation/native';
import { AuthNavigationProp } from '../types/navigationTypes';
import { ClerkErrorResponse } from '../types/types';
import { useDispatch } from 'react-redux';
import { completeOnboarding } from '../reducers/onboarding/onboardingReducer';

const Login: React.FC = () => {
const navigation = useNavigation<AuthNavigationProp>();
const { signIn, setActive, isLoaded } = useSignIn();
const [identifier, setIdentifier] = useState<string>('');
const [password, setPassword] = useState<string>('');
const dispatch = useDispatch();

const handleLogin = async () => {
if (!isLoaded) {
Expand All @@ -25,14 +28,15 @@ const Login: React.FC = () => {
});

await setActive({ session: completeSignIn.createdSessionId });
dispatch(completeOnboarding());
} catch (error) {
const clerkError = error as ClerkErrorResponse;
const clerkMessage = clerkError.errors[0].message;
if(clerkMessage === "Couldn't find your account.") {
Alert.alert('Username or email does not exist');
return;
}
Alert.alert('Invalid password. Please try again.');
Alert.alert(clerkMessage);
}
};

Expand Down
Loading