diff --git a/src/front/Api/Auth/IdNot/index.ts b/src/front/Api/Auth/IdNot/index.ts index 1255ce5a..11b6f7be 100644 --- a/src/front/Api/Auth/IdNot/index.ts +++ b/src/front/Api/Auth/IdNot/index.ts @@ -1,5 +1,6 @@ import { Service } from "typedi"; import BaseApiService from "@Front/Api/BaseApiService"; +import { FrontendVariables } from "@Front/Config/VariablesFront"; @Service() export default class Auth extends BaseApiService { @@ -25,15 +26,18 @@ export default class Auth extends BaseApiService { } } - public async getIdnotJwt(autorizationCode: string | string[]) { + public async getIdnotJwt(autorizationCode: string | string[]): Promise { + const baseBackUrl = FrontendVariables.getInstance().BACK_API_PROTOCOL + + FrontendVariables.getInstance().BACK_API_HOST + + (FrontendVariables.getInstance().BACK_API_PORT ? ":" + FrontendVariables.getInstance().BACK_API_PORT : ""); const url = new URL( - `http://127.0.0.1:3001/api/v1/idnot-user/${autorizationCode}` + `${baseBackUrl}/api/v1/idnot-user/${autorizationCode}` ); try { - await this.postRequest(url); + return await this.postRequest(url); } catch (err) { this.onError(err); - //return Promise.reject(err); + return Promise.reject(err); } } } diff --git a/src/front/Components/Layouts/LoginCallback/index.tsx b/src/front/Components/Layouts/LoginCallback/index.tsx index ea9c09ad..7f7a1512 100644 --- a/src/front/Components/Layouts/LoginCallback/index.tsx +++ b/src/front/Components/Layouts/LoginCallback/index.tsx @@ -1,23 +1,43 @@ // import classes from "./classes.module.scss"; // import LandingImage from "../Login/landing-connect.png"; // import DefaultDoubleSidePage from "@Front/Components/LayoutTemplates/DefaultDoubleSidePage"; +// import Image from "next/image"; +// import CoffreIcon from "@Assets/Icons/coffre.svg"; +// import Button, { EButtonVariant } from "@Front/Components/DesignSystem/Button"; +// import Typography, { ITypo } from "@Front/Components/DesignSystem/Typography"; import { useRouter } from "next/router"; +//import React, { useEffect, useState } from "react"; import React from "react"; //import Loader from "@Front/Components/DesignSystem/Loader"; import Auth from "@Front/Api/Auth/IdNot"; import Folder from "../Folder"; +import LoginClass from "../Login"; -type IPropsClass = {}; + type IPropsClass = {}; -//type IStateClass = {}; +// type IStateClass = {}; // class LoginCallBackClass extends React.Component { // public override render(): JSX.Element { // return ( // //
+// coffre +// +//
+// Connexion espace professionnel +//
+//
// +// +//
+// Vous n’arrivez pas à vous connecter ? +//
+//
+// //
//
// ); @@ -25,20 +45,47 @@ type IPropsClass = {}; // } // TODO: Refacto with functionnal component container of classcomponent +// export default function LoginCallBack(props: IPropsClass) { +// const [user, setUser] = useState(null); +// const [isLoading, setIsLoading] = useState(false); +// const router = useRouter(); +// const { code } = router.query; +// if (code) { +// useEffect(() => { +// const getIdNotJwt = async () => { +// setIsLoading(true); +// try { +// const authService = Auth.getInstance(); +// const fetchedUser = await authService.getIdnotJwt(code); +// setUser(fetchedUser); +// } catch (error) { +// console.error(error); +// // Router.push('/login'); +// } +// }; +// getIdNotJwt(); +// }, []); +// if (isLoading) return +// return ; +// } +// return +// } + export default function LoginCallBack(props: IPropsClass) { - const router = useRouter(); - const { code } = router.query; - if (code) { - const getIdNotJwt = async () => { - try { - const authService = Auth.getInstance(); - await authService.getIdnotJwt(code); - } catch (error) { - console.error(error); - // Router.push('/login'); - } - }; - getIdNotJwt(); + const router = useRouter(); + const { code } = router.query; + if (code) { + const getIdNotJwt = async () => { + try { + const authService = Auth.getInstance(); + await authService.getIdnotJwt(code); + } catch (error) { + console.error(error); + // Router.push('/login'); + } + }; + getIdNotJwt(); + return ; + } + return } - return ; -} \ No newline at end of file