Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Typescript loader addition #1221

Merged
merged 1 commit into from
Mar 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
ts loader addition
  • Loading branch information
gaurav884 committed Mar 24, 2023
commit a85bff3bf9efc878d613c87f531dc2ee3db9c5c6
21,856 changes: 21,856 additions & 0 deletions owtf/webapp/package-lock.json

Large diffs are not rendered by default.

16 changes: 11 additions & 5 deletions owtf/webapp/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@
"@ckeditor/ckeditor5-react": "^1.1.3",
"@types/history": "^5.0.0",
"@types/jest": "^28.1.3",
"@types/node": "^18.0.0",
"@types/react": "^18.0.14",
"@types/react-dom": "^18.0.5",
"@types/node": "^18.15.7",
"@types/react": "17.0.14",
"@types/react-dom": "17.0.14",
"@types/webpack-env": "^1.17.0",
"babel-plugin-transform-require-context": "^0.1.1",
"chalk": "^2.3.2",
Expand Down Expand Up @@ -87,8 +87,9 @@
"@babel/polyfill": "^7.0.0",
"@babel/preset-env": "^7.0.0",
"@babel/preset-react": "^7.0.0",
"@types/react-redux": "^7.1.24",
"@babel/preset-typescript": "^7.21.0",
"@types/react": "^18.0.28",
"@types/react-redux": "^7.1.24",
"babel-core": "^7.0.0-bridge.0",
"babel-jest": "^23.4.2",
"babel-loader": "^8.0.0",
Expand Down Expand Up @@ -124,8 +125,9 @@
"sass": "^1.59.3",
"sass-loader": "^7.0.3",
"style-loader": "^0.20.3",
"ts-loader": "^3.5.0",
"url-loader": "^1.0.1",
"webpack": "3.11.0",
"webpack": "^3.12.0",
"webpack-dev-middleware": "1.11.0",
"webpack-hot-middleware": "2.18.0",
"webpack-merge": "^4.1.2"
Expand All @@ -140,5 +142,9 @@
"ts",
"tsx"
]
},
"resolutions": {
"@types/react": "17.0.14",
"@types/react-dom": "17.0.14"
}
}
33 changes: 33 additions & 0 deletions owtf/webapp/src/components/DialogBox/dialog.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import React, { Component } from "react";
import ReactDOM from "react-dom";

import { IoCloseSharp } from "react-icons/io5";

const modalContainer = document.querySelector("#modalContainer");

export default class Dialog extends Component {
render() {
return ReactDOM.createPortal(
<div>
{this.props.isDialogOpened ? (
<div className="dialogContainer">
<div className="dialogContainer__dialog">
<div className="dialogContainer__content">
<div className="dialogContainer__header">
<h2 className="dialogContainer__title">{this.props.title}</h2>
<button onClick={this.props.onClose}>
<IoCloseSharp />
</button>
</div>
<div className="dialogContainer__body">
{this.props.children}
</div>
</div>
</div>
</div>
) : null}
</div>,
modalContainer
);
}
}
46 changes: 20 additions & 26 deletions owtf/webapp/src/containers/App/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@

import React, { useEffect } from "react";
import { Switch, Route, Router, Redirect } from "react-router-dom";
import NavigationBar, { INavigationBarProps, INavItem } from "../../components/NavigationBar";
import NavigationBar, {
INavigationBarProps,
INavItem
} from "../../components/NavigationBar";
import WelcomePage from "../WelcomePage/Loadable";
import Dashboard from "../Dashboard/Loadable";
import TargetsPage from "../TargetsPage/Loadable";
Expand All @@ -18,7 +21,7 @@ import LoginPage from "../LoginPage/Loadable";
import SignupPage from "../SignupPage/Loadable";
import ForgotPasswordPage from "../ForgotPasswordPage/Loadable";
import OtpPage from "../OtpPage/Loadable";
import WorkersPage from "../WorkersPage/Loadable";
import WorkersPage from "../WorklistPage/WorkersPage/Loadable";
import WorklistPage from "../WorklistPage/Loadable";
import NotFoundPage from "../../components/NotFoundPage";
import TransactionsPage from "../Transactions/Loadable";
Expand All @@ -39,20 +42,19 @@ import {
} from "../LoginPage/selectors";
import "../../styles/main.css";

