import React, { useRef } from 'react';
import styles from './widget.module.scss';

const index = ({ module }) => {
  const iframeRef = useRef(null);
  const url =
  process.env.GATSBY_ENV === 'development'
    ? module.url.replace(
        'https://sportswidget.irishluck.ie',
        'https://dev.sportswidget.gigmedia.com'
      )
    : module.url;
  return (
    <iframe
      ref={iframeRef}
      title="widget"
      scrolling="no"
      style={{
        width: '100%',
        display: 'block',
        overflow: 'hidden',
      }}
      className={`${styles.iframe} ${module?.style ? styles[module.style] : ''}`}
      src={`${url}&linkFormat=${process.env.TRACKER_LINK_FORMAT_MAIN_WIDGET}`}
      loading="lazy"
    />
  );
};
export default index;
