{"version":3,"file":"card-Bd6XXjgA.js","sources":["../../src/components/products/card.tsx"],"sourcesContent":["import Button from '@/components/button';\nimport {ProductPictos} from '@/components/products';\nimport type {Product as TProduct} from '@/lib/sdk';\nimport {useAuth} from '@/stores/auth';\nimport {cleanProductTitle} from '@/utils/cleanProductTitle';\nimport {formatPrice} from '@/utils/formatPrice';\nimport {\n  dispatchGAEvent,\n  formatCategoryIdForGA,\n  formatCategoryNameForGA,\n  formatPriceForGA,\n} from '@/utils/googleAnalytics';\nimport sd from 'snarkdown';\nimport {ParentProps, Show} from 'solid-js';\n\nexport function ProductCard(\n\tprops: ParentProps<{ product: TProduct; isLinkedProduct?: boolean }>,\n) {\n  const product = () => props.product;\n  const [auth] = useAuth();\n  const isAExternalLink = () => !!product()?.externalLink;\n  const isYearlySubscription = () => product()?.isYearlySubscription;\n\n  const isCykleo = () => {\n\treturn product()?.variants.some((variant) => variant.providerId === \"CYKLEO\");\n  }\n\n  const onClickDispatchGAEvent = () => {\n\tdispatchGAEvent('select_item', null, auth.user, {\n\t  ecommerce: {\n\t\titem_list_id: formatCategoryIdForGA(product().categoryId),\n\t\titem_list_name: formatCategoryNameForGA(product().categoryId),\n\t\titems: [\n\t\t  {\n\t\t\titem_id: product().id,\n\t\t\titem_name: product().title,\n\t\t\titem_brand: formatCategoryNameForGA(product().categoryId),\n\t\t\titem_list_id: formatCategoryIdForGA(product().categoryId),\n\t\t\titem_list_name: formatCategoryNameForGA(product().categoryId),\n\t\t\tprice: formatPriceForGA(product().price),\n\t\t\tcurrency: 'EUR',\n\t\t\tquantity: '1',\n\t\t\tindex: 1,\n\t\t\titem_category: formatCategoryNameForGA(product().categoryId),\n\t\t  },\n\t\t],\n\t  },\n\t});\n  };\n\n  return (\n\t  <article\n\t\t  id={`${product().id}`}\n\t\t  class=\"mt-4 flex flex-col rounded-lg border border-gray-300 bg-white px-4 py-4 lg:grid lg:px-10 lg:py-10\"\n\t\t  classList={{\n\t\t\t// This handle the the case where there's no image... might be a bit shaky\n\t\t\t'lg:grid-cols-[15%,50%,35%]': Boolean(product().image),\n\t\t\t'lg:grid-cols-[0%,70%,30%]': !Boolean(product().image),\n\t\t  }}\n\t  >\n\t\t<Show when={Boolean(product().image)}>\n\t\t  <img\n\t\t\t  src={product().image}\n\t\t\t  alt=\"\"\n\t\t\t  class=\"mx-auto h-32 lg:col-start-1 lg:row-span-4 lg:self-center\"\n\t\t  />\n\t\t</Show>\n\n\t\t<section class=\"flex flex-col items-center lg:col-start-2 lg:row-span-4 lg:mr-4 lg:self-center lg:border-r\">\n\t\t  <Show when={!props.isLinkedProduct}>\n\t\t\t<h2 class=\"mb-4 self-center text-xl font-semibold lg:text-2xl\">\n\t\t\t  {cleanProductTitle(product().title)}\n\t\t\t</h2>\n\t\t  </Show>\n\n\t\t  <Show when={product()?.mobilities}>\n\t\t\t<ProductPictos mobilities={product().mobilities}/>\n\t\t  </Show>\n\n\t\t  <p\n\t\t\t  class=\"prose mt-6 text-sm lg:col-start-2 lg:row-span-2 lg:row-start-1 lg:mt-0 lg:self-center lg:px-4\"\n\t\t\t  innerHTML={sd(product()?.shortText || '')}\n\t\t  />\n\t\t</section>\n\n\t\t<hr class=\"mx-auto my-8 w-20 border-gray-300 lg:hidden\"/>\n\n\t\t<Show\n\t\t\twhen={isYearlySubscription()}\n\t\t\tfallback={\n\t\t\t  <p\n\t\t\t\t  class=\"col-span-2 mx-auto text-2xl font-bold lg:col-start-3 lg:row-start-1\"\n\t\t\t\t  classList={{hidden: isAExternalLink()}}\n\t\t\t  >\n\t\t\t\t{/* TODO: Handle localisation */}\n\t\t\t\t{formatPrice(product().price)}\n\t\t\t  </p>\n\t\t\t}\n\t\t>\n\t\t  <Show when={!isCykleo()}\n\t\t\t\tfallback={\n\t\t\t\t  <div\n\t\t\t\t\t  class=\"col-span-2 mx-auto  self-center justify-self-center text-2xl lg:col-start-3 lg:row-start-1\">\n\t\t\t\t\t<p class=\"col-span-2 mx-auto text-2xl font-bold lg:col-start-3 lg:row-start-1\">\n\t\t\t\t\t  {formatPrice(product().price)}\n\t\t\t\t\t</p>\n\t\t\t\t  </div>\n\n\t\t\t\t}\n\t\t  >\n\t\t\t<div class=\"col-span-2 mx-auto  self-center justify-self-center text-2xl lg:col-start-3 lg:row-start-1\">\n\t\t\t  <p class=\"text-xl font-bold\">\n\t\t\t\t{formatPrice(product().monthlyPrice)}/mois\n\t\t\t  </p>\n\t\t\t  <p class=\"text-center text-sm text-gray-400\">\n\t\t\t\tou {formatPrice(product().price)}/an\n\t\t\t  </p>\n\t\t\t</div>\n\t\t  </Show>\n\t\t</Show>\n\n\t\t<Button\n\t\t\thref={\n\t\t\t  props.isLinkedProduct\n\t\t\t\t  ? product().externalLink\n\t\t\t\t  : `/products/${product().id}`\n\t\t\t}\n\t\t\tvariant=\"primary\"\n\t\t\tclass=\"col-span-2 mx-auto mt-2 justify-self-center lg:col-start-3 lg:row-span-3 lg:mx-auto lg:w-auto lg:self-center\"\n\t\t\tclassList={{'lg:row-span-4': isAExternalLink()}}\n\t\t\tonClick={onClickDispatchGAEvent}\n\t\t>\n\t\t  En savoir plus\n\t\t</Button>\n\t  </article>\n  );\n}\n"],"names":["ProductCard","props","product","auth","useAuth","isAExternalLink","externalLink","onClickDispatchGAEvent","dispatchGAEvent","user","ecommerce","item_list_id","formatCategoryIdForGA","categoryId","item_list_name","formatCategoryNameForGA","items","item_id","id","item_name","title","item_brand","price","formatPriceForGA","currency","quantity","index","item_category","_el$","_tmpl$4","_el$3","firstChild","_el$5","nextSibling","_$insert","_$createComponent","Show","when","Boolean","image","children","_el$2","_tmpl$","_$effect","_$setAttribute","isLinkedProduct","_el$4","_tmpl$2","cleanProductTitle","mobilities","ProductPictos","isYearlySubscription","fallback","_el$14","_tmpl$5","formatPrice","classList","toggle","variants","some","variant","providerId","_el$15","_tmpl$6","_el$16","_el$7","_tmpl$3","_el$8","_el$9","_el$10","_el$13","monthlyPrice","Button","href","_$memo","class","onClick","_p$","_v$","_v$2","_v$3","sd","shortText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