This repository was archived by the owner on Jun 22, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathCreateHost.jsx
More file actions
118 lines (104 loc) · 3.68 KB
/
Copy pathCreateHost.jsx
File metadata and controls
118 lines (104 loc) · 3.68 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
import React, {useState} from 'react'
import './CreateHost.css'
import profileImage1 from "./profile_img.jpg"
function CreateHost() {
const [Name, setName] = useState("");
const [Phone, setPhone] = useState("");
const [Email, setEmail] = useState("");
const [Link, setLink] = useState("");
const [ProfileImage, setProfileImage] = useState("");
const [successMessage, setSuccessMessage] = useState("")
const handleSubmit = async (e) => {
e.preventDefault()
try {
let res = await fetch("http://localhost:3000/api/hosts", {
method: "POST",
mode: "cors",
body: JSON.stringify({
first_name: Name, phone_number: Phone, email: Email, image_url: Link
}),
});
if (res.status === 201) {
setSuccessMessage("Host Profile created!")
setTimeout(window.location.replace("/create-event"), 4000);
}
}
catch (err){
console.log(err);
}
}
return (
<div className="create-host-container">
<form className="create-form" onSubmit={handleSubmit}>
<h2>Create Your Profile</h2>
{/* Profile Image Section */}
<div className="form-group">
<img
src={profileImage1}
alt="Profile picture"
className="profile-image"
/>
<label htmlFor="image-input">Enter image URL:</label>
<input
type="text"
id="image-input"
value={ProfileImage}
onChange={(e) => setProfileImage(e.target.value)}
/>
</div>
{/* Name Input */}
<div className="form-group">
<label htmlFor="name-input">Name:</label>
<input
type="text"
id="name-input"
value={Name}
onChange={(e) => setName(e.target.value)}
/>
</div>
{/* Phone Number Input */}
<div className="form-group">
<label htmlFor="phone-input">Phone Number:</label>
<input
type="text"
id="phone-input"
value={Phone}
onChange={(e) => setPhone(e.target.value)}
/>
</div>
{/* Email Input */}
<div className="form-group">
<label htmlFor="email-input">Email:</label>
<input
type="text"
id="email-input"
value={Email}
onChange={(e) => setEmail(e.target.value)}
/>
</div>
{/* Role Selection */}
<div className="form-group">
<label htmlFor="role-select">Are you an attendee or host?</label>
<select id="role-select">
<option value="Attendee">Attendee</option>
<option value="Host">Host</option>
<option value="Both">Both</option>
</select>
</div>
{/* Links Section */}
<div className="form-group">
<label htmlFor="link-input">Add any links (Optional):</label>
<input
type="text"
id="link-input"
value={Link}
onChange={(e) => setLink(e.target.value)}
/>
</div>
{/* Submit Button */}
<button className="button" type="submit">Create Account</button>
</form>
</div>
);
}
export default CreateHost;