fix prettier conflicts
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
// Login.tsx
|
||||
import React, { useEffect, useState } from 'react';
|
||||
import AsyncStorage from "@react-native-async-storage/async-storage";
|
||||
import { FirebaseAuthTypes } from "@react-native-firebase/auth";
|
||||
import React, { useEffect, useState } from "react";
|
||||
import {
|
||||
Button,
|
||||
Keyboard,
|
||||
@@ -7,27 +9,30 @@ import {
|
||||
TextInput,
|
||||
TouchableWithoutFeedback,
|
||||
View,
|
||||
} from 'react-native';
|
||||
import { handleSignInWithPhoneNumber, confirmCode, onAuthStateChanged } from '../auth';
|
||||
import { FirebaseAuthTypes } from '@react-native-firebase/auth';
|
||||
import { useAuthHeader } from '../graphql/client';
|
||||
import AsyncStorage from '@react-native-async-storage/async-storage';
|
||||
import SignOutButton from '../component/buttons/sign-out';
|
||||
} from "react-native";
|
||||
import {
|
||||
confirmCode,
|
||||
handleSignInWithPhoneNumber,
|
||||
onAuthStateChanged,
|
||||
} from "../auth";
|
||||
import SignOutButton from "../component/buttons/sign-out";
|
||||
import { useAuthHeader } from "../graphql/client";
|
||||
|
||||
export default function Login() {
|
||||
const [phoneNumber, setPhoneNumber] = useState<string>('');
|
||||
const [code, setCode] = useState<string>('');
|
||||
const [phoneNumber, setPhoneNumber] = useState<string>("");
|
||||
const [code, setCode] = useState<string>("");
|
||||
const [user, setUser] = useState<FirebaseAuthTypes.User | null>(null);
|
||||
const [confirm, setConfirm] = useState<FirebaseAuthTypes.ConfirmationResult | null>(null);
|
||||
const { authHeader, setAuthHeader } = useAuthHeader()
|
||||
const [confirm, setConfirm] =
|
||||
useState<FirebaseAuthTypes.ConfirmationResult | null>(null);
|
||||
const { authHeader, setAuthHeader } = useAuthHeader();
|
||||
|
||||
useEffect(() => {
|
||||
const unsubscribe = onAuthStateChanged(async (user) => {
|
||||
setUser(user)
|
||||
setUser(user);
|
||||
if (user) {
|
||||
const token = await user.getIdToken()
|
||||
const token = await user.getIdToken();
|
||||
if (token) {
|
||||
await AsyncStorage.setItem('token', token);
|
||||
await AsyncStorage.setItem("token", token);
|
||||
setAuthHeader({ key: "Authorization", value: `Bearer ${token}` });
|
||||
}
|
||||
}
|
||||
@@ -36,11 +41,9 @@ export default function Login() {
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, []);
|
||||
|
||||
|
||||
|
||||
return (
|
||||
<TouchableWithoutFeedback onPress={() => Keyboard.dismiss()}>
|
||||
<View style={{ alignItems: 'center' }}>
|
||||
<View style={{ alignItems: "center" }}>
|
||||
<TextInput
|
||||
style={{
|
||||
width: "50%",
|
||||
@@ -74,10 +77,16 @@ export default function Login() {
|
||||
/>
|
||||
)}
|
||||
<Button
|
||||
title={!confirm ? 'Receive code' : 'Confirm code'}
|
||||
onPress={() => !confirm ? handleSignInWithPhoneNumber(phoneNumber).then(setConfirm) : confirm && confirmCode(confirm, code)}
|
||||
title={!confirm ? "Receive code" : "Confirm code"}
|
||||
onPress={() =>
|
||||
!confirm
|
||||
? handleSignInWithPhoneNumber(phoneNumber).then(setConfirm)
|
||||
: confirm && confirmCode(confirm, code)
|
||||
}
|
||||
/>
|
||||
<Text>{authHeader.key}: {authHeader.value}</Text>
|
||||
<Text>
|
||||
{authHeader.key}: {authHeader.value}
|
||||
</Text>
|
||||
{user && (
|
||||
<>
|
||||
<Text style={{ marginTop: 10 }}>
|
||||
|
Reference in New Issue
Block a user