interface IAppProps{
interface IAppProps {
tryAutoLogin: Function;
isAuthenticated: boolean;
username: string;
}

interface IPrivateRoute{
interface IPrivateRoute {
path: string;
component: Function;
authenticated: boolean;
}

export function App ({tryAutoLogin, isAuthenticated, username}: IAppProps){

export function App({ tryAutoLogin, isAuthenticated, username }: IAppProps) {
useEffect(() => {
tryAutoLogin();
}, []);
Expand All @@ -62,7 +64,7 @@ export function App ({tryAutoLogin, isAuthenticated, username}: IAppProps){
text: "",
links: [],
dropdown: false
}
};

const navbar: INavigationBarProps = {
brand: navitem,
Expand All @@ -84,7 +86,7 @@ export function App ({tryAutoLogin, isAuthenticated, username}: IAppProps){
dropdown: true,
text: username,
links: [{ linkTo: "/logout", text: "Logout" }]
}
};
navbar.links.push(link);
} else {
navbar.links.push({
Expand Down Expand Up @@ -138,9 +140,7 @@ export function App ({tryAutoLogin, isAuthenticated, username}: IAppProps){
path="/login"
component={isAuthenticated ? NotFoundPage : LoginPage}
/>
<Route
path="/logout"
component={LogoutPage} />
<Route path="/logout" component={LogoutPage} />
<Route
path="/signup"
component={isAuthenticated ? NotFoundPage : SignupPage}
Expand All @@ -151,35 +151,29 @@ export function App ({tryAutoLogin, isAuthenticated, username}: IAppProps){
/>
<Route
path="/forgot-password/email"
component={
isAuthenticated ? NotFoundPage : ForgotPasswordPage
}
component={isAuthenticated ? NotFoundPage : ForgotPasswordPage}
/>
<Route
path="/email-send/"
component={
isAuthenticated ? NotFoundPage : EmailSendPage
}
/>
<Route
path="/email-verify/:link"
component={EmailVerificationPage}
component={isAuthenticated ? NotFoundPage : EmailSendPage}
/>
<Route path="/email-verify/:link" component={EmailVerificationPage} />
<Route
path="/new-password/"
component={
isAuthenticated ? NotFoundPage : NewPasswordPage
}
component={isAuthenticated ? NotFoundPage : NewPasswordPage}
/>
<Route path="*" component={NotFoundPage} />
</Switch>
</div>
</Router>
);

}

function PrivateRoute({ component: Component, authenticated, ...rest }: IPrivateRoute) {
function PrivateRoute({
component: Component,
authenticated,
...rest
}: IPrivateRoute) {
if (!authenticated) {
toaster.danger("Login Required!");
}
Expand Down
10 changes: 10 additions & 0 deletions owtf/webapp/src/containers/EmailVerification/constants.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
export const EMAIL_SEND_START: string =
"owtf/EmailVerification/EMAIL_SEND_START",
EMAIL_SEND_SUCCESS: string = "owtf/EmailVerification/EMAIL_SEND_SUCCESS",
EMAIL_SEND_FAIL: string = "owtf/EmailVerification/EMAIL_SEND_FAIL",
EMAIL_VERIFICATION_START: string =
"owtf/EmailVerification/EMAIL_VERIFICATION_START",
EMAIL_VERIFICATION_SUCCESS: string =
"owtf/EmailVerification/EMAIL_VERIFICATION_SUCCESS",
EMAIL_VERIFICATION_FAIL: string =
"owtf/EmailVerification/EMAIL_VERIFICATION_FAIL";
7 changes: 0 additions & 7 deletions owtf/webapp/src/containers/EmailVerification/constants.tsx

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@ export function forgotPasswordEmailFail(error: any): object {
};
}

export function forgotPasswordEmailSuccess(msg: string, emailOrUsername: string): object {
export function forgotPasswordEmailSuccess(
msg: string,
emailOrUsername: string
): object {
return {
type: FORGOT_PASSWORD_EMAIL_SUCCESS,
msg: msg,
Expand Down
11 changes: 11 additions & 0 deletions owtf/webapp/src/containers/LoginPage/Loadable.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/**
* Asynchronously loads the component for LoginPage.
*/
import Loadable from "react-loadable";

import PageLoadingIndicator from "../../components/PageLoadingIndicator";

export default Loadable({
loader: () => import("./index.js"),
loading: PageLoadingIndicator
});
11 changes: 0 additions & 11 deletions owtf/webapp/src/containers/LoginPage/Loadable.tsx

This file was deleted.

Loading