From 5dba0da3efae63cab5313582a17f20dbb41c6450 Mon Sep 17 00:00:00 2001
From: nsfisis <nsfisis@gmail.com>
Date: Wed, 21 Aug 2024 02:46:06 +0900
Subject: feat(frontend): partially implement sound effect

---
 .../GolfWatchAppWithAudioPlayRequest.client.tsx    | 36 ++++++++++++++++++++++
 1 file changed, 36 insertions(+)
 create mode 100644 frontend/app/components/GolfWatchAppWithAudioPlayRequest.client.tsx

(limited to 'frontend/app/components/GolfWatchAppWithAudioPlayRequest.client.tsx')

diff --git a/frontend/app/components/GolfWatchAppWithAudioPlayRequest.client.tsx b/frontend/app/components/GolfWatchAppWithAudioPlayRequest.client.tsx
new file mode 100644
index 0000000..e299f4b
--- /dev/null
+++ b/frontend/app/components/GolfWatchAppWithAudioPlayRequest.client.tsx
@@ -0,0 +1,36 @@
+import { useState } from "react";
+import { AudioController } from "../.client/audio/AudioController";
+import GolfWatchApp, { type Props } from "./GolfWatchApp.client";
+
+export default function GolfWatchAppWithAudioPlayRequest({
+	game,
+	sockToken,
+}: Omit<Props, "audioController">) {
+	const [audioController, setAudioController] =
+		useState<AudioController | null>(null);
+	const audioPlayPermitted = audioController !== null;
+
+	if (audioPlayPermitted) {
+		return (
+			<GolfWatchApp
+				game={game}
+				sockToken={sockToken}
+				audioController={audioController}
+			/>
+		);
+	} else {
+		return (
+			<div>
+				<button
+					onClick={async () => {
+						const audioController = new AudioController();
+						await audioController.loadAll();
+						setAudioController(audioController);
+					}}
+				>
+					Enable Audio Play
+				</button>
+			</div>
+		);
+	}
+}
-- 
cgit v1.2.3-70-g09d2

