diff --git a/src/front/Api/BaseApiService.ts b/src/front/Api/BaseApiService.ts index 963ceebf..7b8d0ef0 100644 --- a/src/front/Api/BaseApiService.ts +++ b/src/front/Api/BaseApiService.ts @@ -1,125 +1,141 @@ export enum ContentType { - JSON = "application/json", - FORM_DATA = "multipart/form-data;", + JSON = "application/json", + FORM_DATA = "multipart/form-data;", } export default abstract class BaseApiService { - protected readonly backUrl = - process.env["NEXT_PUBLIC_API_HOSTNAME"] + ":" + process.env["NEXT_PUBLIC_API_PORT"] + process.env["NEXT_PUBLIC_API_ROOT_URL"]; - protected readonly proxyUrl = - process.env["NEXT_PUBLIC_RPC_GATEWAY_HOSTNAME"] + - ":" + - process.env["NEXT_PUBLIC_RPC_GATEWAY_PORT"] + - process.env["NEXT_PUBLIC_RPC_GATEWAY_ROOT_URL"]; + protected readonly backUrl = + process.env["NEXT_PUBLIC_API_HOSTNAME"] + + ":" + + process.env["NEXT_PUBLIC_API_PORT"] + + process.env["NEXT_PUBLIC_API_ROOT_URL"]; + protected readonly proxyUrl = + process.env["NEXT_PUBLIC_RPC_GATEWAY_HOSTNAME"] + + ":" + + process.env["NEXT_PUBLIC_RPC_GATEWAY_PORT"] + + process.env["NEXT_PUBLIC_RPC_GATEWAY_ROOT_URL"]; - protected constructor() {} + protected constructor() {} - protected buildHeaders(contentType: ContentType) { - const headers = new Headers(); + protected buildHeaders(contentType: ContentType) { + const headers = new Headers(); - if (contentType === ContentType.JSON) { - headers.set("Content-Type", contentType); - } - headers.set("Access-Control-Allow-Origin", "*"); + if (contentType === ContentType.JSON) { + headers.set("Content-Type", contentType); + } + return headers; + } - return headers; - } + protected buildBody(body: { [key: string]: unknown }): string { + return JSON.stringify(body); + } - protected buildBody(body: { [key: string]: unknown }): string { - return JSON.stringify(body); - } + protected async getRequest(url: URL) { + const request = async () => + await fetch(url, { + method: "GET", + headers: this.buildHeaders(ContentType.JSON), + mode: "no-cors", + }); + console.log(request); + return this.sendRequest(request); + } - protected async getRequest(url: URL) { - const request = async () => - await fetch(url, { - method: "GET", - headers: this.buildHeaders(ContentType.JSON), - }); - console.log(request); - return this.sendRequest(request); - } + protected async postRequest( + url: URL, + body: { [key: string]: unknown } = {} + ) { + const request = async () => + await fetch(url, { + method: "POST", + headers: this.buildHeaders(ContentType.JSON), + body: this.buildBody(body), + }); - protected async postRequest(url: URL, body: { [key: string]: unknown } = {}) { - const request = async () => - await fetch(url, { - method: "POST", - headers: this.buildHeaders(ContentType.JSON), - body: this.buildBody(body), - }); + return this.sendRequest(request); + } - return this.sendRequest(request); - } + protected async putRequest( + url: URL, + body: { [key: string]: unknown } = {} + ) { + const request = async () => + await fetch(url, { + method: "PUT", + headers: this.buildHeaders(ContentType.JSON), + body: this.buildBody(body), + }); - protected async putRequest(url: URL, body: { [key: string]: unknown } = {}) { - const request = async () => - await fetch(url, { - method: "PUT", - headers: this.buildHeaders(ContentType.JSON), - body: this.buildBody(body), - }); + return this.sendRequest(request); + } - return this.sendRequest(request); - } + protected async patchRequest( + url: URL, + body: { [key: string]: unknown } = {} + ) { + const request = async () => + await fetch(url, { + method: "PATCH", + headers: this.buildHeaders(ContentType.JSON), + body: this.buildBody(body), + }); - protected async patchRequest(url: URL, body: { [key: string]: unknown } = {}) { - const request = async () => - await fetch(url, { - method: "PATCH", - headers: this.buildHeaders(ContentType.JSON), - body: this.buildBody(body), - }); + return this.sendRequest(request); + } - return this.sendRequest(request); - } + protected async deleteRequest( + url: URL, + body: { [key: string]: unknown } = {} + ) { + const request = async () => + await fetch(url, { + method: "DELETE", + headers: this.buildHeaders(ContentType.JSON), + body: this.buildBody(body), + }); - protected async deleteRequest(url: URL, body: { [key: string]: unknown } = {}) { - const request = async () => - await fetch(url, { - method: "DELETE", - headers: this.buildHeaders(ContentType.JSON), - body: this.buildBody(body), - }); + return this.sendRequest(request); + } - return this.sendRequest(request); - } + protected async putFormDataRequest(url: URL, body: FormData) { + const request = async () => + await fetch(url, { + method: "PUT", + headers: this.buildHeaders(ContentType.FORM_DATA), + body, + }); - protected async putFormDataRequest(url: URL, body: FormData) { - const request = async () => - await fetch(url, { - method: "PUT", - headers: this.buildHeaders(ContentType.FORM_DATA), - body, - }); + return this.sendRequest(request); + } - return this.sendRequest(request); - } + private async sendRequest(request: () => Promise): Promise { + const response = await request(); + return this.processResponse(response, request); + } - private async sendRequest(request: () => Promise): Promise { - const response = await request(); - response.headers.set("Access-Control-Allow-Origin", "*"); - return this.processResponse(response, request); - } + protected async processResponse( + response: Response, + request: () => Promise + ): Promise { + let responseJson: any | null; + try { + responseJson = await response.json(); + } catch (err: unknown) { + responseJson = null; + } - protected async processResponse(response: Response, request: () => Promise): Promise { - let responseJson: any | null; - try { - responseJson = await response.json(); - } catch (err: unknown) { - responseJson = null; - } + if (!response.ok) { + return Promise.reject(response); + } - if (!response.ok) { - return Promise.reject(response); - } + return responseJson as T; + } - return responseJson as T; - } - - protected onError(error: unknown) { - console.error(error); - } + protected onError(error: unknown) { + console.error(error); + } } export interface IResponse { - http_status: number; + http_status: number; } diff --git a/src/front/Api/LeCoffreApi/Notary/Users/Users.ts b/src/front/Api/LeCoffreApi/Notary/Users/Users.ts index bbc5ffa7..00f54229 100644 --- a/src/front/Api/LeCoffreApi/Notary/Users/Users.ts +++ b/src/front/Api/LeCoffreApi/Notary/Users/Users.ts @@ -4,61 +4,64 @@ import User from "le-coffre-resources/dist/Notary"; @Service() export default class Users extends BaseNotary { - private static instance: Users; - private readonly baseURl = this.namespaceUrl.concat("/Users"); + private static instance: Users; + private readonly baseURl = this.namespaceUrl.concat("/Users"); - private constructor() { - super(); - } + private constructor() { + super(); + } - public static getInstance() { - if (!this.instance) { - return new Users(); - } else { - return this.instance; - } - } + public static getInstance() { + if (!this.instance) { + return new Users(); + } else { + return this.instance; + } + } - public async get(): Promise { - const url = new URL(this.baseURl); - try { - return await this.getRequest(url); - } catch (err) { - this.onError(err); - return Promise.reject(err); - } - } + public async get(): Promise { + const url = new URL(this.baseURl); + try { + return await this.getRequest(url); + } catch (err) { + this.onError(err); + return Promise.reject(err); + } + } - public async getAuthorizationCode(): Promise { - try { - await this.getRequest(new URL(`https://qual-connexion.idnot.fr/IdPOAuth2/authorize/idnot_idp_v1? - client_id=4501646203F3EF67 - &redirect_uri=http://locahost:3000 - &scope=openid,profile,offline_access - &response_type=code`)); - } catch (err) { - this.onError(err); - return Promise.reject(err); - } - } + public async getAuthorizationCode(): Promise { + try { + const url = + new URL(`https://qual-connexion.idnot.fr/IdPOAuth2/authorize/idnot_idp_v1? + client_id=4501646203F3EF67 + &redirect_uri=https://app.stg.lecoffre.smart-chain.fr/ + &scope=openid,profile,offline_access + &response_type=code`); + // const url = new URL("https://jsonplaceholder.typicode.com/todos/1"); + await this.getRequest(url); + } catch (err) { + this.onError(err); + return Promise.reject(err); + } + } - public async getOne(uid: string): Promise { - const url = new URL(this.baseURl.concat("/").concat(uid)); - try { - return await this.getRequest(url); - } catch (err) { - this.onError(err); - return Promise.reject(err); - } - } + public async getOne(uid: string): Promise { + const url = new URL(this.baseURl.concat("/").concat(uid)); + try { + return await this.getRequest(url); + } catch (err) { + this.onError(err); + return Promise.reject(err); + } + } - // public async post(params: User): Promise { - // const url = new URL(this.baseURl); - // try { - // return await this.postRequest(url, params); - // } catch (err) { - // this.onError(err); - // return Promise.reject(err); - // } - // } + // public async post(params: User): Promise { + // const url = new URL(this.baseURl); + // try { + // return await this.postRequest(url, params); + // } catch (err) { + // this.onError(err); + // return Promise.reject(err); + // } + // } } diff --git a/src/front/Assets/icons/coffre.svg b/src/front/Assets/icons/coffre.svg new file mode 100644 index 00000000..78198721 --- /dev/null +++ b/src/front/Assets/icons/coffre.svg @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/front/Components/DesignSystem/Header/index.tsx b/src/front/Components/DesignSystem/Header/index.tsx index b8c176be..02ebfef5 100644 --- a/src/front/Components/DesignSystem/Header/index.tsx +++ b/src/front/Components/DesignSystem/Header/index.tsx @@ -13,10 +13,10 @@ enum EHeaderOpeningState { OPEN = "open", CLOSED = "closed", IDLE = "idle", - } type IProps = { + isUserConnected: boolean; }; type IState = { open: EHeaderOpeningState; @@ -55,18 +55,23 @@ export default class Header extends React.Component { logo - -
-
- -
-
- -
-
- -
-
+ {this.props.isUserConnected && + <> + +
+
+ +
+
+ +
+
+ +
+
+ + } + ); } @@ -98,7 +103,7 @@ export default class Header extends React.Component { } private onResize(window: Window) { - if(window.innerWidth > this.headerBreakpoint && this.state.isBurgerMenuOpen) this.setState({ isBurgerMenuOpen: false }); + if (window.innerWidth > this.headerBreakpoint && this.state.isBurgerMenuOpen) this.setState({ isBurgerMenuOpen: false }); if (window.innerWidth < this.headerBreakpoint && this.state.isProfileMenuOpen) this.setState({ isProfileMenuOpen: false }); } diff --git a/src/front/Components/DesignSystem/InformationBox/classes.module.scss b/src/front/Components/DesignSystem/InformationBox/classes.module.scss new file mode 100644 index 00000000..f68b3ab0 --- /dev/null +++ b/src/front/Components/DesignSystem/InformationBox/classes.module.scss @@ -0,0 +1,4 @@ +@import "@Themes/constants.scss"; + +.root { +} diff --git a/src/front/Components/DesignSystem/InformationBox/index.tsx b/src/front/Components/DesignSystem/InformationBox/index.tsx new file mode 100644 index 00000000..22d60a53 --- /dev/null +++ b/src/front/Components/DesignSystem/InformationBox/index.tsx @@ -0,0 +1,27 @@ +import React from "react"; +import classes from "./classes.module.scss"; + +type IProps = { + informations: IFolderInformation[]; +}; +type IState = {}; + +type IFolderInformation = { + label: string; + value: string; +} + + +export default class InformationBox extends React.Component { + public override render(): JSX.Element { + return
+ {this.props.informations.map((information) => { + const output =
+ {information.label} + {information.value} +
; + return output; + })}; +
; + } +} diff --git a/src/front/Components/LayoutTemplates/DefaultDoubleSidePage/classes.module.scss b/src/front/Components/LayoutTemplates/DefaultDoubleSidePage/classes.module.scss new file mode 100644 index 00000000..e8e2a204 --- /dev/null +++ b/src/front/Components/LayoutTemplates/DefaultDoubleSidePage/classes.module.scss @@ -0,0 +1,38 @@ +@import "@Themes/constants.scss"; + +.root { + max-height: 100vh; + min-height: 100vh; + overflow: hidden; + + .content { + display: flex; + align-items: center; + height: 100vh; + width: 100%; + + .sides { + width: 100%; + height: 100vh; + display: flex; + align-items: center; + justify-content: center; + + &.image-container { + @media (max-width: $screen-m) { + display: none; + } + } + + .side-content { + max-width: 530px; + } + + .image { + height: 100%; + width: 100%; + object-fit: cover; + } + } + } +} \ No newline at end of file diff --git a/src/front/Components/LayoutTemplates/DefaultDoubleSidePage/index.tsx b/src/front/Components/LayoutTemplates/DefaultDoubleSidePage/index.tsx new file mode 100644 index 00000000..b6bd2d98 --- /dev/null +++ b/src/front/Components/LayoutTemplates/DefaultDoubleSidePage/index.tsx @@ -0,0 +1,49 @@ +import React, { ReactNode } from "react"; +import classes from "./classes.module.scss"; +import Header from "@Front/Components/DesignSystem/Header"; +import Version from "@Front/Components/DesignSystem/Version"; +import Image, { StaticImageData } from "next/image"; +import classNames from "classnames"; + +type IProps = { + title: string; + children?: ReactNode; + /** + * @description scroll top with number or disabled with null + */ + scrollTop: number | null; + image: StaticImageData; +}; +type IState = {}; + +export default class DefaultDoubleSidePage extends React.Component { + public static defaultProps = { + scrollTop: 0, + }; + + public override render(): JSX.Element { + return ( +
+
+
+
+
+ {this.props.children} +
+
+
+ {"right +
+
+ +
+ ); + } + + public override componentDidMount() { + window.document.title = this.props.title; + if (this.props.scrollTop !== null) { + window.scrollTo(0, this.props.scrollTop); + } + } +} diff --git a/src/front/Components/LayoutTemplates/DefaultTemplate/index.tsx b/src/front/Components/LayoutTemplates/DefaultTemplate/index.tsx index d639f9c8..c7ecd3e4 100644 --- a/src/front/Components/LayoutTemplates/DefaultTemplate/index.tsx +++ b/src/front/Components/LayoutTemplates/DefaultTemplate/index.tsx @@ -21,7 +21,7 @@ export default class DefaultTemplate extends React.Component { public override render(): JSX.Element { return ( <> -
+
{this.props.children}
diff --git a/src/front/Components/Layouts/Login/classes.module.scss b/src/front/Components/Layouts/Login/classes.module.scss index c3a2af63..53e48bc0 100644 --- a/src/front/Components/Layouts/Login/classes.module.scss +++ b/src/front/Components/Layouts/Login/classes.module.scss @@ -1,2 +1,16 @@ .root { -} + display: flex; + align-items: center; + justify-content: center; + flex-direction: column; + + .title { + margin: 32px 0; + text-align: center; + } + + .forget-password { + margin-top: 32px; + margin-bottom: 8px; + } +} \ No newline at end of file diff --git a/src/front/Components/Layouts/Login/index.tsx b/src/front/Components/Layouts/Login/index.tsx index d4d3c70f..00e1e676 100644 --- a/src/front/Components/Layouts/Login/index.tsx +++ b/src/front/Components/Layouts/Login/index.tsx @@ -1,19 +1,46 @@ -import Users from "@Front/Api/LeCoffreApi/Notary/Users/Users"; -import Button from "@Front/Components/DesignSystem/Button"; +import Button, { EButtonVariant } from "@Front/Components/DesignSystem/Button"; import Typography, { ITypo } from "@Front/Components/DesignSystem/Typography"; -import DefaultTemplate from "@Front/Components/LayoutTemplates/DefaultTemplate"; import BasePage from "../Base"; import classes from "./classes.module.scss"; +import CoffreIcon from "@Assets/Icons/coffre.svg"; +import LandingImage from "./landing-connect.png" +import Image from "next/image"; +import DefaultDoubleSidePage from "@Front/Components/LayoutTemplates/DefaultDoubleSidePage"; export default class Login extends BasePage { + //constructor + public constructor(props: any) { + super(props); + // this.getAuthorizationCode = this.getAuthorizationCode.bind(this); + } public override render(): JSX.Element { return ( - +
- login - + coffre +
Connexion espace professionnel
+ + CONNECT +
Vous n’arrivez pas à vous connecter ?
+
-
+ ); } + + private redirectUserOnConnection() { + const url = `https://qual-connexion.idnot.fr/IdPOAuth2/authorize/idnot_idp_v1? + client_id=4501646203F3EF67 + &scope=openid,profile,offline_access + &response_type=code`; + window.location.assign(url) + } + + // private getAuthorizationCode() { + // Users.getInstance().getAuthorizationCode() + // } } diff --git a/src/front/Components/Layouts/Login/landing-connect.png b/src/front/Components/Layouts/Login/landing-connect.png new file mode 100644 index 00000000..5fd6f853 Binary files /dev/null and b/src/front/Components/Layouts/Login/landing-connect.png differ