Skip to content

Commit

Permalink
DefaultGenericErrorPage from plain js to typescript
Browse files Browse the repository at this point in the history
  • Loading branch information
mrFlick72 committed Sep 2, 2023
1 parent b152103 commit b02522f
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 16 deletions.
8 changes: 0 additions & 8 deletions src/main/frontend/app/errors/DefaultErrorPage.js

This file was deleted.

28 changes: 28 additions & 0 deletions src/main/frontend/app/errors/DefaultGenericErrorPage.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import React from "react";

import {ThemeProvider, Typography} from "@mui/material";
import theme from "../component/styles";
import Template from "../component/Template";
import {SentimentVeryDissatisfied} from "@mui/icons-material";

interface DefaultGenericErrorPageProps {
messages: string
}
interface ErrorMessage {
defaultMessage: string
}

const DefaultGenericErrorPage: React.FC<DefaultGenericErrorPageProps> = ({messages}) => {
let errors : ErrorMessage = JSON.parse(messages)
return <ThemeProvider theme={theme}>
<Template maxWidth="sm">
<Typography variant="h3" component="h3">
<SentimentVeryDissatisfied fontSize="large"/> {errors.defaultMessage}
</Typography>

</Template>
</ThemeProvider>

}

export default DefaultGenericErrorPage
10 changes: 4 additions & 6 deletions src/main/frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,7 @@
"name": "vautehenticator-asset",
"version": "0.7",
"description": "VAuthenticator UI Asset library",
"babel": {
"presets": [
"@babel/react",
"@babel/env"
]
},

"scripts": {
"build": "webpack --config webpack.config.js --mode=development",
"production-build": "webpack --config webpack.config.js --mode=production",
Expand All @@ -28,6 +23,9 @@
"webpack-cli": "5.1.4"
},
"dependencies": {
"@types/node": "^20.5.8",
"@types/react": "^18.2.21",
"@types/react-dom": "^18.2.7",
"typescript": "^5.2.2",
"@date-io/moment": "^2.17.0",
"@emotion/react": "^11.11.1",
Expand Down
4 changes: 2 additions & 2 deletions src/main/frontend/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const BUID_DIR = path.resolve(__dirname + "/dist");

module.exports = {
entry: {
"default_error": path.resolve(__dirname, './app/errors/DefaultErrorPage.js'),
"default_error": path.resolve(__dirname, './app/errors/DefaultGenericErrorPage.tsx'),
"404_error": path.resolve(__dirname, './app/errors/400ErrorPage.js'),
"400_error": path.resolve(__dirname, './app/errors/404ErrorPage.js'),
"500_error": path.resolve(__dirname, './app/errors/500ErrorPage.js'),
Expand Down Expand Up @@ -34,7 +34,7 @@ module.exports = {
exclude: /node_modules$/,
},
{
test: path.join(__dirname, "."),
test: /\.js$/,
exclude: path.resolve(__dirname, "node_modules"),
use: {
loader: "babel-loader",
Expand Down

0 comments on commit b02522f

Please sign in to comment.