Skip to content

Commit 848f79f

Browse files
authored
Moved DashboardView.jsx to Functional Component processing#2358
1 parent fd4ed50 commit 848f79f

File tree

1 file changed

+10
-20
lines changed

1 file changed

+10
-20
lines changed

client/modules/User/pages/DashboardView.jsx

+10-20
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
1-
import PropTypes from 'prop-types';
2-
import React, { useState, useEffect } from 'react';
1+
import React, { useState } from 'react';
32
import { connect } from 'react-redux';
43
import MediaQuery from 'react-responsive';
54
import { withTranslation } from 'react-i18next';
5+
import PropTypes from 'prop-types';
66

7-
import browserHistory from '../../../browserHistory';
87
import Button from '../../../common/Button';
98
import Nav from '../../IDE/components/Header/Nav';
109
import Overlay from '../../App/components/Overlay';
@@ -27,22 +26,10 @@ import DashboardTabSwitcherPublic, {
2726
function DashboardView(props) {
2827
const [collectionCreateVisible, setCollectionCreateVisible] = useState(false);
2928

30-
useEffect(() => {
31-
// You can add any componentDidMount logic here if needed.
32-
}, []);
33-
34-
const closeAccountPage = () => {
35-
browserHistory.push(props.previousPath);
36-
};
37-
3829
const createNewSketch = () => {
3930
props.newProject();
4031
};
4132

42-
const gotoHomePage = () => {
43-
browserHistory.push('/');
44-
};
45-
4633
const selectedTabKey = () => {
4734
const path = props.location.pathname;
4835

@@ -63,9 +50,7 @@ function DashboardView(props) {
6350
return props.user.username;
6451
};
6552

66-
const isOwner = () => {
67-
return props.user.username === props.params.username;
68-
};
53+
const isOwner = () => props.user.username === props.params.username;
6954

7055
const toggleCollectionCreate = () => {
7156
setCollectionCreateVisible((prevState) => !prevState);
@@ -111,7 +96,9 @@ function DashboardView(props) {
11196
);
11297
case TabKey.sketches:
11398
default:
114-
return <SketchList key={username} mobile={mobile} username={username} />;
99+
return (
100+
<SketchList key={username} mobile={mobile} username={username} />
101+
);
115102
}
116103
};
117104

@@ -168,6 +155,10 @@ const mapDispatchToProps = {
168155
...ProjectActions
169156
};
170157

158+
DashboardView.defaultProps = {
159+
user: null // Provide an appropriate default value
160+
};
161+
171162
DashboardView.propTypes = {
172163
newProject: PropTypes.func.isRequired,
173164
location: PropTypes.shape({
@@ -176,7 +167,6 @@ DashboardView.propTypes = {
176167
params: PropTypes.shape({
177168
username: PropTypes.string.isRequired
178169
}).isRequired,
179-
previousPath: PropTypes.string.isRequired,
180170
user: PropTypes.shape({
181171
username: PropTypes.string
182172
}),

0 commit comments

Comments
 (0)