-
+
@@ -33,6 +33,6 @@ const RegistrationSuccessPage = () => {
);
}
-export { RegistrationSuccessPage }
+export default RegistrationSuccessPage;
diff --git a/packages/webapp/src/components/submit-button/index.tsx b/packages/webapp/src/components/submit-button/index.tsx
index 9d07906f..c28e4612 100644
--- a/packages/webapp/src/components/submit-button/index.tsx
+++ b/packages/webapp/src/components/submit-button/index.tsx
@@ -9,18 +9,11 @@ const SubmitButton = (props: SubmitButton) => {
const [disabled, setDisabled] = useState(props.disabled ? true : false);
const intl = useIntl();
- useEffect(() => {
- document.title = 'WiseMapping - Login';
- });
-
let valueTxt = props.value;
if (disabled) {
valueTxt = intl.formatMessage({ id: "common.wait", defaultMessage: "Please wait ..." });
}
const [value, setValue] = useState(valueTxt);
-
- console.log(disabled);
- console.log(value);
return (
);
diff --git a/packages/webapp/src/services/Service.ts b/packages/webapp/src/services/Service.ts
index c2bafe2a..07acbbff 100644
--- a/packages/webapp/src/services/Service.ts
+++ b/packages/webapp/src/services/Service.ts
@@ -6,12 +6,12 @@ type NewUser = {
lastname: string;
password: string;
recaptcha: string | null;
- }
+}
+
-
interface Service {
registerNewUser(user: NewUser, onSuccess: () => void, onError: (msg: string) => void): void;
- resetPassword(email:string, onSuccess: () => void, onError: (msg: string) => void): void;
+ resetPassword(email: string, onSuccess: () => void, onError: (msg: string) => void): void;
}
class RestService implements Service {
@@ -24,7 +24,7 @@ class RestService implements Service {
async registerNewUser(user: NewUser, onSuccess: () => void, onError: (msg: string) => void) {
- await axios.post(this.baseUrl + '/service/user',
+ await axios.post(this.baseUrl + '/service/users',
JSON.stringify(user),
{ headers: { 'Content-Type': 'application/json' } }
).then(response => {
@@ -32,36 +32,61 @@ class RestService implements Service {
onSuccess();
}).catch(error => {
const response = error.response;
- let msg = '';
- if (response) {
- const status: number = response.status;
- const data = response.data;
-
- switch (status) {
- case 401:
- this.authFailed();
- break;
- default:
- console.log(data);
- // Is a server error ?
- if (!data.fieldErrors) {
- msg = response.statusText;
- } else if (data) {
- const fieldsError = data.fieldErrors;
- msg = Object.values(fieldsError)[0] as string;
- }
- }
-
- } else {
- // Network related problem ...
- msg = 'Unexpected error. Please, try latter';
- }
- onError(msg);
+ const errorMsg = this.parseResponseOnError(response);
+ onError(errorMsg);
});
}
- resetPassword(email:string, onSuccess: () => void, onError: (msg: string) => void): void {
-
+ async resetPassword(email: string, onSuccess: () => void, onError: (msg: string) => void) {
+ await axios.put(this.baseUrl + '/service/users/resetPassword?email=' + email,
+ null,
+ { headers: { 'Content-Type': 'application/json' } }
+ ).then(response => {
+ // All was ok, let's sent to success page ...
+ onSuccess();
+ }).catch(error => {
+ const response = error.response;
+ const errorMsg = this.parseResponseOnError(response);
+ onError(errorMsg);
+ });
+ }
+
+ private parseResponseOnError = (response: any) => {
+ let msg;
+ if (response) {
+ const status: number = response.status;
+ const data = response.data;
+ console.log(data);
+
+ switch (status) {
+ case 401:
+ this.authFailed();
+ break;
+ default:
+ if (data) {
+ let errors: string[] = [];
+ if (data.globalErrors) {
+ errors = data.globalErrors;
+ } else if (data.fieldErrors) {
+ errors = Object.values(data.fieldErrors);
+ }
+
+ if (errors.length > 0) {
+ msg = errors[0];
+ }
+
+ } else {
+ msg = response.statusText;
+ }
+ }
+ }
+
+ // Network related problem ...
+ if (!msg) {
+ msg = 'Unexpected error. Please, try latter';
+ }
+
+ return msg;
}
}
diff --git a/packages/webapp/src/theme/global-style.ts b/packages/webapp/src/theme/global-style.ts
index 6f5e2fce..7d604a44 100644
--- a/packages/webapp/src/theme/global-style.ts
+++ b/packages/webapp/src/theme/global-style.ts
@@ -124,6 +124,10 @@ padding: 20px 10px 20px 10px;
background-color: #f9a826;
}
+& label {
+ font-size:15px;
+}
+
& input:placeholder {
color: grey;
}
@@ -147,7 +151,7 @@ padding: 20px 10px 20px 10px;
}
& a {
- font-size: 17px;
+ font-size: 15px;
color: #f9a826;
}
`;
diff --git a/packages/webapp/webpack.config.js b/packages/webapp/webpack.config.js
index af190a49..62776ef7 100644
--- a/packages/webapp/webpack.config.js
+++ b/packages/webapp/webpack.config.js
@@ -1,6 +1,5 @@
const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');
-const HtmlWebpackDynamicEnvPlugin = require('html-webpack-dynamic-env-plugin');
const webpack = require('webpack');
const { CleanWebpackPlugin } = require('clean-webpack-plugin');
@@ -17,13 +16,11 @@ module.exports = {
extensions: ['.ts', '.tsx', '.js', '.jsx']
},
module: {
- rules: [
-
- {
+ rules: [{
test: /\.tsx?$/,
use: 'ts-loader',
exclude: '/node_modules/'
- }, ,
+ },
{
test: /\.(png|jpe?g|gif|svg)$/,
use: [{
@@ -31,7 +28,7 @@ module.exports = {
options: {
esModule: false,
}
- }, ],
+ }]
}
]
},