diff --git a/dependencygraph.svg b/dependencygraph.svg deleted file mode 100644 index 57da55e9..00000000 --- a/dependencygraph.svg +++ /dev/null @@ -1,271 +0,0 @@ - - - - - - -dependency-cruiser output - - -cluster_src - -src - - -cluster_src/Components - -Components - - -cluster_src/Components/Map - -Map - - -cluster_src/Utils - -Utils - - - -src/Components/Map/AddButton.tsx - - -AddButton.tsx - - - - - -src/Utils/DynamicHeroIcon.tsx - - -DynamicHeroIcon.tsx - - - - - -src/Components/Map/AddButton.tsx->src/Utils/DynamicHeroIcon.tsx - - - - - -src/Components/Map/Layer.tsx - - -Layer.tsx - - - - - -src/Utils/MarkerIconFactory.ts - - -MarkerIconFactory.ts - - - - - -src/Components/Map/Layer.tsx->src/Utils/MarkerIconFactory.ts - - - - - -src/Components/Map/Popup.tsx - - -Popup.tsx - - - - - -src/Components/Map/Layer.tsx->src/Components/Map/Popup.tsx - - - - - -src/Components/Map/useItems.tsx - - -useItems.tsx - - - - - -src/Components/Map/Layer.tsx->src/Components/Map/useItems.tsx - - - - - -src/Utils/ReplaceURLs.ts - - -ReplaceURLs.ts - - - - - -src/Components/Map/Popup.tsx->src/Utils/ReplaceURLs.ts - - - - - -src/Components/Map/NewItemPopup.tsx - - -NewItemPopup.tsx - - - - - -src/Components/Map/NewItemPopup.tsx->src/Components/Map/useItems.tsx - - - - - -src/types.ts - - -types.ts - - - - - -src/Components/Map/NewItemPopup.tsx->src/types.ts - - - - - -src/Components/Map/UtopiaMap.tsx - - -UtopiaMap.tsx - - - - - -src/Components/Map/NewItemPopup.tsx->src/Components/Map/UtopiaMap.tsx - - - - - - - -src/Components/Map/UtopiaMap.tsx->src/Components/Map/AddButton.tsx - - - - - -src/Components/Map/UtopiaMap.tsx->src/Components/Map/useItems.tsx - - - - - -src/Components/Map/UtopiaMap.tsx->src/Components/Map/NewItemPopup.tsx - - - - - - - -src/Components/Map/UtopiaMap.tsx->src/types.ts - - - - - -src/index.css - - -index.css - - - - - -src/Components/Map/UtopiaMap.tsx->src/index.css - - - - - -src/Components/Map/UtopiaMap.stories.tsx - - -UtopiaMap.stories.tsx - - - - - -src/Components/Map/UtopiaMap.stories.tsx->src/Components/Map/Layer.tsx - - - - - -src/Components/Map/UtopiaMap.stories.tsx->src/Components/Map/UtopiaMap.tsx - - - - - -src/Components/Map/index.tsx - - -index.tsx - - - - - -src/Components/Map/index.tsx->src/Components/Map/UtopiaMap.tsx - - - - - -src/index.tsx - - -index.tsx - - - - - -src/index.tsx->src/Components/Map/Layer.tsx - - - - - -src/index.tsx->src/Components/Map/index.tsx - - - - - diff --git a/src/Components/AppShell/NavBar.tsx b/src/Components/AppShell/NavBar.tsx index 9507f044..cc6ef303 100644 --- a/src/Components/AppShell/NavBar.tsx +++ b/src/Components/AppShell/NavBar.tsx @@ -4,42 +4,70 @@ 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); -export default function NavBar({appName, useAuth} : {appName: string, useAuth : any}) { const [email, setEmail] = useState(""); const [userName, setUserName] = useState(""); const [password, setPassword] = useState(""); + const { isAuthenticated, user, login, register, loading, logout, token } = useAuth(); - const onRegister = () => { - toast.promise( - register({ email: email, password: password}, userName), + const onRegister = async () => { + await toast.promise( + register({ email: email, password: password }, userName), { success: { - render({data}){ + render({ data }) { return `Hi ${data?.first_name}` }, // other options icon: "✌️", }, - error: 'Error' + error: 'Error', + pending: '123 ...' }); + setSignupOpen(false); } - const onLogin = () => { - toast.promise( + const onLogin = async () => { + await toast.promise( login({ email: email, password: password }), { success: { - render({data}){ + render({ data }) { return `Hi ${data?.first_name}` }, // other options icon: "✌️", }, - error: 'Error' + error: 'Error', + pending: '123 ...' + }); + setLoginOpen(false); + } + + const onLogout = () => { + toast.promise( + logout(), + { + success: { + render() { + return `Bye bye` + }, + // other options + icon: "👋", + }, + error: 'Error', + pending: '123 ...' }); } @@ -54,21 +82,21 @@ export default function NavBar({appName, useAuth} : {appName: string, useAuth :
-
-

{appName}

- +
+

{appName}

+ -
+
- + {isAuthenticated ?
{user.avatar ?
- -
+ @@ -77,49 +105,62 @@ export default function NavBar({appName, useAuth} : {appName: string, useAuth : -
- : + :
- -
-
+ 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" /> +
+ +
+
) } diff --git a/src/Components/Auth/index.tsx b/src/Components/Auth/index.tsx index 415ff395..0142c432 100644 --- a/src/Components/Auth/index.tsx +++ b/src/Components/Auth/index.tsx @@ -1 +1,3 @@ -export {AuthProvider, useAuth} from "./useAuth" \ No newline at end of file +export {AuthProvider, useAuth} from "./useAuth" +export {LoginPage} from "./LoginPage" +export {SignupPage} from "./SignupPage" \ No newline at end of file diff --git a/src/Components/Auth/useAuth.tsx b/src/Components/Auth/useAuth.tsx index c54a1fe5..4a0556a9 100644 --- a/src/Components/Auth/useAuth.tsx +++ b/src/Components/Auth/useAuth.tsx @@ -52,12 +52,16 @@ export const AuthProvider = ({ userApi, children }: AuthProviderProps) => { async function loadUser(): Promise { try { - const me = await userApi.getUser(); - setUser(me as UserItem); - const token = await userApi.getToken(); + const token = await userApi.getToken(); setToken(token); - setLoading(false); - return me as UserItem; + if(token){ + const me = await userApi.getUser(); + setUser(me as UserItem); + setLoading(false); + return me as UserItem; + } + else return undefined; + } catch (error) { setLoading(false) return undefined; diff --git a/src/Components/Templates/CardPage.tsx b/src/Components/Templates/CardPage.tsx index f7099f01..76484487 100644 --- a/src/Components/Templates/CardPage.tsx +++ b/src/Components/Templates/CardPage.tsx @@ -15,7 +15,7 @@ export function CardPage({title,children} : {
  • Home
  • -
  • FAQ
  • +
  • {title}
diff --git a/src/index.tsx b/src/index.tsx index b5f64a07..4f5461e5 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -1,6 +1,6 @@ export { UtopiaMap, Layer, Tags, Item, Tag } from './Components/Map/index'; export {AppShell, Content, SideBar} from "./Components/AppShell" -export {AuthProvider, useAuth} from "./Components/Auth" +export {AuthProvider, useAuth, LoginPage, SignupPage} from "./Components/Auth" export {Settings} from './Components/Profile' export {Quests, Modal} from './Components/Gaming' export {TitleCard, CardPage} from './Components/Templates' @@ -10,5 +10,6 @@ import "./index.css" declare global { interface Window { my_modal_3: any; + sign_up_modal: any; } } \ No newline at end of file