-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathadd_campaign.html
65 lines (60 loc) · 1.97 KB
/
add_campaign.html
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Create Campaign</title>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css">
</head>
<body>
<div class="container">
<h2>Tambah Campaign</h2>
<form id="reportForm" enctype="multipart/form-data">
<div class="form-group">
<label for="picture">Picture:</label>
<input type="file" class="form-control-file" id="picture" name="picture" accept="image/*" required>
</div>
<div class="form-group">
<label for="title">Title:</label>
<input type="text" class="form-control" id="title" name="title" required>
</div>
<div class="form-group">
<label for="description">Description:</label>
<textarea class="form-control" id="description" name="description" rows="3" required></textarea>
</div>
<div class="form-group">
<label for="reward">Reward:</label>
<input type="number" class="form-control" id="reward" name="reward" required>
</div>
<button type="submit" class="btn btn-primary">Submit</button>
</form>
</div>
<script src="https://code.jquery.com/jquery-3.5.1.min.js"></script>
<script>
$(document).ready(function(){
$('#reportForm').submit(function(e){
e.preventDefault();
var formData = new FormData(this);
formData.append('reward', parseInt($('#reward').val()));
$.ajax({
url: 'https://hackfest.miruza.my.id/api/campaigns',
type: 'POST',
headers: {
'Authorization': 'Bearer ' + localStorage.getItem('token')
},
processData: false,
contentType: false,
data: formData,
success: function(response) {
alert('Campaign submitted successfully!');
window.location.href = 'campaign.html';
},
error: function(xhr, status, error) {
alert('Failed to submit report. Please try again.');
}
});
});
});
</script>
</body>
</html>