Skip to content

Commit

Permalink
Add snek song when score includes holderOfSnek
Browse files Browse the repository at this point in the history
  • Loading branch information
Niclas Fredriksson committed May 4, 2021
1 parent 0184d6b commit 036f4d1
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 1 deletion.
1 change: 1 addition & 0 deletions ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"react-scripts": "4.0.0",
"react-simple-pull-to-refresh": "^1.2.3",
"typescript": "~4.0.5",
"use-sound": "^3.0.1",
"web-vitals": "^0.2.4"
},
"scripts": {
Expand Down
Binary file added ui/public/snek.mp3
Binary file not shown.
7 changes: 6 additions & 1 deletion ui/src/components/scorecard/ScorecardForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import DialogContentText from '@material-ui/core/DialogContentText';
import DialogTitle from '@material-ui/core/DialogTitle';
import MenuItem from '@material-ui/core/MenuItem';
import { SubmitScorecard } from '../../services/ScoreboardService';
import useSound from 'use-sound';

type Scorecard = {
name: string;
Expand All @@ -26,6 +27,7 @@ export function ScorecardForm(props: { updateState: () => Promise<void> }) {
const [nettoEagles, setNettoEagles] = useState('0');
const [muligans, setMuligans] = useState('0');
const [open, setOpen] = useState(false);
const [playSnek] = useSound('./snek.mp3', { volume: 0.25 });
const validData: { [key: string]: string } = {
name: '.+',
points: '^[0-9]\\d*$',
Expand Down Expand Up @@ -85,7 +87,10 @@ export function ScorecardForm(props: { updateState: () => Promise<void> }) {
nettoEagles: +nettoEagles,
muligans: +muligans,
};
const body = await SubmitScorecard(JSON.stringify(scorecard));
if (scorecard.holderOfSnek) {
playSnek();
}
await SubmitScorecard(JSON.stringify(scorecard));
await props.updateState();
setOpen(false);
};
Expand Down
12 changes: 12 additions & 0 deletions ui/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5551,6 +5551,11 @@ hosted-git-info@^2.1.4:
resolved "https://registry.yarnpkg.com/hosted-git-info/-/hosted-git-info-2.8.8.tgz#7539bd4bc1e0e0a895815a2e0262420b12858488"
integrity sha512-f/wzC2QaWBs7t9IYqB4T3sR1xviIViXJRJTWBlx2Gf3g0Xi5vI7Yy4koXQ1c9OYDGHN9sBy1DQ2AB8fqZBWhUg==

howler@^2.1.3:
version "2.2.1"
resolved "https://registry.yarnpkg.com/howler/-/howler-2.2.1.tgz#a521a9b495841e8bb9aa12e651bebba0affc179e"
integrity sha512-0iIXvuBO/81CcrQ/HSSweYmbT50fT2mIc9XMFb+kxIfk2pW/iKzDbX1n3fZmDXMEIpYvyyfrB+gXwPYSDqUxIQ==

hpack.js@^2.1.6:
version "2.1.6"
resolved "https://registry.yarnpkg.com/hpack.js/-/hpack.js-2.1.6.tgz#87774c0949e513f42e84575b3c45681fade2a0b2"
Expand Down Expand Up @@ -11014,6 +11019,13 @@ url@^0.11.0:
punycode "1.3.2"
querystring "0.2.0"

use-sound@^3.0.1:
version "3.0.1"
resolved "https://registry.yarnpkg.com/use-sound/-/use-sound-3.0.1.tgz#9671926ffb32773875f80b51258a5a17e3841ac5"
integrity sha512-M6rwX6x+yaBw/R+adPfSlydef2W3UXcOZOmk9TsfAobEDUfKO71lwHOe6ammGGW2DVDXV5t1KoU7dxBLlxFTtA==
dependencies:
howler "^2.1.3"

use@^3.1.0:
version "3.1.1"
resolved "https://registry.yarnpkg.com/use/-/use-3.1.1.tgz#d50c8cac79a19fbc20f2911f56eb973f4e10070f"
Expand Down

0 comments on commit 036f4d1

Please sign in to comment.