Skip to content

Commit

Permalink
childrenlinks fix
Browse files Browse the repository at this point in the history
  • Loading branch information
mihai-macaneata committed Jun 15, 2020
1 parent a4840af commit 960766b
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 54 deletions.
44 changes: 21 additions & 23 deletions src/components/manage/Blocks/ChildrenLinks/Edit.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import { compose } from 'redux';
import { connect } from 'react-redux';
import { getParentFolderData } from '~/actions';
import { Link } from 'react-router-dom';
import _ from 'lodash'

import _ from 'lodash';
import { getBasePath } from '~/helpers';

class Edit extends Component {
/**
Expand All @@ -31,20 +31,18 @@ class Edit extends Component {

constructor(props) {
super(props);
this.state = {
};
this.state = {};
}

componentDidUpdate(prevProps) {
if (prevProps.childrenLinks !== this.props.childrenLinks) {
this.onEditData()
this.onEditData();
}
}

handleLinkData = (link) => {
this.props.getParentFolderData(link.value)

}
handleLinkData = link => {
this.props.getParentFolderData(link.value);
};

onEditData() {
const childrenLinks = this.props.childrenLinks;
Expand All @@ -55,44 +53,44 @@ class Edit extends Component {
}

render() {

const childrenLinks = this.props.data.links;

console.log('props in childrenlist', this.props);
return (
<Grid columns={1}>
<Grid.Row>
{childrenLinks &&
childrenLinks.map(child =>
childrenLinks.map(child => (
<div className="child-container">
<Link target="_blank" className="child-link" to={child.url}>
<Link
target="_blank"
className="child-link"
to={getBasePath(child?.['@id'] || '')}
>
{_.capitalize(child.title)}
</Link>
</div>
)
}
))}
</Grid.Row>
<Grid.Column>
<p className="search-text">Search page</p>
<AddLinkForm onAddLink={this.handleLinkData} />
<p className="search-text">Search page</p>
<AddLinkForm onAddLink={this.handleLinkData} />
</Grid.Column>
</Grid>
);
}
}



const mapDispatchToProps = {
getParentFolderData,
}
};

export default compose(
injectIntl,
connect(
state => ({
state,
childrenLinks: state.parent_folder_data.items
childrenLinks: state.parent_folder_data.items,
}),
mapDispatchToProps,
)
)(Edit)
),
)(Edit);
64 changes: 33 additions & 31 deletions src/components/manage/Blocks/ChildrenLinks/View.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,40 +8,42 @@ import PropTypes from 'prop-types';
import { injectIntl } from 'react-intl';
import { Grid } from 'semantic-ui-react';
import { Link } from 'react-router-dom';
import _ from 'lodash'
import _ from 'lodash';
import { getBasePath } from '~/helpers';

class View extends Component {
/**
* Property types.
* @property {Object} propTypes Property types.
* @static
*/
static propTypes = {
data: PropTypes.objectOf(PropTypes.any).isRequired,
// pathname: PropTypes.string.isRequired,
};

render() {

const childrenLinks = this.props.data.links
return (
<div style={{marginBottom:"40px",marginTop:"40px"}}>
<Grid columns={1}>
{childrenLinks &&
childrenLinks.map(child =>
<div className="child-container">
<Link target="_blank" className="child-link" to={child.url}>
{_.capitalize(child.title)}

</Link>
</div>
class View extends Component {
/**
* Property types.
* @property {Object} propTypes Property types.
* @static
*/
static propTypes = {
data: PropTypes.objectOf(PropTypes.any).isRequired,
// pathname: PropTypes.string.isRequired,
};

)
}
</Grid>
</div>
);
}
render() {
const childrenLinks = this.props.data.links;
return (
<div style={{ marginBottom: '40px', marginTop: '40px' }}>
<Grid columns={1}>
{childrenLinks &&
childrenLinks.map(child => (
<div className="child-container">
<Link
target="_blank"
className="child-link"
to={getBasePath(child?.['@id'] || '')}
>
{_.capitalize(child.title)}
</Link>
</div>
))}
</Grid>
</div>
);
}
}

export default injectIntl(View);

0 comments on commit 960766b

Please sign in to comment.