From 016a4f266b3275ff2e66c7cf9fdf8da3d7a04c11 Mon Sep 17 00:00:00 2001 From: Pinapelz Date: Sun, 26 Oct 2025 15:19:05 -0700 Subject: reduce amount of modal useStates + add Flower import modals (RB + nostop) --- .../components/modals/FlowerUserscriptModal.tsx | 169 +++++++++++++++++++++ frontend/src/pages/Import.tsx | 101 ++++++++---- 2 files changed, 243 insertions(+), 27 deletions(-) create mode 100644 frontend/src/components/modals/FlowerUserscriptModal.tsx diff --git a/frontend/src/components/modals/FlowerUserscriptModal.tsx b/frontend/src/components/modals/FlowerUserscriptModal.tsx new file mode 100644 index 0000000..7e0b3ce --- /dev/null +++ b/frontend/src/components/modals/FlowerUserscriptModal.tsx @@ -0,0 +1,169 @@ +interface UserScript { + name: string; + url: string; +} + +interface FlowerUserscriptModalProps { + isOpen: boolean; + onClose: () => void; + mainGameName: string; + userPage: string; + importPage: string; + scripts: UserScript[]; +} + +interface FlowerUserscriptCardProps { + mainGameName: string; + onClick: () => void; +} + +export const FlowerUserscriptCard = ({ mainGameName, onClick }: FlowerUserscriptCardProps) => { + return ( +
+
+ + + +
+

+ {mainGameName} Flower Play History (Userscript) +

+

+ Import playdata from cabinets on the Flower network +

+ +
+ ) +} + +const FlowerUserscriptModal = ({ + isOpen, + onClose, + mainGameName, + userPage, + importPage, + scripts, +}: FlowerUserscriptModalProps) => { + if (!isOpen) return null; + + const handleClose = () => { + onClose(); + }; + if(mainGameName === undefined){ + return "Sorry, due to some extreme error the game you're looking for doesn't seem to exist..." + } + return ( +
+ {/* Backdrop */} +
+ + {/* Modal */} +
+
+ {/* Header */} +
+

+ Import {mainGameName} Flower Play Data +

+

+ Follow the instructions below to import your data +

+
+ + {/* Warning */} +
+

+ You will need your ACCESS CODE to register on Flower for the first time!

+ Do this by tapping your Amusement IC card at any machine on the Flower network and copying + down the code displayed on the screen. +

+ This is likely not the same code as the one on the back of your card. +

+
+ + {/* Instructions */} +
+

+ Instructions: +

+
    +
  1. + Log into the{" "} + + {mainGameName} Project Flower page + +
  2. +
  3. + Navigate to the{" "} + + {mainGameName} Play History Page + {" "} +
  4. +
  5. + Install the relevant userscript (use a browser extension such as{" "} + Tampermonkey) +
  6. + {/* Additional Info */} +
    +

    + {scripts.map(userscript => ( + + {userscript.name} + + ))} +

    +
    +
  7. + A button will appear on the page that you can click to start the scraping process. +
  8. +
  9. + Upload the resulting JSON file into Mirage using the + Batch-Manual Upload functionality +
  10. +
  11. Verify that all data has been imported correctly
  12. +
+
+ + {/* Actions */} +
+ +
+
+
+
+ ); +}; + +export default FlowerUserscriptModal; diff --git a/frontend/src/pages/Import.tsx b/frontend/src/pages/Import.tsx index f798b51..2af4a0e 100644 --- a/frontend/src/pages/Import.tsx +++ b/frontend/src/pages/Import.tsx @@ -6,21 +6,22 @@ import type { SupportedGame } from "../types/game"; import { uploadScore } from "../utils/scoreUpload"; import { NavBar } from "../components/NavBar"; import { EamusementUserscriptCard } from "../components/modals/EamusementUserscriptModal"; +import { FlowerUserscriptCard } from "../components/modals/FlowerUserscriptModal"; const JsonUploadModal = lazy(() => import("../components/modals/JsonUploadModal")); const EamusementUserscriptModal = lazy(() => import("../components/modals/EamusementUserscriptModal")); const DivaNetModal = lazy(() => import("../components/modals/DivaNetModal")); const MusicDiverModal = lazy(() => import("../components/modals/MusicDiverModal")); +const FlowerUserscriptModal = lazy(() => import("../components/modals/FlowerUserscriptModal")); + +type ModalType = 'json' | 'dancerush' | 'dancearound' | 'divanet' | 'musicdiver' | 'nostalgia' | 'reflecbeat'; const Import = () => { const { user, isLoading, logout } = useAuth(); const navigate = useNavigate(); const [selectedGame, setSelectedGame] = useState(""); - const [isJsonModalOpen, setIsJsonModalOpen] = useState(false); - const [isDancerushModalOpen, setIsDancerushModalOpen] = useState(false); - const [isDanceAroundModalOpen, setIsDanceAroundModalOpen] = useState(false); - const [isDivaNetModalOpen, setIsDivaNetModalOpen] = useState(false); - const [isMusicDiverModalOpen, setIsMusicDiverModalOpen] = useState(false); + const [openModal, setOpenModal] = useState(null); + const [supportedGames, setSupportedGames] = useState([]); const [gamesLoading, setGamesLoading] = useState(true); const [uploadStatus, setUploadStatus] = useState<{ @@ -120,7 +121,7 @@ const Import = () => { Upload your game data from a Mirage compatible JSON file

}> - {isJsonModalOpen && ( + {openModal === 'json' && ( setIsJsonModalOpen(false)} + isOpen={true} + onClose={() => setOpenModal(null)} onUpload={handleJsonUpload} game={ supportedGames.find((g) => g.internalName === selectedGame) @@ -293,23 +314,23 @@ const Import = () => { } /> )} - {isDancerushModalOpen && ( + {openModal === 'dancerush' && ( setIsDancerushModalOpen(false)} + isOpen={true} + onClose={() => setOpenModal(null)} mainGameName="DANCERUSH" userPage="https://p.eagate.573.jp/game/dan/1st/top/entrance.html" - importPage="https://p.eagate.573.jp/game/dan/1st/top/index.html#play_his" + importPage="https://p.eagate.573.jp/payment/p/ex_select_course.html" scripts={[{ name: "e-amusement Recently Played Score Export Userscript (Last 20 Played)", url: "https://github.com/pinapelz/Mirage/raw/refs/heads/main/scripts/dancerush/dancerush_play_history.user.js" }]} /> )} - {isDanceAroundModalOpen && ( + {openModal === 'dancearound' && ( setIsDanceAroundModalOpen(false)} + isOpen={true} + onClose={() => setOpenModal(null)} mainGameName="DANCE aROUND" userPage="https://p.eagate.573.jp/game/around/1st/top/index.html" importPage="https://p.eagate.573.jp/game/around/1st/top/index.html#play_hist" @@ -319,26 +340,52 @@ const Import = () => { }]} /> )} - {isDivaNetModalOpen && ( + {openModal === 'divanet' && ( setIsDivaNetModalOpen(false)} + isOpen={true} + onClose={() => setOpenModal(null)} game={ supportedGames.find((g) => g.internalName === selectedGame) || undefined } /> )} - {isMusicDiverModalOpen && ( + {openModal === 'musicdiver' && ( setIsMusicDiverModalOpen(false)} + isOpen={true} + onClose={() => setOpenModal(null)} game={ supportedGames.find((g) => g.internalName === selectedGame) || undefined } /> )} + {openModal === 'nostalgia' && ( + setOpenModal(null)} + mainGameName="NOSTALGIA" + userPage="https://projectflower.eu" + importPage="https://projectflower.eu/game/nostalgia/54827307" + scripts={[{ + name: "Flower Play History (Exports only the page you are on)", + url: "https://github.com/pinapelz/Mirage/raw/refs/heads/main/scripts/nostalgia/nostalgia_flower_scraper.user.js" + }]} + /> + )} + {openModal === 'reflecbeat' && ( + setOpenModal(null)} + mainGameName="REFLEC BEAT" + userPage="https://projectflower.eu" + importPage="https://projectflower.eu/game/rb/profile/21363050" + scripts={[{ + name: "Flower Play History (Exports only the page you are on)", + url: "https://github.com/pinapelz/Mirage/raw/refs/heads/main/scripts/reflecbeat/reflecbeat_flower_scraper.user.js" + }]} + /> + )} ); -- cgit v1.2.3