// @ts-nocheck
import * as React from "react";
import { useCallback } from "react";
import { View, Text, TouchableOpacity, ScrollView } from "react-native";
import Button from "../ui/button";
import Input from "../ui/text-field";
import { style } from "./style";
import { Tabs } from "../tabs";
import { LoginButttons } from "./login-buttons";
import { AUTH_PROVIDERS, authService } from "../../services/auth";
import { useSiteSettings } from "../../providers/site";
import Modal from "react-native-modal";
const ErrorMessage = ({
show,
children,
}: {
show: boolean;
children: string;
}) => {
return (
<>
{show ? (
{children}
) : null}
>
);
};
type LoginModalType = {
open: boolean;
onClose: () => void;
onOpenOauth?: (provider: string) => void;
};
export const LoginModal = ({ open, onClose, onOpenOauth }: LoginModalType) => {
const {
style: siteStyle,
regions: {
header: { authentication },
},
} = useSiteSettings();
const [email, setEmail] = React.useState("");
const [password, setPassword] = React.useState("");
const [error, setError] = React.useState("");
const [submitted, setSubmitted] = React.useState(false);
const [loading, setLoading] = React.useState(false);
const [currentTab, setCurrentTab] = React.useState("login");
const onLoginButtonPressed = useCallback(
(provider: keyof typeof AUTH_PROVIDERS) => {
onClose();
if (onOpenOauth) onOpenOauth(provider || "");
// navigation.navigate('oauth-webview', {provider});
},
[onClose]
);
const onSubmit = useCallback(() => {
setSubmitted(true);
if (loading || !email || !password) {
return;
}
setLoading(true);
authService
.maestroLogin(email, password)
.then(() => {
setLoading(false);
onClose();
})
.catch((error) => {
setLoading(false);
setError(error.message);
});
}, [email, password, loading]);
return (
{authentication.maestro ? (
Email is required
Password is required
{error}
I forgot my password
),
},
{
id: "signup",
title: "Sign up",
content: (
),
},
]}
>
) : null}
Powered by Maestro
);
};