add login page
This commit is contained in:
parent
e98b8b601b
commit
50d157a1da
@ -12,7 +12,6 @@ export default abstract class BaseApiService {
|
||||
process.env["NEXT_PUBLIC_RPC_GATEWAY_PORT"] +
|
||||
process.env["NEXT_PUBLIC_RPC_GATEWAY_ROOT_URL"];
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
||||
protected constructor() {}
|
||||
|
||||
protected buildHeaders(contentType: ContentType) {
|
||||
@ -21,6 +20,8 @@ export default abstract class BaseApiService {
|
||||
if (contentType === ContentType.JSON) {
|
||||
headers.set("Content-Type", contentType);
|
||||
}
|
||||
headers.set("Access-Control-Allow-Origin", "*");
|
||||
|
||||
return headers;
|
||||
}
|
||||
|
||||
@ -34,7 +35,7 @@ export default abstract class BaseApiService {
|
||||
method: "GET",
|
||||
headers: this.buildHeaders(ContentType.JSON),
|
||||
});
|
||||
|
||||
console.log(request);
|
||||
return this.sendRequest<T>(request);
|
||||
}
|
||||
|
||||
@ -95,11 +96,11 @@ export default abstract class BaseApiService {
|
||||
|
||||
private async sendRequest<T>(request: () => Promise<Response>): Promise<T> {
|
||||
const response = await request();
|
||||
response.headers.set("Access-Control-Allow-Origin", "*");
|
||||
return this.processResponse<T>(response, request);
|
||||
}
|
||||
|
||||
protected async processResponse<T>(response: Response, request: () => Promise<Response>): Promise<T> {
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
let responseJson: any | null;
|
||||
try {
|
||||
responseJson = await response.json();
|
||||
|
@ -29,6 +29,19 @@ export default class Users extends BaseNotary {
|
||||
}
|
||||
}
|
||||
|
||||
public async getAuthorizationCode(): Promise<any> {
|
||||
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 getOne(uid: string): Promise<User> {
|
||||
const url = new URL(this.baseURl.concat("/").concat(uid));
|
||||
try {
|
||||
|
2
src/front/Components/Layouts/Login/classes.module.scss
Normal file
2
src/front/Components/Layouts/Login/classes.module.scss
Normal file
@ -0,0 +1,2 @@
|
||||
.root {
|
||||
}
|
19
src/front/Components/Layouts/Login/index.tsx
Normal file
19
src/front/Components/Layouts/Login/index.tsx
Normal file
@ -0,0 +1,19 @@
|
||||
import Users from "@Front/Api/LeCoffreApi/Notary/Users/Users";
|
||||
import Button 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";
|
||||
|
||||
export default class Login extends BasePage {
|
||||
public override render(): JSX.Element {
|
||||
return (
|
||||
<DefaultTemplate title={"HomePage"}>
|
||||
<div className={classes["root"]}>
|
||||
<Typography typo={ITypo.H1}>login</Typography>
|
||||
<Button onClick={async() => Users.getInstance().getAuthorizationCode()}>IDNOT</Button>
|
||||
</div>
|
||||
</DefaultTemplate>
|
||||
);
|
||||
}
|
||||
}
|
@ -12,10 +12,6 @@ export class FrontendVariables {
|
||||
|
||||
public readonly NEXT_PUBLIC_API_URL!: string;
|
||||
|
||||
public readonly NEXT_PUBLIC_RPC_GATEWAY_MAINNET_URL!: string;
|
||||
|
||||
public readonly NEXT_PUBLIC_RPC_GATEWAY_TESTNET_URL!: string;
|
||||
|
||||
public readonly NODE_ENV!: string;
|
||||
|
||||
constructor() {
|
||||
@ -24,8 +20,6 @@ export class FrontendVariables {
|
||||
this.WEB_PORT = process.env["WEB_PORT"]!;
|
||||
this.WEB_ROOT_URL = process.env["WEB_ROOT_URL"]!;
|
||||
this.NEXT_PUBLIC_API_URL = process.env["NEXT_PUBLIC_API_URL"]!;
|
||||
this.NEXT_PUBLIC_RPC_GATEWAY_MAINNET_URL = process.env["NEXT_PUBLIC_RPC_GATEWAY_MAINNET_URL"]!;
|
||||
this.NEXT_PUBLIC_RPC_GATEWAY_TESTNET_URL = process.env["NEXT_PUBLIC_RPC_GATEWAY_TESTNET_URL"]!;
|
||||
}
|
||||
|
||||
public static getInstance(): FrontendVariables {
|
||||
|
@ -3,7 +3,6 @@ import EventEmitter from "@Front/Services/EventEmitter";
|
||||
export default abstract class BaseStore {
|
||||
protected readonly event = new EventEmitter();
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
||||
protected constructor() {}
|
||||
|
||||
public onChange<T>(callback: (params: T) => void) {
|
||||
|
5
src/pages/login.tsx
Normal file
5
src/pages/login.tsx
Normal file
@ -0,0 +1,5 @@
|
||||
import Login from "@Front/Components/Layouts/Login";
|
||||
|
||||
export default function Route() {
|
||||
return <Login />;
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user