diff --git a/src/app/_components/HomePage/HomePagePlayMode.tsx b/src/app/_components/HomePage/HomePagePlayMode.tsx
index 13c54358..a8b6a9c0 100644
--- a/src/app/_components/HomePage/HomePagePlayMode.tsx
+++ b/src/app/_components/HomePage/HomePagePlayMode.tsx
@@ -93,7 +93,7 @@ const HomePagePlayMode: React.FC = () => {
}
-
+
{showTestGames &&
diff --git a/src/app/_components/_sharedcomponents/CreateGameForm/CreateGameForm.tsx b/src/app/_components/_sharedcomponents/CreateGameForm/CreateGameForm.tsx
index c7d9bc16..6d98b5c0 100644
--- a/src/app/_components/_sharedcomponents/CreateGameForm/CreateGameForm.tsx
+++ b/src/app/_components/_sharedcomponents/CreateGameForm/CreateGameForm.tsx
@@ -20,23 +20,14 @@ import {
DeckValidationFailureReason,
IDeckValidationFailures
} from '@/app/_validators/DeckValidation/DeckValidationTypes';
-
-interface ICreateGameFormProps {
- format?: string | null;
- setFormat?: (format: string) => void;
-}
+import { SwuGameFormat, FormatLabels } from '@/app/_constants/constants';
const deckOptions: string[] = [
'Order66',
'ThisIsTheWay',
];
-const formatOptions: string[] = ['Premier'];
-
-const CreateGameForm: React.FC = ({
- format,
- setFormat,
-}) => {
+const CreateGameForm = () => {
const pathname = usePathname();
const router = useRouter();
const isCreateGamePath = pathname === '/creategame';
@@ -47,6 +38,10 @@ const CreateGameForm: React.FC = ({
const [deckLink, setDeckLink] = useState('');
const [saveDeck, setSaveDeck] = useState(false);
const [errorModalOpen, setErrorModalOpen] = useState(false);
+ const savedFormat = localStorage.getItem('format') || SwuGameFormat.Premier;
+ const [format, setFormat] = useState(savedFormat);
+
+ const formatOptions = Object.values(SwuGameFormat);
// For a short, user-friendly error message
const [deckErrorSummary, setDeckErrorSummary] = useState(null);
@@ -58,6 +53,11 @@ const CreateGameForm: React.FC = ({
const [gameName, setGameName] = useState('');
const [privacy, setPrivacy] = useState(user ? 'Public' : 'Private');
+ const handleChangeFormat = (format: SwuGameFormat) => {
+ localStorage.setItem('format', format);
+ setFormat(format);
+ }
+
// Handle Create Game Submission
const handleCreateGameSubmit = async (event: FormEvent) => {
event.preventDefault();
@@ -84,6 +84,7 @@ const CreateGameForm: React.FC = ({
user: user || sessionStorage.getItem('anonymousUserId'),
deck: deckData,
isPrivate: privacy === 'Private',
+ format: format,
};
const response = await fetch(`${process.env.NEXT_PUBLIC_ROOT_URL}/api/create-lobby`,
{
@@ -257,14 +258,14 @@ const CreateGameForm: React.FC = ({
) =>
- setFormat ? setFormat(e.target.value) : null
+ handleChangeFormat(e.target.value as SwuGameFormat)
}
- required
>
{formatOptions.map((fmt) => (
))}
diff --git a/src/app/_constants/constants.ts b/src/app/_constants/constants.ts
index 59bd22c4..9c8423a0 100644
--- a/src/app/_constants/constants.ts
+++ b/src/app/_constants/constants.ts
@@ -2,4 +2,16 @@ export enum MatchType {
Custom = 'Custom',
Private = 'Private',
Quick = 'Quick',
-}
\ No newline at end of file
+}
+
+export enum SwuGameFormat {
+ Premier = 'premier',
+ NextSetPreview = 'nextSetPreview',
+ Open = 'open'
+}
+
+export const FormatLabels: Record = {
+ [SwuGameFormat.Premier]: 'Premier',
+ [SwuGameFormat.NextSetPreview]: 'Next Set Preview',
+ [SwuGameFormat.Open]: 'Open',
+};
\ No newline at end of file