import React from 'react'; import style from '../../styles/style'; import DigitInput from 'react-digit-input'; import API from '../SpreadsheetData'; import {observable} from "mobx"; import {observer, inject} from 'mobx-react'; const s = Object.create(style); s.input = { width: '1em', height: '1em', font: 'inherit', textAlign: 'center', margin: '0.1em', } s.inputGroup = { // display: 'flex', alignItems: 'center', } s.hyphen = { background: 'white', height: '0.1em', width: '.5em', display: 'inline-block', } @inject((stores, props, context) => props) @observer export default class EnterTheCode extends React.Component { @observable code = ""; @observable message = null; @observable fan = null; render() { if (!this.fan) { API.getSpreadsheet(API.path("1hzSojB76Me-P1qppxYR0oiHSU56jyK59x3DKm660ntc"), (data) => { this.fan = data; }); return (Loading...); } let getRandomInt = (min, max) => { min = Math.ceil(min); max = Math.floor(max); //The maximum is exclusive and the minimum is inclusive return Math.floor(Math.random() * (max - min)) + min; } let validate = (e) => { e.preventDefault(); e.stopPropagation(); if (this.code == "" || this.code.indexOf(" ") === 1) { this.message = (

Please enter a 12 digit code

); } else { let card = this.fan[getRandomInt(0, this.fan.length)]; this.message = (

Congrats on your scan!


{card.gsx$name.$t}


); } } return(
this.code = value} > {props => (
)}



{this.message}
); } }