-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
initial user creation form on first start
- Loading branch information
Showing
7 changed files
with
48 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import React, {useState} from 'react'; | ||
import {useNavigate} from 'react-router-dom'; | ||
import {useApi} from '../../hooks/useApi'; | ||
|
||
const InitialUserCreation = () => { | ||
const navigate = useNavigate(); | ||
const { apiCall } = useApi(); | ||
const [name, setName] = useState(''); | ||
const [email, setEmail] = useState(''); | ||
const [username, setUsername] = useState(''); | ||
const [password, setPassword] = useState(''); | ||
|
||
const handleSubmit = async (e) => { | ||
e.preventDefault(); | ||
try { | ||
await apiCall('/users/create-initial', 'POST', { name, email, username, password }); | ||
navigate('/login'); | ||
} catch (error) { | ||
console.error('Error creating initial user:', error); | ||
} | ||
}; | ||
|
||
return ( | ||
<div className="initialUserCreationContainer"> | ||
<form onSubmit={handleSubmit} className="formStyle"> | ||
<input type="text" value={name} onChange={(e) => setName(e.target.value)} placeholder="Name" required /> | ||
<input type="email" value={email} onChange={(e) => setEmail(e.target.value)} placeholder="Email" required /> | ||
<input type="text" value={username} onChange={(e) => setUsername(e.target.value)} placeholder="Username" required /> | ||
<input type="password" value={password} onChange={(e) => setPassword(e.target.value)} placeholder="Password" required /> | ||
<button type="submit" className="buttonStyle">Create Initial User</button> | ||
</form> | ||
</div> | ||
); | ||
}; | ||
|
||
export default InitialUserCreation; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters