From a25c9f984674653c88f8323186137786028939c0 Mon Sep 17 00:00:00 2001 From: muhammadeko Date: Fri, 6 May 2022 16:13:57 +0700 Subject: [PATCH] wip --- public/locales/en-US/gcauth.json | 4 ++ src/components/MenuDesktop.tsx | 6 ++ src/components/MenuMobile.tsx | 6 ++ src/components/Navbar.tsx | 108 ++++++++++++++++--------------- src/components/RouteMenu.tsx | 4 ++ src/components/pages/GCAuth.tsx | 74 +++++++++++++++++++++ src/i18n.ts | 2 +- 7 files changed, 151 insertions(+), 53 deletions(-) create mode 100644 public/locales/en-US/gcauth.json create mode 100644 src/components/pages/GCAuth.tsx diff --git a/public/locales/en-US/gcauth.json b/public/locales/en-US/gcauth.json new file mode 100644 index 0000000..61a5e94 --- /dev/null +++ b/public/locales/en-US/gcauth.json @@ -0,0 +1,4 @@ +{ + "navigation": "GCAuth", + "title": "GCAuth Token Generator" +} \ No newline at end of file diff --git a/src/components/MenuDesktop.tsx b/src/components/MenuDesktop.tsx index 3a93fdb..342ffed 100644 --- a/src/components/MenuDesktop.tsx +++ b/src/components/MenuDesktop.tsx @@ -20,6 +20,12 @@ export default function MenuDesktop(props:{handleHeaderTitleChange: (title:strin ) : ( handleHeaderTitleChange("Artifact Command Generator")} className="menu-item text-gray-300 hover:bg-gray-700 hover:text-white px-3 py-2 rounded-md text-sm font-medium">Artifact )} + + {location.pathname === "/gcauth" ? ( + GCAuth + ) : ( + handleHeaderTitleChange("GCAuth Token Generator")} className="menu-item block text-gray-300 hover:bg-gray-700 hover:text-white px-3 py-2 rounded-md text-sm font-medium">GCAuth + )} ) } \ No newline at end of file diff --git a/src/components/MenuMobile.tsx b/src/components/MenuMobile.tsx index d81ac35..b24f03d 100644 --- a/src/components/MenuMobile.tsx +++ b/src/components/MenuMobile.tsx @@ -20,6 +20,12 @@ export default function MenuMobile(props: any) { ) : ( handleHeaderTitleChange("Artifact Command Generator")} className="menu-item block text-gray-300 hover:bg-gray-700 hover:text-white px-3 py-2 rounded-md text-sm font-medium">Artifact )} + + {location.pathname === "/gcauth" ? ( + GCAuth + ) : ( + handleHeaderTitleChange("GCAuth Token Generator")} className="menu-item block text-gray-300 hover:bg-gray-700 hover:text-white px-3 py-2 rounded-md text-sm font-medium">GCAuth + )} ) } \ No newline at end of file diff --git a/src/components/Navbar.tsx b/src/components/Navbar.tsx index def1893..4072a75 100644 --- a/src/components/Navbar.tsx +++ b/src/components/Navbar.tsx @@ -1,14 +1,20 @@ -import React from "react"; +import React, {useEffect} from "react"; import MenuDesktop from "./MenuDesktop"; import MenuMobile from "./MenuMobile"; import {Menu} from "@mui/material"; -import i18n from "i18next"; +import i18n, {use} from "i18next"; import {useTranslation} from "react-i18next"; import LanguageChange from "./LanguageChange"; +import {useNavigate} from "react-router-dom"; -class Navbar extends React.Component { - handleHeaderTitleChange; - toggleMobileMenu = () => { +interface Props { + handleHeaderTitleChange: (title: string) => void; +} +export default function Navbar(props: Props) { + const {handleHeaderTitleChange} = props; + const pathname = window.location.pathname; + const {t} = useTranslation(); + const toggleMobileMenu = () => { const menuShow = document.querySelector(".menu-show"); const menuHide = document.querySelector(".menu-hide"); const mobileMenu = document.querySelector("#mobile-menu"); @@ -28,56 +34,54 @@ class Navbar extends React.Component { } } } - - constructor(props:{handleHeaderTitleChange: (title:string) => void}) { - super(props); - const {handleHeaderTitleChange} = props; - - this.handleHeaderTitleChange = handleHeaderTitleChange; - const pathname =window.location.pathname; - - if(pathname==="/") handleHeaderTitleChange("Home") - else if(pathname==="/artifact") handleHeaderTitleChange("Artifact Command Generator") - } - - render() { - return( - + ) +} \ No newline at end of file diff --git a/src/components/RouteMenu.tsx b/src/components/RouteMenu.tsx index 6df7131..19078d8 100644 --- a/src/components/RouteMenu.tsx +++ b/src/components/RouteMenu.tsx @@ -1,6 +1,7 @@ import {Routes, Route, RouteProps} from "react-router-dom"; import React from "react"; import Artifacts from "./pages/Artifacts"; +import GCAuth from "./pages/GCAuth"; interface RouteMenuProps extends RouteProps{ handleHeaderTitleChange: (title: string) => void; @@ -17,6 +18,9 @@ export default function RouteMenu(props: RouteMenuProps) { }/> + + }/> ); } \ No newline at end of file diff --git a/src/components/pages/GCAuth.tsx b/src/components/pages/GCAuth.tsx new file mode 100644 index 0000000..b5f16e7 --- /dev/null +++ b/src/components/pages/GCAuth.tsx @@ -0,0 +1,74 @@ +import {useEffect, useState} from "react"; +import {Autocomplete, TextField} from "@mui/material"; + +interface IGCAuthResponse{ + status: string; + message: string; + jwt: string; +} + +interface IJWTPayload{ + token: string; + username: string; + uid: string; +} + +interface IGCAuthLogin{ + username: string; + password: string; +} + +interface IGCAuthRegister{ + username: string; + password: string; + password_confirmation: string; +} + +interface IGCAuthChangePassword{ + username: string; + new_password: string; + new_password_confirmation: string; + old_password: string; +} + +export default function GCAuth() { + const [jwt, setJwt] = useState(""); + const [dispatchServer, setDispatchServer] = useState(""); + const [useSSl, setUseSSl] = useState(true); + const [baseUrl, setBaseUrl] = useState(""); + + const checkGCAuth = async ()=>{ + fetch(baseUrl+"/authentication/type") + .then(res => res.text()) + .then(res => { + if (res === "me.exzork.gcauth.handler.GCAuthAuthenticationHandler"){ + console.log("GCAuth is installed"); + }else{ + console.log("GCAuth is not installed"); + } + }) + .catch(err => { + console.log(err); + }); + } + + useEffect(() => { + setBaseUrl(`http${useSSl ? "s" : ""}://${dispatchServer}`); + }, [useSSl, dispatchServer]); + return ( + <> +
+
+
+ setDispatchServer(e.currentTarget.value)} placeholder="Input server ip/domain with port, ex : genshin.exzork.me:443" className="block w-full shadow-sm focus:ring-indigo-500 focus:border-indigo-500 sm:text-sm border-gray-300 rounded-md"/> +
+ setUseSSl(e.currentTarget.checked)} id="with-ssl" className="form-checkbox m-auto text-indigo-600 transition duration-150 ease-in-out"/> + +
+ +
+
+
+ + ) +} \ No newline at end of file diff --git a/src/i18n.ts b/src/i18n.ts index 3c5a4cd..2e6d058 100644 --- a/src/i18n.ts +++ b/src/i18n.ts @@ -13,7 +13,7 @@ i18n interpolation: { escapeValue: false, // not needed for react!! }, - ns: ["artifact"], + ns: ["artifact","gcauth"], defaultNS: "", });