Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 0 additions & 29 deletions packages/template-retail-react-app/app/components/_app/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -126,27 +126,6 @@ const ListMenuContentWithData = withCommerceSdkReact(

const onClient = typeof window !== 'undefined'

function initEmbeddedMessaging() {
try {
if (onClient && embeddedservice_bootstrap && embeddedservice_bootstrap?.settings) {
embeddedservice_bootstrap.settings.language = 'en_US'; // For example, enter 'en' or 'en-US'
embeddedservice_bootstrap.init(
'00DSB00000MJ7YH',
'MIAW_Guided_Shopper_production_functional38',
'https://orgfarm-7455a909de.test1.my.pc-rnd.site.com/ESWMIAWGuidedShopperpr1743525851212',
{
scrt2URL: 'https://orgfarm-7455a909de.test1.my.pc-rnd.salesforce-scrt.com'
}
);


}

} catch (err) {
console.error('Error loading Embedded Messaging: ', err)
}
}

const App = (props) => {
const {children} = props
const {data: categoriesTree} = useCategory({
Expand Down Expand Up @@ -482,14 +461,6 @@ const App = (props) => {
async="async"
></script>
)}

{config.EMBEDDED_MESSAGING_ENABLED && (
<script
type='text/javascript'
src='https://orgfarm-7455a909de.test1.my.pc-rnd.site.com/ESWMIAWGuidedShopperpr1743525851212/assets/js/bootstrap.min.js'
onLoad={initEmbeddedMessaging()}
></script>
)}
</StorefrontPreview>
</Box>
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,10 @@ function useMiaw(
return isMiawInitialized
}

function isEnabled(enabled) {
return enabled === 'true'
}

/**
* ShopperAgent component that initializes and manages the embedded messaging service
* @param {Object} props - Component props
Expand All @@ -83,7 +87,7 @@ const ShopperAgent = ({
onAgentConversationClosed
}) => {
const { enabled, embeddedServiceName, embeddedServiceEndpoint, scriptSourceUrl, scrt2Url, salesforceOrgId, siteId } = JSON.parse(commerceAgent)
if (!onClient || !enabled) {
if (!onClient || !isEnabled(enabled)) {
return null
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,4 +162,14 @@ describe('ShopperAgent Component', () => {
}
)
})

test('should not load the script when the commerceAgent is disabled', () => {
const commerceAgentSettings = {...defaultProps.commerceAgent, enabled: 'false'};
const props = {...defaultProps, commerceAgent: JSON.stringify(commerceAgentSettings)};

const {container} = render(<ShopperAgent {...props} />)

// Component should not render anything when there's an error
expect(useScript).not.toHaveBeenCalled()
})
})
149 changes: 0 additions & 149 deletions packages/template-retail-react-app/app/hooks/use-miaw.js

This file was deleted.

Loading