-
Notifications
You must be signed in to change notification settings - Fork 0
/
affiliate_dashboard.html
209 lines (179 loc) · 8.72 KB
/
affiliate_dashboard.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
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
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta http-equiv="Content-Language" content="en">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Spark - Affiliate Dashboard</title>
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no, shrink-to-fit=no" />
<meta name="description" content="This is an example dashboard created using build-in elements and components.">
<meta name="msapplication-tap-highlight" content="no">
<link rel="icon" href="images/favicon.png" type="image/x-icon">
<link href="css/dashboard.css" rel="stylesheet">
<link href="css/bootstrap.css" rel="stylesheet">
</head>
<body>
<div class="app-container app-theme-white body-tabs-shadow fixed-header">
<div class="app-header header-shadow d-flex justify-content-between ">
<div class="app-header__logo">
<div class="logo-src"></div>
</div>
<div class="mx-5 d-flex">
<div>
<div class=" affiliate_name">
</div>
<div class=" affiliate_id">
Affiliate ID:
</div>
</div>
<div class="ml-4">
<button id="logout" class="btn btn-danger">Log Out</button>
</div>
</div>
</div>
<div class="app-main">
<div class="app-main__outer">
<div class="app-main__inner">
<div class="app-page-title">
<div class="page-title-wrapper">
<div class="page-title-heading">
<div class="affiliate_name"> Hi, </div>
</div>
</div>
</div>
<div class="row">
<div class="col-md-6 ">
<div class="card mb-3 widget-content">
<div class="widget-content-outer">
<div class="widget-content-wrapper">
<div class="widget-content-left">
<div class="widget-heading">Total Sales</div>
<div class="widget-subheading">Total count of sales</div>
</div>
<div class="widget-content-right">
<div id="total_sales" class="widget-numbers text-success"> </div>
</div>
</div>
</div>
</div>
</div>
<div class="col-md-6 ">
<div class="card mb-3 widget-content">
<div class="widget-content-outer">
<div class="widget-content-wrapper">
<div class="widget-content-left">
<div class="widget-heading">Total Earnings</div>
<div class="widget-subheading">Total sales earnings</div>
</div>
<div class="widget-content-right">
<div id="total_earnings" class="widget-numbers text-warning"> </div>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-md-12">
<div class="main-card mb-3 card">
<div class="card-header">Sales Report
</div>
<div class="table-responsive">
<table class="align-middle mb-0 table table-borderless table-striped table-hover">
<thead>
<tr>
<th class="text-center">#</th>
<th>Sales Type</th>
<th class="text-center">Duration</th>
<th class="text-center">Earnings</th>
<th class="text-center">Date</th>
</tr>
</thead>
<tbody>
<!-- <tr>
<td class="text-center text-muted">#345</td>
<td>John Doe</td>
<td class="text-center">One-off</td>
<td class="text-center">20,000</td>
<td class="text-center">12/05/2022
</td>
</tr> -->
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<script src="js/jquery.js"></script>
<script src="js/popper.min.js"></script>
<script src="js/bootstrap.min.js"></script>
<script src="https://unpkg.com/axios/dist/axios.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@10"></script>
<script type="text/javascript" src="js/dashboard.js"></script>
<script>
$('.app-container').hide()
if (localStorage.getItem('token') === null) {
Swal.fire({
title: 'Warning',
text: 'Login is required',
icon: 'warning'
}).then((result) => {
if (result.isConfirmed) {
window.location.href = 'energy_exchange.html';
}
})
} else {
$('.app-container').show()
}
$(document).ready(function() {
let token = localStorage.getItem('token')
let affiliate = JSON.parse(localStorage.getItem('affiliate'))
$('.affiliate_name').append(affiliate.fullname)
$('.affiliate_id').append(affiliate.id)
getAffiliate();
$('#logout').click(e => {
localStorage.clear();
window.location.replace("/index.html");
})
function getAffiliate() {
let config = {
headers: {
'Authorization': 'Bearer ' + token
}
}
axios.get(`https://api.sparknigeria.isparkng.com/api/dashboard?affliateID=${affiliate.id}`, config)
.then(function(response) {
console.log(response);
if (response.data.status) {
let result = response.data
$('#total_sales').append(result.total_sales)
$('#total_earnings').append(result.total_earnings)
result.data.forEach((i, ix) => {
$('table tbody').append('<tr><td class="text-center text-muted">' + ix + 1 + ' </td> <td>' + i.sale_type + '</td> <td class="text-center">' + i.earning_duration + '</td><td class="text-center">' + i.sales_earnings + '</td> <td class="text-center">' + i.date_of_sale + ' </td> </tr>')
})
} else {
Swal.fire({
title: 'Error!',
text: response.data.message,
icon: 'error'
})
}
})
.catch(function(error) {
console.log(error);
Swal.fire({
title: 'Error!',
text: error.message,
icon: 'error'
})
});
}
});
</script>
</body>
</html>