UNPKG

@noaignite/react-centra-checkout

Version:

React components and helpers for Centra checkout api

1 lines 1.13 kB
{"version":3,"file":"ShipwalletEmbed.cjs","names":["useCentraSelection","HtmlEmbed"],"sources":["../src/ShipwalletEmbed.tsx"],"sourcesContent":["import { useEffect } from 'react'\nimport { useCentraSelection } from './Context'\nimport { HtmlEmbed } from './internal/HtmlEmbed'\n\nexport function ShipwalletEmbed() {\n const { selection } = useCentraSelection()\n\n useEffect(() => {\n if ('CentraCheckout' in window) {\n // we need to re init the shipwallet if the centra checkout script was loaded before the ingrid embed\n window.CentraCheckout?.reInitiate('shipwallet')\n }\n }, [])\n\n if (!selection?.pluginFields?.shipwallet?.snippet) {\n return null\n }\n\n return (\n <HtmlEmbed html={selection.pluginFields.shipwallet.snippet} id=\"centra-shipwallet-snippet\" />\n )\n}\n"],"mappings":";;;;;;AAIA,SAAgB,kBAAkB;CAChC,MAAM,EAAE,cAAcA,gBAAAA,mBAAmB;CAEzC,CAAA,GAAA,MAAA,UAAA,OAAgB;EACd,IAAI,oBAAoB,QAEtB,OAAO,gBAAgB,WAAW,YAAY;CAElD,GAAG,CAAC,CAAC;CAEL,IAAI,CAAC,WAAW,cAAc,YAAY,SACxC,OAAO;CAGT,OACE,iBAAA,GAAA,kBAAA,IAAA,CAACC,2BAAAA,WAAD;EAAW,MAAM,UAAU,aAAa,WAAW;EAAS,IAAG;CAA6B,CAAA;AAEhG"}