import { useState } from "react"; //import { useAuth } from "../api/auth"; import { Link } from "react-router-dom"; import { toast } from "react-toastify"; import QuestionMarkIcon from '@heroicons/react/24/outline/QuestionMarkCircleIcon' import * as React from "react"; import DialogModal from "./DialogModal"; export default function NavBar({ appName, useAuth }: { appName: string, useAuth: any }) { const [signupOpen, setSignupOpen] = useState(false); const [loginOpen, setLoginOpen] = useState(false); const [email, setEmail] = useState(""); const [userName, setUserName] = useState(""); const [password, setPassword] = useState(""); const { isAuthenticated, user, login, register, loading, logout, token } = useAuth(); const onRegister = async () => { await toast.promise( register({ email: email, password: password }, userName), { success: { render({ data }) { return `Hi ${data?.first_name}` }, // other options icon: "✌️", }, error: 'Error', pending: '123 ...' }); setSignupOpen(false); } const onLogin = async () => { await toast.promise( login({ email: email, password: password }), { success: { render({ data }) { return `Hi ${data?.first_name}` }, // other options icon: "✌️", }, error: 'Error', pending: 'logging in ...' }); setLoginOpen(false); } const onLogout = () => { toast.promise( logout(), { success: { render() { return `Bye bye` }, // other options icon: "👋", }, error: 'Error', pending: 'logging out ..' }); } return ( <>

{appName}

{isAuthenticated ?
{user.avatar ? :
setLoginOpen(true)} className="tw-btn tw-btn-ghost tw-mr-2"> Login
setSignupOpen(true)} className="tw-btn tw-btn-ghost tw-mr-2"> Sign Up
}
setLoginOpen(false)}> setEmail(e.target.value)} className="tw-input tw-input-bordered tw-w-full tw-max-w-xs" /> setPassword(e.target.value)} className="tw-input tw-input-bordered tw-w-full tw-max-w-xs" />
setSignupOpen(false)}> setUserName(e.target.value)} className="tw-input tw-input-bordered tw-w-full tw-max-w-xs" /> setEmail(e.target.value)} className="tw-input tw-input-bordered tw-w-full tw-max-w-xs" /> setPassword(e.target.value)} className="tw-input tw-input-bordered tw-w-full tw-max-w-xs" />
) }