Skip to content

Commit

Permalink
Fix Lint
Browse files Browse the repository at this point in the history
  • Loading branch information
officiallygod committed Jul 3, 2024
1 parent aee8cb0 commit 7eff4f2
Showing 1 changed file with 49 additions and 48 deletions.
97 changes: 49 additions & 48 deletions src/OnboardingSPA/steps/SiteGen/SiteLogo/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,21 +30,22 @@ import { SITEGEN_FLOW } from '../../../data/flows/constants';
import { SiteGenStateHandler } from '../../../components/StateHandlers';

const SiteGenSiteLogo = () => {
const [siteLogo, setSiteLogo] = useState();
const [ siteLogo, setSiteLogo ] = useState();

const isLargeViewport = useViewportMatch('small');
const isLargeViewport = useViewportMatch( 'small' );

const { currentData } = useSelect((select) => {
const { currentData } = useSelect( ( select ) => {
return {
currentData: select(nfdOnboardingStore).getCurrentOnboardingData(),
currentData:
select( nfdOnboardingStore ).getCurrentOnboardingData(),
};
});
} );

const { getEditedEntityRecord } = useSelect((select) => {
return select(coreStore);
}, []);
const { getEditedEntityRecord } = useSelect( ( select ) => {
return select( coreStore );
}, [] );

const { editEntityRecord } = useDispatch(coreStore);
const { editEntityRecord } = useDispatch( coreStore );

const {
setIsFooterNavAllowed,
Expand All @@ -56,22 +57,22 @@ const SiteGenSiteLogo = () => {
setCurrentOnboardingData,
setIsHeaderNavigationEnabled,
updateSiteGenErrorStatus,
} = useDispatch(nfdOnboardingStore);

useEffect(() => {
setHideFooterNav(false);
setIsHeaderEnabled(true);
setSidebarActiveView(false);
setIsHeaderNavigationEnabled(true);
setHeaderActiveView(HEADER_SITEGEN);
setDrawerActiveView(false);
if (currentData.sitegen.siteLogo?.id !== 0) {
setIsFooterNavAllowed(true);
return setSiteLogo(currentData.sitegen.siteLogo);
} = useDispatch( nfdOnboardingStore );

useEffect( () => {
setHideFooterNav( false );
setIsHeaderEnabled( true );
setSidebarActiveView( false );
setIsHeaderNavigationEnabled( true );
setHeaderActiveView( HEADER_SITEGEN );
setDrawerActiveView( false );
if ( currentData.sitegen.siteLogo?.id !== 0 ) {
setIsFooterNavAllowed( true );
return setSiteLogo( currentData.sitegen.siteLogo );
}
setIsFooterNavAllowed(false);
getEditedEntityRecord('root', 'site');
}, []);
setIsFooterNavAllowed( false );
getEditedEntityRecord( 'root', 'site' );
}, [] );

Check warning on line 75 in src/OnboardingSPA/steps/SiteGen/SiteLogo/index.js

View workflow job for this annotation

GitHub Actions / Run Lint Checks

React Hook useEffect has missing dependencies: 'currentData.sitegen.siteLogo', 'getEditedEntityRecord', 'setDrawerActiveView', 'setHeaderActiveView', 'setHideFooterNav', 'setIsFooterNavAllowed', 'setIsHeaderEnabled', 'setIsHeaderNavigationEnabled', and 'setSidebarActiveView'. Either include them or remove the dependency array

const resetSiteLogo = () => {
const currentDataCopy = { ...currentData };
Expand All @@ -81,28 +82,28 @@ const SiteGenSiteLogo = () => {
fileName: '',
fileSize: 0,
};
setCurrentOnboardingData(currentDataCopy);
setSiteLogo(undefined);
setIsFooterNavAllowed(false);
setCurrentOnboardingData( currentDataCopy );
setSiteLogo( undefined );
setIsFooterNavAllowed( false );
trackOnboardingEvent(
new OnboardingEvent(ACTION_SITEGEN_LOGO_SKIPPED, undefined, {
new OnboardingEvent( ACTION_SITEGEN_LOGO_SKIPPED, undefined, {
source: SITEGEN_FLOW,
})
} )
);
};

const handleSiteLogo = (siteLogoNew) => {
const handleSiteLogo = ( siteLogoNew ) => {
const currentDataCopy = { ...currentData };
currentDataCopy.sitegen.siteLogo.id = siteLogoNew.id;
currentDataCopy.sitegen.siteLogo.url = siteLogoNew.url;
currentDataCopy.sitegen.siteLogo.fileName = siteLogoNew.fileName;
currentDataCopy.sitegen.siteLogo.fileSize = siteLogoNew.fileSize;
setCurrentOnboardingData(currentDataCopy);
setIsFooterNavAllowed(siteLogoNew.id !== 0);
editEntityRecord('root', 'site', undefined, {
setCurrentOnboardingData( currentDataCopy );
setIsFooterNavAllowed( siteLogoNew.id !== 0 );
editEntityRecord( 'root', 'site', undefined, {
site_logo: siteLogoNew.id,
});
setSiteLogo(siteLogoNew);
} );
setSiteLogo( siteLogoNew );
};

const handleFailure = () => {
Expand All @@ -115,7 +116,7 @@ const SiteGenSiteLogo = () => {
}
)
);
updateSiteGenErrorStatus(true);
updateSiteGenErrorStatus( true );
};

const content = getContents();
Expand All @@ -127,22 +128,22 @@ const SiteGenSiteLogo = () => {
className="nfd-onboarding-step--site-gen__site-logo"
>
<div className="nfd-onboarding-step--site-gen__site-logo__container">
<AIHeading title={content.heading} />
<AIHeading title={ content.heading } />
<ImageUploaderWithText
image={siteLogo}
imageSetter={handleSiteLogo}
onFailure={handleFailure}
image={ siteLogo }
imageSetter={ handleSiteLogo }
onFailure={ handleFailure }
/>
<div className="nfd-onboarding-step--site-gen__site-logo__container__buttons">
<SkipButton
callback={() => resetSiteLogo()}
callback={ () => resetSiteLogo() }
className="nfd-onboarding-step--site-gen__site-logo__container__buttons__skip"
text={content.buttons.skip}
text={ content.buttons.skip }
/>
{isLargeViewport && (
{ isLargeViewport && (
<NextButtonSiteGen
callback={() => {
if (siteLogo) {
callback={ () => {
if ( siteLogo ) {
trackOnboardingEvent(
new OnboardingEvent(
ACTION_LOGO_ADDED,
Expand All @@ -153,15 +154,15 @@ const SiteGenSiteLogo = () => {
)
);
}
}}
text={content.buttons.next}
} }
text={ content.buttons.next }
disabled={
siteLogo === undefined || siteLogo?.id === 0
? true
: false
}
/>
)}
) }
</div>
</div>
</CommonLayout>
Expand Down

0 comments on commit 7eff4f2

Please sign in to comment.