import { IntelligemsReactProvider, useIgTrack } from "@intelligems/headless/next-clientside"
const InnerHoc = ({ children }) => {
const { checkout } = React.useContext(StoreContext)
useIgTrack({
cartOrCheckoutToken: checkout?.id,
currency: checkout.totalTaxV2?.currencyCode,
country: "US"
})
return children
}
export const wrapRootElement = ({ element }) => {
return <IntelligemsNextClientsideProvider
organizationId={process.env.NEXT_PUBLIC_INTELLIGEMS_ORG_ID}
storefrontApiToken={process.env.NEXT_PUBLIC_STOREFRONT_ACCESS_TOKEN}
antiFlicker={true}
>
<StoreProvider>
<InnerHoc>
{element}
</InnerHoc>
</StoreProvider>
</IntelligemsNextClientsideProvider>
}