Web: Fix: Error on additionalResources is null

This commit is contained in:
Alexey Safronov 2022-09-14 15:10:13 +03:00
parent 94859dfd24
commit 81b8e0ce3b
2 changed files with 14 additions and 12 deletions

View File

@ -55,15 +55,15 @@ const AdditionalResources = (props) => {
} = props;
const [feedbackAndSupportEnabled, setShowFeedback] = useState(
additionalResourcesData.feedbackAndSupportEnabled
additionalResourcesData?.feedbackAndSupportEnabled
);
const [videoGuidesEnabled, setShowVideoGuides] = useState(
additionalResourcesData.videoGuidesEnabled
additionalResourcesData?.videoGuidesEnabled
);
const [helpCenterEnabled, setShowHelpCenter] = useState(
additionalResourcesData.helpCenterEnabled
additionalResourcesData?.helpCenterEnabled
);
const [hasChange, setHasChange] = useState(false);
@ -77,9 +77,9 @@ const AdditionalResources = (props) => {
);
useEffect(() => {
setShowFeedback(additionalResourcesData.feedbackAndSupportEnabled);
setShowVideoGuides(additionalResourcesData.videoGuidesEnabled);
setShowHelpCenter(additionalResourcesData.helpCenterEnabled);
setShowFeedback(additionalResourcesData?.feedbackAndSupportEnabled);
setShowVideoGuides(additionalResourcesData?.videoGuidesEnabled);
setShowHelpCenter(additionalResourcesData?.helpCenterEnabled);
}, [additionalResourcesData]);
useEffect(() => {

View File

@ -224,27 +224,29 @@ class ProfileActionsStore {
const actionsArray = actions;
const feedbackAndSupportEnabled = this.authStore.settingsStore
.additionalResourcesData.feedbackAndSupportEnabled;
.additionalResourcesData?.feedbackAndSupportEnabled;
const videoGuidesEnabled = this.authStore.settingsStore
.additionalResourcesData.videoGuidesEnabled;
.additionalResourcesData?.videoGuidesEnabled;
const helpCenterEnabled = this.authStore.settingsStore
.additionalResourcesData.helpCenterEnabled;
.additionalResourcesData?.helpCenterEnabled;
if (!feedbackAndSupportEnabled) {
const index = actionsArray.findIndex((item) => item.key === "SupportBtn");
const index = actionsArray.findIndex(
(item) => item?.key === "SupportBtn"
);
actionsArray.splice(index, 1);
}
if (!videoGuidesEnabled) {
const index = actionsArray.findIndex((item) => item.key === "VideoBtn");
const index = actionsArray.findIndex((item) => item?.key === "VideoBtn");
actionsArray.splice(index, 1);
}
if (!helpCenterEnabled) {
const index = actionsArray.findIndex(
(item) => item.key === "HelpCenterBtn"
(item) => item?.key === "HelpCenterBtn"
);
actionsArray.splice(index, 1);