From 3a785c212a00bdb1cf095e31de81a294a05a8c9a Mon Sep 17 00:00:00 2001 From: franciszek Date: Tue, 2 Feb 2021 17:39:23 +0100 Subject: [PATCH] fixing auth, added registration page --- src/front/Nav.tsx | 34 ++++++++++++----- src/front/app.tsx | 47 +++++++++-------------- src/front/login.tsx | 37 +++++++++---------- src/front/register.html | 14 +++++++ src/front/register.tsx | 78 +++++++++++++++++++++++++++++++++++++++ src/front/styles/nav.scss | 1 + 6 files changed, 153 insertions(+), 58 deletions(-) create mode 100644 src/front/register.html create mode 100644 src/front/register.tsx diff --git a/src/front/Nav.tsx b/src/front/Nav.tsx index 9b7a1aa..43ec418 100644 --- a/src/front/Nav.tsx +++ b/src/front/Nav.tsx @@ -1,27 +1,43 @@ -import React, { ReactElement, useEffect, useState } from "react"; +import axios from "axios"; +import React, { ReactElement } from "react"; import "./styles/nav.scss"; interface Props { isLogged: boolean; + logoutState: () => void; } const NOT_LOGGED = [ { name: "aplikacja", href: "/" }, { name: "logowanie", href: "login.html" }, + { name: "rejestracja", href: "register.html" }, ]; -const LOGGED = [ - { name: "aplikacja", href: "/" }, - { name: "wyloguj", href: "login.html" }, -]; -function Nav({ isLogged }: Props): ReactElement { +const LOGGED = [{ name: "aplikacja", href: "/" }]; + +function Nav({ isLogged, logoutState }: Props): ReactElement { + const logout = async () => { + await axios.delete( + "http://localhost:8080/api/v1/collections/sessions/current" + ); + logoutState(); + }; + return (