|
9 | 9 | import { ipfsToHttpUrl, isIpfsUrl, uploadToPinata } from "./utils/pinata"; |
10 | 10 | import PlayerCreationProgress from "./PlayerCreationProgress"; |
11 | 11 | import { usePlayerCreationService } from "./services/playerCreationService"; |
| 12 | +import { useNetworkCheck } from "./shared/hooks/useNetworkCheck"; |
| 13 | +import { NetworkSwitchMessage } from "./shared/components/NetworkSwitchMessage"; |
12 | 14 |
|
13 | 15 | interface RegistrationFormProps { |
14 | 16 | isOpen: boolean; |
@@ -70,6 +72,11 @@ const RegistrationForm: React.FC<RegistrationFormProps> = ({ |
70 | 72 | publicClient |
71 | 73 | ); |
72 | 74 |
|
| 75 | + const { isCorrectNetwork, currentChainId, targetChainId } = useNetworkCheck({ |
| 76 | + walletConnected, |
| 77 | + publicClient: wagmiConfig?.publicClient |
| 78 | + }); |
| 79 | + |
73 | 80 | useEffect(() => { |
74 | 81 | const checkExistingAtom = async () => { |
75 | 82 | if (!walletAddress || !walletConnected) return; |
@@ -178,6 +185,7 @@ const RegistrationForm: React.FC<RegistrationFormProps> = ({ |
178 | 185 | // Close the form after 3 seconds |
179 | 186 | setTimeout(() => { |
180 | 187 | onClose(); |
| 188 | + window.location.reload(); |
181 | 189 | }, 3000); |
182 | 190 | } catch (error) { |
183 | 191 | console.error("Error creating player:", error); |
@@ -271,24 +279,31 @@ const RegistrationForm: React.FC<RegistrationFormProps> = ({ |
271 | 279 | Create Your Player |
272 | 280 | </h2> |
273 | 281 |
|
274 | | - <PlayerCreationProgress |
275 | | - step={step} |
276 | | - isCreatingAtom={isCreatingAtom} |
277 | | - isCreatingTriples={isCreatingTriples} |
278 | | - creationSuccess={creationSuccess} |
279 | | - atomId={atomId} |
280 | | - tripleCreated={tripleCreated} |
281 | | - walletAddress={walletAddress} |
282 | | - hasExistingAtom={hasExistingAtom} |
283 | | - formData={formData} |
284 | | - handleInputChange={handleInputChange} |
285 | | - handleSelectChange={handleSelectChange} |
286 | | - handleFileUpload={handleFileUpload} |
287 | | - handleSubmit={handleSubmit} |
288 | | - isLoading={isLoading} |
289 | | - isUploading={isUploading} |
290 | | - fileInputRef={fileInputRef} |
291 | | - /> |
| 282 | + {!isCorrectNetwork ? ( |
| 283 | + <NetworkSwitchMessage |
| 284 | + currentChainId={currentChainId} |
| 285 | + targetChainId={targetChainId} |
| 286 | + /> |
| 287 | + ) : ( |
| 288 | + <PlayerCreationProgress |
| 289 | + step={step} |
| 290 | + isCreatingAtom={isCreatingAtom} |
| 291 | + isCreatingTriples={isCreatingTriples} |
| 292 | + creationSuccess={creationSuccess} |
| 293 | + atomId={atomId} |
| 294 | + tripleCreated={tripleCreated} |
| 295 | + walletAddress={walletAddress} |
| 296 | + hasExistingAtom={hasExistingAtom} |
| 297 | + formData={formData} |
| 298 | + handleInputChange={handleInputChange} |
| 299 | + handleSelectChange={handleSelectChange} |
| 300 | + handleFileUpload={handleFileUpload} |
| 301 | + handleSubmit={handleSubmit} |
| 302 | + isLoading={isLoading} |
| 303 | + isUploading={isUploading} |
| 304 | + fileInputRef={fileInputRef} |
| 305 | + /> |
| 306 | + )} |
292 | 307 | </div> |
293 | 308 | </div> |
294 | 309 | ); |
|
0 commit comments