Skip to content
This repository has been archived by the owner on Apr 25, 2024. It is now read-only.

Commit

Permalink
Header better data fetch cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
andreiggr committed Nov 29, 2021
1 parent 40ae6ab commit 6baf20d
Showing 1 changed file with 3 additions and 52 deletions.
55 changes: 3 additions & 52 deletions src/customizations/volto/components/theme/Header/Header.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,46 +29,6 @@ const Header = (props) => {
const [leadCaptionText, setLeadCaptionText] = React.useState('');
const [navigationItems, setNavigationItems] = React.useState('');

// console.log('parentImg', props.parentImg);
// const getParentData = (url) => {
// axios
// .get(url, {
// headers: {
// accept: 'application/json',
// },
// })
// .then((response) => {
// const parentImage =
// response.data && response.data.image && response.data.image.download
// ? response.data.image.download
// : '';

// const parentLeadCaption =
// response.data &&
// response.data.lead_image_caption &&
// response.data.lead_image_caption.data
// ? response.data.lead_image_caption.data
// : '';

// const parentData =
// response.data && props.navItems && response.data['@id']
// ? getNavigationByParent(
// props.navItems,
// getBasePath(response.data['@id']),
// )
// : '';
// if (inheritLeadingData) {
// //setInheritedImage(props.parentImg);
// //setLeadCaptionText(parentLeadCaption);
// }
// // if (leadNavigation) {
// // setNavigationItems(parentData.items);
// // }
// })
// .catch((error) => {
// return error;
// });
// };
React.useEffect(() => {
if (leadNavigation || inheritLeadingData) {
if (!props.parentItems || props.parentItems.length === 0) {
Expand All @@ -86,6 +46,9 @@ const Header = (props) => {
setInheritedImage(props.parentImg.download);
if (props.leadCaption) setLeadCaptionText(props.leadCaption);
}
if (!inheritLeadingData) {
setLeadCaptionText(leadImageCaption.data);
}
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [
Expand All @@ -103,18 +66,6 @@ const Header = (props) => {
}
}, [props.actualPathName, props.frontPageSlides]);

React.useEffect(() => {
if (inheritLeadingData || leadNavigation) {
//const parentUrl = parentData['@id'];
// getParentData(parentUrl);

if (!inheritLeadingData) {
setLeadCaptionText(leadImageCaption.data);
}
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [props.extraData, props.navItems]);

const defaultHeaderImage = props.defaultHeaderImage;
let headerImageUrl = defaultHeaderImage?.image || defaultHeaderImage;
const pathName = props.pathname;
Expand Down

0 comments on commit 6baf20d

Please sign in to comment.