Skip to content

Commit

Permalink
Moved DashboardView.jsx to Functional Component processing#2358
Browse files Browse the repository at this point in the history
  • Loading branch information
up1512001 authored Sep 15, 2023
1 parent fd4ed50 commit 848f79f
Showing 1 changed file with 10 additions and 20 deletions.
30 changes: 10 additions & 20 deletions client/modules/User/pages/DashboardView.jsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import PropTypes from 'prop-types';
import React, { useState, useEffect } from 'react';
import React, { useState } from 'react';
import { connect } from 'react-redux';
import MediaQuery from 'react-responsive';
import { withTranslation } from 'react-i18next';
import PropTypes from 'prop-types';

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

useEffect(() => {
// You can add any componentDidMount logic here if needed.
}, []);

const closeAccountPage = () => {
browserHistory.push(props.previousPath);
};

const createNewSketch = () => {
props.newProject();
};

const gotoHomePage = () => {
browserHistory.push('/');
};

const selectedTabKey = () => {
const path = props.location.pathname;

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

const isOwner = () => {
return props.user.username === props.params.username;
};
const isOwner = () => props.user.username === props.params.username;

const toggleCollectionCreate = () => {
setCollectionCreateVisible((prevState) => !prevState);
Expand Down Expand Up @@ -111,7 +96,9 @@ function DashboardView(props) {
);
case TabKey.sketches:
default:
return <SketchList key={username} mobile={mobile} username={username} />;
return (
<SketchList key={username} mobile={mobile} username={username} />
);
}
};

Expand Down Expand Up @@ -168,6 +155,10 @@ const mapDispatchToProps = {
...ProjectActions
};

DashboardView.defaultProps = {
user: null // Provide an appropriate default value
};

DashboardView.propTypes = {
newProject: PropTypes.func.isRequired,
location: PropTypes.shape({
Expand All @@ -176,7 +167,6 @@ DashboardView.propTypes = {
params: PropTypes.shape({
username: PropTypes.string.isRequired
}).isRequired,
previousPath: PropTypes.string.isRequired,
user: PropTypes.shape({
username: PropTypes.string
}),
Expand Down

0 comments on commit 848f79f

Please sign in to comment.