Skip to content

Commit 2101992

Browse files
committed
chores:
- connect sentry dsn - create error fallback component - add new translation - add margin on login form
1 parent e15bb22 commit 2101992

File tree

12 files changed

+468
-39
lines changed

12 files changed

+468
-39
lines changed

.env.example

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
REACT_APP_BACKEND_URL_DEV='dev.demosite.com/api'
2-
REACT_APP_BACKEND_URL_PROD='www.demosite.com/api'
2+
REACT_APP_BACKEND_URL_PROD='www.demosite.com/api'
3+
REACT_APP_BACKEND_SENTRY_DSN='sentry-dsn-url'

package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
"@ant-design/icons": "^4.4.0",
77
"@craco/craco": "^6.1.0",
88
"@reduxjs/toolkit": "^1.5.0",
9+
"@sentry/react": "^6.2.4",
10+
"@sentry/tracing": "^6.2.4",
911
"@testing-library/jest-dom": "^5.11.9",
1012
"@testing-library/react": "^11.2.3",
1113
"@testing-library/user-event": "^12.6.2",
@@ -67,6 +69,7 @@
6769
"eslint-plugin-react-hooks": "4.2.0",
6870
"husky": "^4.3.8",
6971
"prettier": "^2.2.1",
72+
"serve": "^11.3.2",
7073
"source-map-explorer": "^2.5.2"
7174
},
7275
"husky": {
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import React from 'react';
2+
import { ThemeProvider } from 'styled-components';
3+
import { ConfigProvider } from 'antd';
4+
import { IntlProvider } from 'react-intl';
5+
import PropTypes from 'prop-types';
6+
import { theme, AppLocale } from 'config';
7+
import { useSelector } from 'react-redux';
8+
import { ErrorBoundary } from '@sentry/react';
9+
import { ErrorFallback } from 'components';
10+
11+
export default function AppProvider({ children }) {
12+
const { locale } = useSelector(state => state.LanguageSwitcher.language);
13+
14+
const currentAppLocale = AppLocale[locale];
15+
16+
return (
17+
<ErrorBoundary
18+
fallback={({ error, componentStack, resetError }) => (
19+
<ErrorFallback error={{ error, componentStack, resetError }} />
20+
)}
21+
showDialog
22+
>
23+
<ConfigProvider locale={currentAppLocale.antd}>
24+
<IntlProvider
25+
locale={currentAppLocale.locale}
26+
messages={currentAppLocale.messages}
27+
>
28+
<ThemeProvider theme={theme}>{children}</ThemeProvider>
29+
</IntlProvider>
30+
</ConfigProvider>
31+
</ErrorBoundary>
32+
);
33+
}
34+
35+
AppProvider.propTypes = {
36+
children: PropTypes.node.isRequired,
37+
};
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import { Result } from 'antd';
2+
import React from 'react';
3+
import PropTypes from 'prop-types';
4+
5+
function ErrorFallback({ error }) {
6+
return (
7+
<Result
8+
status="500"
9+
title="500"
10+
subTitle={
11+
<>
12+
<div>Sorry, something went wrong!</div>
13+
<div>{error?.error.toString()}</div>
14+
<div>{error?.componentStack}</div>
15+
</>
16+
}
17+
/>
18+
);
19+
}
20+
21+
ErrorFallback.propTypes = {
22+
error: PropTypes.object,
23+
};
24+
25+
export default ErrorFallback;

src/components/index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
export { default as AppProvider } from './wrapper/AppProvider';
1+
export { default as AppProvider } from './AppProvider';
2+
export { default as ErrorFallback } from './ErrorFallback';

src/components/wrapper/AppProvider.js

Lines changed: 0 additions & 28 deletions
This file was deleted.

src/config/app/default.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
export default {
22
siteName: 'Dashboard Boilerplate',
33
defaultLanguage: 'english',
4+
sentryDSN: process.env.REACT_APP_BACKEND_SENTRY_DSN,
45
};

src/config/translation/locales/bn_BD.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,6 @@
1818
"Dashboard": "ড্যাশবোর্ড",
1919
"Settings": "সেটিংস",
2020
"Logout": "প্রস্থান",
21-
"Successfully logged in!": "সফলভাবে লগ ইন হয়েছে!"
21+
"Successfully logged in!": "সফলভাবে লগ ইন হয়েছে!",
22+
"Sorry, something went wrong!": "দুঃখিত, কিছু ভুল হয়েছে!"
2223
}

src/config/translation/locales/en_US.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,6 @@
1818
"Dashboard": "Dashboard",
1919
"Settings": "Settings",
2020
"Logout": "Logout",
21-
"Successfully logged in!": "Successfully logged in!"
21+
"Successfully logged in!": "Successfully logged in!",
22+
"Sorry, something went wrong!": "Sorry, something went wrong!"
2223
}

src/features/UserAuth/UserAuthForm.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ function UserAuthForm() {
3030
validateMessages={getValidateMessages(messages, 'name')}
3131
>
3232
<Form.Item
33-
className="mb-1"
33+
className="mb-3"
3434
name="email"
3535
rules={[{ required: true }, { type: 'email' }]}
3636
hasFeedback

0 commit comments

Comments
 (0)