// src/OptionPage.js
import { useEffect, useState } from 'react';
import '../css/global.css';
import '../css/textBox.css';
import '../css/nameBox.css';
import '../css/option.css'

function OptionPage({data , onClicked}) {
  const backgroundSRC = `${import.meta.env.VITE_ASSETS_URL}/${data.background}`
  const videoPath = `${import.meta.env.VITE_ASSETS_URL}/${data.sprite}`; // data.sprite return webm file name

  return (
    <div
      style={{
        display: 'flex',
        justifyContent: 'center',
        alignItems: 'center',
        height: '100svh',
        width: '100svw',  
        flexDirection: 'column',
        backgroundImage: `url(${backgroundSRC})`,
        backgroundSize: 'cover',
        backgroundPosition: 'center',
      }}
    >
      <div className='spriteBox'>
        <video width="200%" height="200%" autoPlay loop muted>
          <source src={videoPath} type="video/webm" />
          Your browser does not support the video tag.
        </video>
      </div>
      <div className='optionSection'>
        {
            data.option.map((item,i) => 
                <div onClick={()=>onClicked(item.goTo-1)} key={i} className='optionBox title'>{item.text}</div>)
        }
      </div>
    </div>
  );
}

export default OptionPage;
