import React, { useEffect } from 'react';

import classNames from 'classnames';

import Spotlight from '@enact/spotlight';
import Spottable from '@enact/spotlight/Spottable';

import css from './TCFI.module.less';

const SpottableComponent = Spottable("div");

export default function TCFI({ className, data }) {
  useEffect(() => {
    Spotlight.focus("spotData");
  }, [data]);
  return (
    <>
      {data &&
        data.map(({ bgImgPath, curationNm, tmpltCd }) => {
          return (
            <div key={tmpltCd} className={classNames(className && className)}>
              <SpottableComponent
                className={css.fullImg}
                spotlightId="spotData"
              >
                <img src={bgImgPath} alt={curationNm} />
              </SpottableComponent>
            </div>
          );
        })}
    </>
  );
}
