/* eslint-disable no-plusplus */ import React, { useState } from 'react'; import Confetti from 'react-confetti'; import { Button, Popup } from 'semantic-ui-react'; import { GridSize } from '../App'; import BingoSlot from '../components/BingoSlot'; import { LoadDataOrFallback, SaveDataToAppStorage, ClearSavedData } from '../data/Loader'; const CheckForBingpot = (data /* {src: img, hit: bool}[] */) => { let bingpot = true; let rowIdx = 0; let colIdx = 0; for (rowIdx = 0; rowIdx < GridSize; rowIdx++) { bingpot = true; for (colIdx = 0; colIdx < GridSize; colIdx++) { if (!data[rowIdx][colIdx].hit) { bingpot = false; break; } } if (bingpot) return true; } for (colIdx = 0; colIdx < GridSize; colIdx++) { bingpot = true; for (rowIdx = 0; rowIdx < GridSize; rowIdx++) { if (!data[rowIdx][colIdx].hit) { bingpot = false; break; } } if (bingpot) return true; } bingpot = true; rowIdx = 0; colIdx = 0; while (rowIdx < GridSize && colIdx < GridSize) { if (!data[rowIdx][colIdx].hit) { bingpot = false; break; } rowIdx++; colIdx++; } if (bingpot) return true; bingpot = true; rowIdx = 0; colIdx = (GridSize - 1); while (rowIdx < GridSize) { if (!data[rowIdx][colIdx].hit) { bingpot = false; break; } rowIdx++; colIdx--; } return bingpot; }; export default () => { const [showConfetti, setShowConfetti] = useState(false); const data = LoadDataOrFallback(); SaveDataToAppStorage(data); const rows = []; data.forEach((row, rowIdx) => { rows.push(