Skip to content

Commit 0a1c7aa

Browse files
authored
Merge pull request #9 from x-team/feature/XTG-321
[XTG-321] - Fixing game name update logic to match new design
2 parents fc4be3c + b56eeff commit 0a1c7aa

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

src/pages/GameEditorPage.tsx

+10-6
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,7 @@ const GameEditorPage = function GameEditorPage({ editMode }: IProps) {
7474
getFieldProps,
7575
getFieldMeta,
7676
handleSubmit,
77-
// dirty,
78-
// isValid,
77+
isValid,
7978
setValues,
8079
} = useFormik({
8180
initialValues: initialForm,
@@ -139,15 +138,21 @@ const GameEditorPage = function GameEditorPage({ editMode }: IProps) {
139138
return <SyncLoader />;
140139
}
141140

142-
// const isSubmitDisabled = !dirty || !isValid;
141+
const handleEditButtonClick = () => {
142+
if(isUpdatingGameName && isValid) {
143+
handleSubmit()
144+
} else {
145+
setIsUpdatingGameName(true)
146+
}
147+
}
143148

144149
return (
145150
<div>
146151
<h2 className="text-2xl font-bold italic font-sans mb-8">
147152
{editMode ? "UPDATE GAME" : "NEW GAME"}
148153
</h2>
149154
<div className="flex flex-wrap">
150-
<form onSubmit={handleSubmit} className="py-10 mr-8">
155+
<form className="py-10 mr-8">
151156
<div className="flex">
152157
<div>
153158
{isUpdatingGameName ?
@@ -180,8 +185,7 @@ const GameEditorPage = function GameEditorPage({ editMode }: IProps) {
180185
</div>
181186

182187
<div className="mt-4">
183-
{/* FIX THIS LOGIC */}
184-
<Button onClick={() => setIsUpdatingGameName(true)}>
188+
<Button type="button" onClick={handleEditButtonClick}>
185189
{editMode ? "Update Game" : "Create Game"}
186190
</Button>
187191
</div>

0 commit comments

Comments
 (0)