-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcreate_event.html
More file actions
164 lines (138 loc) · 8.13 KB
/
create_event.html
File metadata and controls
164 lines (138 loc) · 8.13 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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Create Blood Donation Event</title>
<script src="https://kit.fontawesome.com/a076d05399.js" crossorigin="anonymous"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0-beta3/css/all.min.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0-beta3/css/all.min.css">
<link rel="stylesheet" href="src/css/style.css">
<script src="https://cdn.tailwindcss.com"></script>
<link rel="icon" href="/src/images/data.doner_icon.png" type="image/x-icon">
</head>
<body class="bg-red-50">
<header class="z-10"> </header>
<div class="max-w-5xl mx-auto mt-10 p-8 rounded-lg">
<!-- Animated Header -->
<div class="flex flex-col items-center justify-center">
<div class="bg-red-500 p-4 rounded-full shadow-lg animate-bounce">
<svg class="w-10 h-10 text-white" fill="none" stroke="currentColor" stroke-width="2" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" d="M12 8v4l3 3m0 0l-3-3m3 3H9m12-6a9 9 0 11-18 0 9 9 0 0118 0z"></path>
</svg>
</div>
<h1 class="text-3xl font-bold text-red-600 mt-4">Create Blood Donation Event</h1>
<p class="text-gray-600 mt-1 mb-6">Fill in the details to organize an event</p>
</div>
<form id="create-event-form" class="space-y-6 mt-6">
<!-- Toolbar in header of Form and submit button -->
<!-- <div class="flex items-center justify-between rounded-lg px-4 py-4 mt-8 "> </div> -->
<div class="lg:grid space-y-6 lg:space-y-0 grid-cols-12 gap-8">
<!-- Left Side (Title, Blood Group, Description) -->
<div class="col-span-8 space-y-4 bg-white border shadow-lg px-8 py-10 rounded-lg">
<!-- Event Title & Blood Group -->
<div class="md:grid grid-cols-10 gap-4">
<div class="col-span-8 relative text-2xl">
<input type="text" name="title" placeholder="Event Title" class="peer w-full font-bold text-gray-800 focus:outline-none focus:ring-0">
<!-- <label class="absolute left-3 -top-3 text-gray-500 peer-placeholder-shown:top-3 transition-all">Event Title</label> -->
</div>
<div class="col-span-2">
<select name="blood" class="w-full px-4 py-3 rounded-lg border border-gray-300 focus:ring-1 focus:ring-gray-400">
<option value="" disabled selected> Blood </option>
<option value="A+">A+</option>
<option value="A-">A-</option>
<option value="B+">B+</option>
<option value="B-">B-</option>
<option value="O+">O+</option>
<option value="O-">O-</option>
<option value="AB+">AB+</option>
<option value="AB-">AB-</option>
</select>
</div>
</div>
<hr class="my-4 border-gray-300">
<!-- Description -->
<div>
<label class="block text-sm font-medium text-gray-600 mb-1">Event Description</label>
<textarea name="description" rows="8" placeholder="Provide a brief description..." class="w-full text-gray-800 bg-gray-50 border border-gray-300 focus:outline-none focus:ring-1 focus:ring-gray-500 p-4 rounded-lg" required></textarea>
</div>
</div>
<!-- Right Side (Date, Time, Location, Organizer) -->
<div class="col-span-4 bg-white border shadow-lg px-8 py-10 rounded-lg">
<div class="flex flex-col gap-6 space-y-2">
<div>
<label class="block text-sm font-medium text-gray-600 mb-1">Event Date</label>
<input type="date" name="date" class="w-full text-gray-800 focus:outline-none focus:ring-0 px-2" required>
</div>
<div>
<label class="block text-sm font-medium text-gray-600 mb-1">Event Time</label>
<input type="time" name="time" class="w-full text-gray-800 focus:outline-none focus:ring-0 px-2" required>
</div>
<div>
<label class="block text-sm font-medium text-gray-600 mb-1">Event Location</label>
<input type="text" name="location" placeholder="Venue address or link" class="w-full text-gray-800 border border-gray-300 focus:outline-none focus:ring-1 focus:ring-gray-400 px-4 py-2" required>
</div>
<div>
<label class="block text-sm font-medium text-gray-600 mb-1">Organizer</label>
<input type="text" name="organizer" value="@username" placeholder="Your Name" class="w-full text-gray-800 border border-gray-300 focus:outline-none focus:ring-1 focus:ring-gray-400 px-4 py-2" disabled>
</div>
<!-- Submit Button -->
<div class="text-center mt-6">
<button type="submit" class="px-6 py-3 bg-red-600 text-white font-semibold rounded-md hover:bg-red-700 transition duration-300">
Create Event
</button>
</div>
</div>
</div>
</div>
</form>
</div>
<footer> </footer>
<script>
document.getElementById('create-event-form').addEventListener('submit', function (event) {
event.preventDefault();
// is_authticated();
const form = document.getElementById('create-event-form');
const formData = new FormData(form);
const user_id = localStorage.getItem('user_id');
// document.getElementById('submit-btn').disabled = true;
// document.getElementById('loading-spinner').classList.remove('hidden');
const data = {
"user": user_id,
"title": formData.get('title'),
"description": formData.get('description'),
"event_date": formData.get('date'),
"event_time": formData.get('time'),
"blood": formData.get('blood'),
"location": formData.get('location'),
};
pushAlert('processing',"Wait few second!")
fetch('https://datadonor-webapp.vercel.app/event/events/create/', {
method: 'POST',
headers: {
"Content-Type": "application/json", // Corrected header name
},
body: JSON.stringify(data)
})
.then(res => {
if (!res.ok) {
// If the response is not OK (status code not in the 200-299 range)
throw new Error('Failed to create event');
}
return res.json();
})
.then(backdata => {
pushAlert('success',`${data.blood} event created successfull!. View Your profile`)
// window.location.reload(); // Reload the page after successful creation
})
.catch(error => {
console.error('Error:', error); // Added error handling
pushAlert('alert',error);
});
});
</script>
<script src="src/js/header.js"></script>
<script src="src/js/footer.js"></script>
<script src="src/js/logout.js"></script>
</body>
</html>