// #region [Imports] =================================================================================================== // Libraries import React from 'react'; import { bindActionCreators, Dispatch } from 'redux'; import { connect } from 'react-redux'; import { Link, useHistory } from 'react-router-dom'; import { Skeleton, Menu } from 'antd'; // Actions import { PageActions } from '../../store/actions/page'; // Types import { IStore } from '../../types/store'; import { ISection } from '../../types/section'; // SCSS import './index.scss'; // Components import MenuIcon from './icons'; // Helpers import { getPathPrefix } from '../../helpers/utils'; // #endregion [Imports] // #region [Variables] ================================================================================================= declare var acfwAdminApp: any; const { setStorePage } = PageActions; const pathPrefix = getPathPrefix(); // #endregion [Variables] // #region [Interfaces] ================================================================================================ interface IActions { setStorePage: typeof setStorePage; } interface IProps { sections: ISection[]; currentSection: string | null; actions: IActions; } // #endregion [Interfaces] // #region [Component] ================================================================================================= const SettingsNav = (props: IProps) => { const { sections, currentSection, actions } = props; const { app_pages } = acfwAdminApp; const defaultKey: string = currentSection ? currentSection : 'general_section'; const history = useHistory(); if (sections.length < 1) { return (
); } const handleMenuClick = (id: string) => { history.push(`${pathPrefix}admin.php?page=${id}`); actions.setStorePage({ data: id }); }; const filteredSections = sections.filter(({ show }) => show); const HideAppPages = ['acfw-settings', 'acfw-about', 'acfw-store-credits']; return ( {filteredSections.map(({ id, title }) => ( {title} ))} {app_pages .filter(({ slug }: any) => !HideAppPages.includes(slug)) .map(({ slug, label, page }: any) => ( ))} ); }; const mapStateToProps = (store: IStore) => ({ sections: store.sections }); const mapDispatchToProps = (dispatch: Dispatch) => ({ actions: bindActionCreators({ setStorePage }, dispatch), }); export default connect(mapStateToProps, mapDispatchToProps)(SettingsNav); // #endregion [Component]