From 2165ef8739accd82b085d2e98c03207d5c9e3605 Mon Sep 17 00:00:00 2001 From: Steve C Date: Sun, 23 Jun 2024 23:04:34 -0400 Subject: [PATCH 01/10] convert CRA to Next --- .gitignore | 4 + {src/app => app}/BetFunctions.jsx | 0 {src/app => app}/DropZone.jsx | 0 app/FaviconGenerator.jsx | 40 ++ {src/app => app}/Footer.jsx | 4 +- {src/app => app}/Header.jsx | 6 +- {src/app => app}/HomePage.jsx | 0 {src/app => app}/RoundState.jsx | 17 +- .../app => app}/components/BetAmountInput.jsx | 0 .../components/BetAmountsButtons.jsx | 0 .../components/BetAmountsSettings.jsx | 0 .../components/BigBrainElement.jsx | 0 .../components/ClearBetsButton.jsx | 0 .../components/CustomOddsElement.jsx | 0 .../components/CustomOddsInput.jsx | 0 .../components/CustomProbsInput.jsx | 0 {src/app => app}/components/EditBets.jsx | 0 {src/app => app}/components/ExtraBox.jsx | 0 .../components/FaDetailsElement.jsx | 0 .../components/HorizontalScrollingBox.jsx | 0 {src/app => app}/components/PayoutCharts.jsx | 0 {src/app => app}/components/PayoutTable.jsx | 0 {src/app => app}/components/Pd.jsx | 0 {src/app => app}/components/PirateSelect.jsx | 0 .../components/PlaceThisBetButton.jsx | 0 {src/app => app}/components/RoundInput.jsx | 0 {src/app => app}/components/SettingsBox.jsx | 0 {src/app => app}/components/TableSettings.jsx | 2 +- {src/app => app}/components/Td.jsx | 0 {src/app => app}/components/TextTooltip.jsx | 0 {src/app => app}/components/VercelCredit.jsx | 0 {src/app => app}/constants.js | 0 {src/app => app}/constants_logit.js | 0 {public => app}/icon-16x16.png | Bin {public => app}/icon-192x192.png | Bin {public => app}/icon-32x32.png | Bin {public => app}/icon-512x512.png | Bin {src => app}/index.css | 0 app/layout.jsx | 19 + {public => app}/manifest.json | 0 {src/app => app}/maths.js | 0 src/app/App.jsx => app/page.jsx | 29 +- {public => app}/robots.txt | 0 {src => app}/service-worker.js | 0 {src => app}/serviceWorkerRegistration.js | 0 {src => app}/theme.js | 0 {src/app => app}/useRoundData.js | 0 {src/app => app}/util.js | 0 jsconfig.json | 7 + next.config.mjs | 7 + package-lock.json | 423 +++++++++++++++++- package.json | 8 +- {src/app => public}/images/np-icon.svg | 0 public/index.html | 46 -- src/.index.js.swn | Bin 4096 -> 0 bytes src/.index.js.swo | Bin 4096 -> 0 bytes src/.index.js.swp | Bin 12288 -> 0 bytes src/app/FaviconGenerator.jsx | 34 -- src/index.js | 31 -- src/reportWebVitals.js | 13 - src/setupTests.js | 5 - 61 files changed, 537 insertions(+), 158 deletions(-) rename {src/app => app}/BetFunctions.jsx (100%) rename {src/app => app}/DropZone.jsx (100%) create mode 100644 app/FaviconGenerator.jsx rename {src/app => app}/Footer.jsx (96%) rename {src/app => app}/Header.jsx (98%) rename {src/app => app}/HomePage.jsx (100%) rename {src/app => app}/RoundState.jsx (89%) rename {src/app => app}/components/BetAmountInput.jsx (100%) rename {src/app => app}/components/BetAmountsButtons.jsx (100%) rename {src/app => app}/components/BetAmountsSettings.jsx (100%) rename {src/app => app}/components/BigBrainElement.jsx (100%) rename {src/app => app}/components/ClearBetsButton.jsx (100%) rename {src/app => app}/components/CustomOddsElement.jsx (100%) rename {src/app => app}/components/CustomOddsInput.jsx (100%) rename {src/app => app}/components/CustomProbsInput.jsx (100%) rename {src/app => app}/components/EditBets.jsx (100%) rename {src/app => app}/components/ExtraBox.jsx (100%) rename {src/app => app}/components/FaDetailsElement.jsx (100%) rename {src/app => app}/components/HorizontalScrollingBox.jsx (100%) rename {src/app => app}/components/PayoutCharts.jsx (100%) rename {src/app => app}/components/PayoutTable.jsx (100%) rename {src/app => app}/components/Pd.jsx (100%) rename {src/app => app}/components/PirateSelect.jsx (100%) rename {src/app => app}/components/PlaceThisBetButton.jsx (100%) rename {src/app => app}/components/RoundInput.jsx (100%) rename {src/app => app}/components/SettingsBox.jsx (100%) rename {src/app => app}/components/TableSettings.jsx (99%) rename {src/app => app}/components/Td.jsx (100%) rename {src/app => app}/components/TextTooltip.jsx (100%) rename {src/app => app}/components/VercelCredit.jsx (100%) rename {src/app => app}/constants.js (100%) rename {src/app => app}/constants_logit.js (100%) rename {public => app}/icon-16x16.png (100%) rename {public => app}/icon-192x192.png (100%) rename {public => app}/icon-32x32.png (100%) rename {public => app}/icon-512x512.png (100%) rename {src => app}/index.css (100%) create mode 100644 app/layout.jsx rename {public => app}/manifest.json (100%) rename {src/app => app}/maths.js (100%) rename src/app/App.jsx => app/page.jsx (84%) rename {public => app}/robots.txt (100%) rename {src => app}/service-worker.js (100%) rename {src => app}/serviceWorkerRegistration.js (100%) rename {src => app}/theme.js (100%) rename {src/app => app}/useRoundData.js (100%) rename {src/app => app}/util.js (100%) create mode 100644 jsconfig.json create mode 100644 next.config.mjs rename {src/app => public}/images/np-icon.svg (100%) delete mode 100644 public/index.html delete mode 100644 src/.index.js.swn delete mode 100644 src/.index.js.swo delete mode 100644 src/.index.js.swp delete mode 100644 src/app/FaviconGenerator.jsx delete mode 100644 src/index.js delete mode 100644 src/reportWebVitals.js delete mode 100644 src/setupTests.js diff --git a/.gitignore b/.gitignore index f8c4f656..afd5249e 100644 --- a/.gitignore +++ b/.gitignore @@ -27,3 +27,7 @@ yarn-error.log* public/rounds/ __pycache__/ + +.next +next-env.d.ts +dist diff --git a/src/app/BetFunctions.jsx b/app/BetFunctions.jsx similarity index 100% rename from src/app/BetFunctions.jsx rename to app/BetFunctions.jsx diff --git a/src/app/DropZone.jsx b/app/DropZone.jsx similarity index 100% rename from src/app/DropZone.jsx rename to app/DropZone.jsx diff --git a/app/FaviconGenerator.jsx b/app/FaviconGenerator.jsx new file mode 100644 index 00000000..f4418d96 --- /dev/null +++ b/app/FaviconGenerator.jsx @@ -0,0 +1,40 @@ +import { useEffect } from "react"; + +const faviconTemplate = (icon) => { + return `${icon}`; +}; + +function FaviconGenerator() { + useEffect(() => { + const emojis = [ + "🍗", + "🍔", + "🍞", + "🥪", + "🥨", + "🍕", + "🌭", + "🌮", + "🌯", + "🍖", + "🥩", + "🥧", + "🥓", + "🦀", + ]; + + const linkForFavicon = document.querySelector(`head > link[rel='icon']`); + + if (linkForFavicon) { + const favicon = faviconTemplate( + emojis[Math.floor(Math.random() * emojis.length)] + ); + + linkForFavicon.setAttribute("href", `data:image/svg+xml,${favicon}`); + } + }, []); // Empty dependency array ensures this runs only once + + return null; +} + +export default FaviconGenerator; diff --git a/src/app/Footer.jsx b/app/Footer.jsx similarity index 96% rename from src/app/Footer.jsx rename to app/Footer.jsx index 2dfd4a30..5c5b2dad 100644 --- a/src/app/Footer.jsx +++ b/app/Footer.jsx @@ -12,13 +12,13 @@ import { Flex, } from "@chakra-ui/react"; import * as React from "react"; -import NeopointIcon from "./images/np-icon.svg"; +import NeopointIcon from "../public/images/np-icon.svg"; import { VercelCredit } from "./components/VercelCredit"; function Logo() { return ( - + NeoFoodClub diff --git a/src/app/Header.jsx b/app/Header.jsx similarity index 98% rename from src/app/Header.jsx rename to app/Header.jsx index fc4984b4..c9567691 100644 --- a/src/app/Header.jsx +++ b/app/Header.jsx @@ -28,7 +28,7 @@ import Cookies from "universal-cookie"; import Moment from "react-moment"; import React, { useContext, useEffect, useState, useMemo } from "react"; import moment from "moment"; -import NeopointIcon from "./images/np-icon.svg"; +import NeopointIcon from "../public/images/np-icon.svg"; import { calculateBaseMaxBet, @@ -211,14 +211,14 @@ function MaxBetInput() { ); } -function TitleHeading(props) { +function TitleHeading() { return ( <>
{ + const initialState = parseBetUrl(global?.window?.location.hash.slice(1)); -const initialViewMode = - Object.values(initialState.bets).filter((x) => x.some((val) => val > 0)) - .length > 0; + const initialViewMode = + Object.values(initialState.bets).filter((x) => x.some((val) => val > 0)) + .length > 0; -const StateProvider = ({ children }) => { const [roundState, setRoundState] = useReducer(reducer, { roundData: null, currentRound: null, @@ -79,7 +78,7 @@ const StateProvider = ({ children }) => { }; return ( - { }} > {children} - + ); }; diff --git a/src/app/components/BetAmountInput.jsx b/app/components/BetAmountInput.jsx similarity index 100% rename from src/app/components/BetAmountInput.jsx rename to app/components/BetAmountInput.jsx diff --git a/src/app/components/BetAmountsButtons.jsx b/app/components/BetAmountsButtons.jsx similarity index 100% rename from src/app/components/BetAmountsButtons.jsx rename to app/components/BetAmountsButtons.jsx diff --git a/src/app/components/BetAmountsSettings.jsx b/app/components/BetAmountsSettings.jsx similarity index 100% rename from src/app/components/BetAmountsSettings.jsx rename to app/components/BetAmountsSettings.jsx diff --git a/src/app/components/BigBrainElement.jsx b/app/components/BigBrainElement.jsx similarity index 100% rename from src/app/components/BigBrainElement.jsx rename to app/components/BigBrainElement.jsx diff --git a/src/app/components/ClearBetsButton.jsx b/app/components/ClearBetsButton.jsx similarity index 100% rename from src/app/components/ClearBetsButton.jsx rename to app/components/ClearBetsButton.jsx diff --git a/src/app/components/CustomOddsElement.jsx b/app/components/CustomOddsElement.jsx similarity index 100% rename from src/app/components/CustomOddsElement.jsx rename to app/components/CustomOddsElement.jsx diff --git a/src/app/components/CustomOddsInput.jsx b/app/components/CustomOddsInput.jsx similarity index 100% rename from src/app/components/CustomOddsInput.jsx rename to app/components/CustomOddsInput.jsx diff --git a/src/app/components/CustomProbsInput.jsx b/app/components/CustomProbsInput.jsx similarity index 100% rename from src/app/components/CustomProbsInput.jsx rename to app/components/CustomProbsInput.jsx diff --git a/src/app/components/EditBets.jsx b/app/components/EditBets.jsx similarity index 100% rename from src/app/components/EditBets.jsx rename to app/components/EditBets.jsx diff --git a/src/app/components/ExtraBox.jsx b/app/components/ExtraBox.jsx similarity index 100% rename from src/app/components/ExtraBox.jsx rename to app/components/ExtraBox.jsx diff --git a/src/app/components/FaDetailsElement.jsx b/app/components/FaDetailsElement.jsx similarity index 100% rename from src/app/components/FaDetailsElement.jsx rename to app/components/FaDetailsElement.jsx diff --git a/src/app/components/HorizontalScrollingBox.jsx b/app/components/HorizontalScrollingBox.jsx similarity index 100% rename from src/app/components/HorizontalScrollingBox.jsx rename to app/components/HorizontalScrollingBox.jsx diff --git a/src/app/components/PayoutCharts.jsx b/app/components/PayoutCharts.jsx similarity index 100% rename from src/app/components/PayoutCharts.jsx rename to app/components/PayoutCharts.jsx diff --git a/src/app/components/PayoutTable.jsx b/app/components/PayoutTable.jsx similarity index 100% rename from src/app/components/PayoutTable.jsx rename to app/components/PayoutTable.jsx diff --git a/src/app/components/Pd.jsx b/app/components/Pd.jsx similarity index 100% rename from src/app/components/Pd.jsx rename to app/components/Pd.jsx diff --git a/src/app/components/PirateSelect.jsx b/app/components/PirateSelect.jsx similarity index 100% rename from src/app/components/PirateSelect.jsx rename to app/components/PirateSelect.jsx diff --git a/src/app/components/PlaceThisBetButton.jsx b/app/components/PlaceThisBetButton.jsx similarity index 100% rename from src/app/components/PlaceThisBetButton.jsx rename to app/components/PlaceThisBetButton.jsx diff --git a/src/app/components/RoundInput.jsx b/app/components/RoundInput.jsx similarity index 100% rename from src/app/components/RoundInput.jsx rename to app/components/RoundInput.jsx diff --git a/src/app/components/SettingsBox.jsx b/app/components/SettingsBox.jsx similarity index 100% rename from src/app/components/SettingsBox.jsx rename to app/components/SettingsBox.jsx diff --git a/src/app/components/TableSettings.jsx b/app/components/TableSettings.jsx similarity index 99% rename from src/app/components/TableSettings.jsx rename to app/components/TableSettings.jsx index 55da5ab7..e76eebcb 100644 --- a/src/app/components/TableSettings.jsx +++ b/app/components/TableSettings.jsx @@ -253,7 +253,7 @@ const CopyWithDomain = () => { return (