From 97b963f8422e466afcc71481d98be77a1c8170d6 Mon Sep 17 00:00:00 2001 From: arunshenoy99 Date: Tue, 27 Feb 2024 23:14:11 +0530 Subject: [PATCH] Fix Site Logo Data --- .../components/ImageUploaderWithText/index.js | 4 +++- src/OnboardingSPA/steps/SiteGen/SiteLogo/index.js | 12 ++++++------ 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/OnboardingSPA/components/ImageUploader/components/ImageUploaderWithText/index.js b/src/OnboardingSPA/components/ImageUploader/components/ImageUploaderWithText/index.js index 0123832d8..491fc2595 100644 --- a/src/OnboardingSPA/components/ImageUploader/components/ImageUploaderWithText/index.js +++ b/src/OnboardingSPA/components/ImageUploader/components/ImageUploaderWithText/index.js @@ -71,7 +71,7 @@ const ImageUploaderWithText = ( { image, imageSetter } ) => { const getContrastingColor = ( color ) => { /* if the contrast value more than 150 it should have black bg, otherwise white */ const [ r, g, b ] = color.match( /\d+/g ).map( Number ); - const contrastValue = ( 0.2126 * r ) + ( 0.7152 * g ) + ( 0.0722 * b ); + const contrastValue = 0.2126 * r + 0.7152 * g + 0.0722 * b; return contrastValue > 160 ? 'black' : 'white'; }; @@ -130,6 +130,8 @@ const ImageUploaderWithText = ( { image, imageSetter } ) => { imageSetter( { id: 0, url: '', + fileName: '', + fileSize: 0, } ); if ( inputRef?.current?.files.length > 0 ) { inputRef.current.value = ''; diff --git a/src/OnboardingSPA/steps/SiteGen/SiteLogo/index.js b/src/OnboardingSPA/steps/SiteGen/SiteLogo/index.js index 22cac2402..c090532dd 100644 --- a/src/OnboardingSPA/steps/SiteGen/SiteLogo/index.js +++ b/src/OnboardingSPA/steps/SiteGen/SiteLogo/index.js @@ -61,9 +61,9 @@ const SiteGenSiteLogo = () => { setIsHeaderNavigationEnabled( true ); setHeaderActiveView( HEADER_SITEGEN ); setDrawerActiveView( false ); - if ( currentData.data.siteLogo?.id !== 0 ) { + if ( currentData.sitegen.siteLogo?.id !== 0 ) { setIsFooterNavAllowed( true ); - return setSiteLogo( currentData.data.siteLogo ); + return setSiteLogo( currentData.sitegen.siteLogo ); } setIsFooterNavAllowed( false ); getEditedEntityRecord( 'root', 'site' ); @@ -71,10 +71,10 @@ const SiteGenSiteLogo = () => { const handleSiteLogo = ( siteLogoNew ) => { const currentDataCopy = { ...currentData }; - currentDataCopy.data.siteLogo.id = siteLogoNew.id; - currentDataCopy.data.siteLogo.url = siteLogoNew.url; - currentDataCopy.data.siteLogo.fileName = siteLogoNew.fileName; - currentDataCopy.data.siteLogo.fileSize = siteLogoNew.fileSize; + 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, {