Skip to content

Commit

Permalink
Merge pull request #360 from Talishar/github-logo
Browse files Browse the repository at this point in the history
GitHub logo
  • Loading branch information
LaustinSpayce committed May 7, 2023
2 parents 583d154 + 39a21e4 commit 1f5a942
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 14 deletions.
3 changes: 2 additions & 1 deletion src/appConstants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,8 @@ export const URL_END_POINT = {
RESET_PASSWORD: `AccountFiles/ResetPassword.php`,
GET_COSMETICS: `APIs/GetCosmetics.php`,
DELETE_DECK: `APIs/DeleteDeckAPI.php`,
PATREON_LOGIN: `AccountFiles/PatreonLoginAPI.php`
PATREON_LOGIN: `AccountFiles/PatreonLoginAPI.php`,
LOAD_BUG_REPORT: `LoadBugReport.php`
};

export const GAME_VISIBILITY = {
Expand Down
11 changes: 11 additions & 0 deletions src/features/api/apiSlice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,16 @@ export const apiSlice = createApi({
};
}
}),
loadDebugGame: builder.mutation({
query: ({ ...body }: any) => {
return {
url: URL_END_POINT.LOAD_BUG_REPORT,
method: 'POST',
body: body,
responseHandler: parseResponse
};
}
}),
submitPatreonLogin: builder.mutation<
PatreonLoginResponse,
{
Expand Down Expand Up @@ -364,5 +374,6 @@ export const {
useChooseFirstPlayerMutation,
useSubmitSideboardMutation,
useSubmitPatreonLoginMutation,
useLoadDebugGameMutation,
useGetUserProfileQuery
} = apiSlice;
11 changes: 10 additions & 1 deletion src/routes/game/components/zones/playerHand/PlayerHand.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,16 @@ const ManualMode = () => {

return (
<div className={styles.manualMode}>
<input onChange={(e) => setCard(e.target.value)}></input>
<input
onChange={(e) => setCard(e.target.value)}
onKeyDown={(e) => {
e.stopPropagation();
}}
onKeyDownCapture={(e) => {
e.stopPropagation();
}}
placeholder={'enter card code here'}
></input>
<button onClick={handleSubmitButton}>Add</button>
<button onClick={handleCloseManualMode}>Close</button>
</div>
Expand Down
32 changes: 20 additions & 12 deletions src/routes/index/components/devTool/devTool.tsx
Original file line number Diff line number Diff line change
@@ -1,43 +1,51 @@
import React, { useId, useState } from 'react';

import styles from './devTool.module.css';
import { useLoadDebugGameMutation } from 'features/api/apiSlice';
import { toast } from 'react-hot-toast';

const DevTool = () => {
return (
<article className={styles.devTool}>
<h2>Dev Tool (Not visible in prod)</h2>
<div>No tools right now</div>
<DebugGame />
</article>
);
};

const DebugGame = () => {
const gameIDInput = useId();
const localIDInput = useId();
const [gameID, setGameID] = useState<string | undefined>(undefined);
const [localGame, setLocalGame] = useState<string | undefined>(undefined);
const [debugGameMutation] = useLoadDebugGameMutation();

const handleButtonClick = (
e: React.MouseEvent<HTMLButtonElement, MouseEvent>
) => {
e.preventDefault();
window.open(
`${window.location.origin}/game/play/${gameID}/?playerID=1`,
'_blank'
);
window.open(
`${window.location.origin}/game/play/${gameID}/?playerID=2`,
'_blank'
);
toast.promise(debugGameMutation({ source: gameID, target: localGame }), {
loading: 'Submitting',
success: 'Success, refresh your games in progress.',
error: 'Some error, check the network'
});
};

return (
<div>
<label htmlFor={gameIDInput}>Game ID to debug:</label>
<label htmlFor={gameIDInput}>Debug game ID:</label>
<input
id={gameIDInput}
onChange={(e) => setGameID(e.target.value)}
></input>
<button onClick={handleButtonClick}>Launch game</button>
<div>{gameID}</div>
<label htmlFor={localIDInput}>Local game ID to overwrite:</label>
<input
id={localIDInput}
onChange={(e) => setLocalGame(e.target.value)}
></input>
<button onClick={handleButtonClick}>
Replace local game with debug game
</button>
</div>
);
};
Expand Down

0 comments on commit 1f5a942

Please sign in to comment.