Skip to content

Commit

Permalink
add formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
IvanKiral committed Jun 18, 2024
1 parent 05fe37c commit ff195d2
Show file tree
Hide file tree
Showing 35 changed files with 499 additions and 284 deletions.
6 changes: 6 additions & 0 deletions dprint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"extends": "https://raw.githubusercontent.com/kontent-ai/dprint-config/main/dprint.json",
"includes": [
"src/**/*.{ts,tsx,js,jsx,json}"
]
}
175 changes: 175 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 5 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@
"test": "react-scripts test",
"eject": "react-scripts eject",
"predeploy": "npm run build",
"deploy": "gh-pages -d build"
"deploy": "gh-pages -d build",
"fmt": "dprint fmt",
"fmt:check": "dprint check"
},
"eslintConfig": {
"extends": "react-app"
Expand All @@ -44,6 +46,7 @@
]
},
"devDependencies": {
"dprint": "^0.46.2",
"gh-pages": "^2.0.1"
}
}
}
24 changes: 11 additions & 13 deletions src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
import React from 'react';
import './App.css';
import { Route, Switch } from 'react-router-dom';
import { NavigationBar } from './components/NavigationBar';
import { ProductDetailsPage } from './components/Product/ProductDetailsPage';
import { ProductsPage } from './components/Product/ProductsPage';
import { ProductDetailsRoute, ProductsRoute, EnvironmentRoute } from './constants/routePaths';
import { WelcomePage } from './components/WelcomePage';
import { ProgressBar } from './components/ProgressBar';
import React from "react";
import "./App.css";
import { Route, Switch } from "react-router-dom";
import { NavigationBar } from "./components/NavigationBar";
import { ProductDetailsPage } from "./components/Product/ProductDetailsPage";
import { ProductsPage } from "./components/Product/ProductsPage";
import { ProductDetailsRoute, ProductsRoute, EnvironmentRoute } from "./constants/routePaths";
import { WelcomePage } from "./components/WelcomePage";
import { ProgressBar } from "./components/ProgressBar";

export class App extends React.PureComponent {
render() {
return (
<div className="app">
<ProgressBar/>
<ProgressBar />
<Route
path={EnvironmentRoute}
component={NavigationBar}
Expand All @@ -33,9 +33,7 @@ export class App extends React.PureComponent {
component={ProductsPage}
/>
<Route
render={() => (
<p>Ooops, missing page!</p>
)}
render={() => <p>Ooops, missing page!</p>}
/>
</Switch>
</div>
Expand Down
22 changes: 12 additions & 10 deletions src/authentication/WebAuth.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
import auth0 from 'auth0-js';
import {
authOptions,
logoutOptions,
} from './authOptions';
import auth0 from "auth0-js";
import { authOptions, logoutOptions } from "./authOptions";
import { Auth0RedirectUriStorageKey } from "../constants/localStorageKeys";
import { RootRoute, DeployedProjectRootRoute } from "../constants/routePaths";

Expand All @@ -15,7 +12,10 @@ export interface IWebAuth {
readonly login: () => void;
readonly logout: () => void;
readonly silentLogin: () => void;
readonly handleAuthentication: (onSuccessLogin: (accessToken: IAccessToken, redirectUri: string) => void, onFailedLogin: () => void) => void;
readonly handleAuthentication: (
onSuccessLogin: (accessToken: IAccessToken, redirectUri: string) => void,
onFailedLogin: () => void,
) => void;
readonly isAuthenticated: (expiresIn: number) => boolean;
}

Expand All @@ -29,7 +29,7 @@ export class WebAuth implements IWebAuth {
silentLogin = (): void => {
localStorage.setItem(Auth0RedirectUriStorageKey, window.location.pathname);
this.webAuth.authorize({
prompt: 'none',
prompt: "none",
});
};

Expand All @@ -50,7 +50,10 @@ export class WebAuth implements IWebAuth {
return redirectUri;
};

handleAuthentication = (onSuccessLogin: (accessToken: IAccessToken, redirectUri: string) => void, onFailedLogin: () => void): void => {
handleAuthentication = (
onSuccessLogin: (accessToken: IAccessToken, redirectUri: string) => void,
onFailedLogin: () => void,
): void => {
this.webAuth.parseHash((err, authResult) => {
if (authResult && authResult.accessToken && authResult.idToken) {
const accessToken: IAccessToken = {
Expand All @@ -59,8 +62,7 @@ export class WebAuth implements IWebAuth {
};
const redirectUri = this.getRedirectUri();
onSuccessLogin(accessToken, redirectUri);
}
else if (err) {
} else if (err) {
onFailedLogin();
this.login();
}
Expand Down
11 changes: 4 additions & 7 deletions src/authentication/authOptions.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
import {
AuthOptions,
LogoutOptions,
} from 'auth0-js';
import { AuthOptions, LogoutOptions } from "auth0-js";

export const authOptions: AuthOptions = {
audience: 'https://app.kenticocloud.com/',
audience: "https://app.kenticocloud.com/",
clientID: process.env.REACT_APP_AUTH_CLIENT_ID!,
domain: process.env.REACT_APP_AUTH_DOMAIN!,
redirectUri: process.env.REACT_APP_AUTH_REDIRECT_URL,
responseType: 'token id_token',
scope: 'openid',
responseType: "token id_token",
scope: "openid",
};

export const logoutOptions: LogoutOptions = {
Expand Down
Loading

0 comments on commit ff195d2

Please sign in to comment.