Skip to content

Commit

Permalink
add defensive checks for the preview drawer
Browse files Browse the repository at this point in the history
  • Loading branch information
arunshenoy99 committed Oct 3, 2022
1 parent 6d61dd9 commit de2e88b
Showing 1 changed file with 15 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@ import { store as nfdOnboardingStore } from '../../../store';
import { getPatterns } from '../../../utils/api/patterns';
import { getGlobalStyles } from '../../../utils/api/themes';
import { useGlobalStylesOutput } from '../../../utils/global-styles/use-global-styles-output';
import { THEME_STATUS_ACTIVE } from '../../../../constants';
import {
THEME_STATUS_ACTIVE,
THEME_STATUS_NOT_ACTIVE,
} from '../../../../constants';

const DesignThemeStylesPreview = () => {
const MAX_PREVIEWS_PER_ROW = 3;
Expand All @@ -27,15 +30,24 @@ const DesignThemeStylesPreview = () => {
};
}, [] );

const { updatePreviewSettings, setCurrentOnboardingData } =
useDispatch( nfdOnboardingStore );
const {
updatePreviewSettings,
setCurrentOnboardingData,
updateThemeStatus,
} = useDispatch( nfdOnboardingStore );

const getStylesAndPatterns = async () => {
const patternResponse = await getPatterns(
currentStep.patternId,
true
);
if ( patternResponse?.error ) {
return updateThemeStatus( THEME_STATUS_NOT_ACTIVE );
}
const globalStylesResponse = await getGlobalStyles();
if ( globalStylesResponse?.error ) {
return updateThemeStatus( THEME_STATUS_NOT_ACTIVE );
}
setPattern( patternResponse?.body );
setGlobalStyles( globalStylesResponse?.body );
let selectedGlobalStyle;
Expand Down

0 comments on commit de2e88b

Please sign in to comment.