-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathgenerateMonthSellers.js
256 lines (216 loc) · 9.11 KB
/
generateMonthSellers.js
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
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
const monthSellers = [
{
imgUrl: "https://pewdizinho.github.io/PI1/assets/fotosZoadas/fundadores/Paulo.jpg",
name: "Paulo Eduardo Konopka",
category: "programmer",
curso: "Análise e Desenvolvimento de Sistemas",
title: "Programador do mês",
university: "Tuiuti",
stars: "★★★☆☆☆",
sellsThisMonth: "NaN",
sellAllTime: "NaN",
profileUrl: "",
},
{
imgUrl: "https://pewdizinho.github.io/PI1/assets/fotosZoadas/fundadores/joao.jpeg",
name: "João Gualberto Boissa Netto",
category: "programmer",
curso: "Análise e Desenvolvimento de Sistemas",
title: "Programador",
university: "Tuiuti",
stars: "★★★☆☆☆",
sellsThisMonth: "NaN",
sellAllTime: "NaN",
profileUrl: "",
},
{
imgUrl: "https://pewdizinho.github.io/PI1/assets/fotosZoadas/fundadores/Audrei.jpeg",
name: "Audrey Cristhiny",
category: "design",
curso: "Designer",
title: "Designer do mês",
university: "Tuiuti",
stars: "★★★☆☆☆",
sellsThisMonth: "NaN",
sellAllTime: "NaN",
profileUrl: "",
},
{
imgUrl: "https://pewdizinho.github.io/PI1/assets/fotosZoadas/fundadores/bagi.jpeg",
name: "Gabi Bagi Rocca Lobo da Costa",
category: "design",
curso: "Designer",
title: "Designer",
university: "Tuiuti",
stars: "★☆☆☆☆☆",
sellsThisMonth: "NaN",
sellAllTime: "NaN",
profileUrl: "",
},
{
imgUrl: "https://pewdizinho.github.io/PI1/assets/fotosZoadas/fundadores/cabeludo.jpeg",
name: "João Cabeludo Gabriel",
category: "marketing",
curso: "Marketing",
title: "Marketero do mês",
university: "Tuiuti",
stars: "★★★☆☆☆",
sellsThisMonth: "NaN",
sellAllTime: "NaN",
profileUrl: "",
},
{
imgUrl: "https://pewdizinho.github.io/PI1/assets/fotosZoadas/fundadores/luiz.jpeg",
name: "Luiz Henrique Pago",
category: "marketing",
curso: "Marketing",
title: "Marketero",
university: "Tuiuti",
stars: "★★★☆☆☆",
sellsThisMonth: "NaN",
sellAllTime: "NaN",
profileUrl: "",
},
]
function filterCategory(index) {
const categories = ["programmer", "design", "marketing", "nutrition", "audiosvisuais", "publicity"];
const categoriesNames = ["Programador", "Designer", "Marketing", "Nutricionistas", "Audios Visuais", "Publicitários"];
const parentElement = document.getElementById('menuBoxInside');
while (parentElement.firstChild) {
parentElement.removeChild(parentElement.firstChild);
}
for (let seller of monthSellers) {
document.getElementById("menuBoxTitle").innerText = categoriesNames[index];
if (seller.category.toLowerCase() == categories[index] || index > categories.length) {
document.getElementById("menuBoxInside").appendChild(new SellerOfTheMonthCard(seller).newCard);
if (index > categories.length) {
document.getElementById("menuBoxTitle").innerText = "Vendedores";
}
}
}
if (parentElement.firstChild == null) {
document.getElementById("menuBoxInside").appendChild(new SellerOfTheMonthCard().emptyCard);
}
}
function generateCard() {
for (let seller of monthSellers) {
const container = document.getElementById("menuBoxInside");
container.appendChild(new SellerOfTheMonthCard(seller).newCard);
}
}
class SellerOfTheMonthCard {
constructor(obj) {
this.seller = obj;
}
get newCard() {
const card = document.createElement("div");
const flipCardInner = document.createElement("div");
const flipCardFront = document.createElement("div");
const infoLeft = document.createElement("div");
const infoRight = document.createElement("div");
const spacer = document.createElement("div");
const name = document.createElement("p");
const title = document.createElement("p");
const area = document.createElement("p");
const university = document.createElement("p");
const stars = document.createElement("p");
const sellsThisMonth = document.createElement("p");
const sellAllTime = document.createElement("p");
const img = document.createElement("img");
name.innerText = this.seller.name;
title.innerText = this.seller.title;
area.innerText = this.seller.curso;
stars.innerText = this.seller.stars;
sellsThisMonth.innerText = `Vendas realizadas esse mês: ${this.seller.sellsThisMonth}`;
sellAllTime.innerText = `Vendas realizadas no total: ${this.seller.sellAllTime}`;
img.src = this.seller.imgUrl;
card.className = "flip-card";
flipCardInner.className = "flip-card-inner";
flipCardFront.className = "flip-card-front";
title.className = "menuBoxInfo txtShadow";
name.className = "menuBoxInfo txtShadow";
area.className = "menuBoxInfo txtShadow";
university.className = "menuBoxInfo txtShadow";
stars.className = "menuBoxInfo txtShadow";
sellsThisMonth.className = "menuBoxInfo txtShadow";
sellAllTime.className = "menuBoxInfo txtShadow";
spacer.className = "spacer";
img.className = "menuBoxIcon";
infoLeft.className = "menuBoxInfo";
infoRight.className = "menuBoxInfo";
card.addEventListener('click', () => {
window.location.href = 'https://pewdizinho.github.io/PI1/pages/clientplace/vendedor/index.html?user='
+ encodeURIComponent(this.seller.name)
})
infoLeft.appendChild(name);
infoLeft.appendChild(title);
infoLeft.appendChild(area);
flipCardFront.appendChild(img);
infoRight.appendChild(sellsThisMonth);
infoRight.appendChild(sellAllTime);
infoRight.appendChild(stars);
flipCardFront.appendChild(infoLeft);
flipCardFront.appendChild(spacer);
flipCardFront.appendChild(infoRight);
flipCardInner.appendChild(flipCardFront);
card.appendChild(flipCardInner);
return card;
}
get getCard() {
const card = document.createElement("div");
card.className = "menuBoxCard row justify";
const img = document.createElement("img");
img.className = "menuBoxIcon"
img.src = this.seller.imgUrl;
card.appendChild(img);
const infoLeft = document.createElement("div");
infoLeft.className = "menuBoxInfo column justify";
const infoRight = document.createElement("div");
infoRight.className = "menuBoxInfo column";
const name = document.createElement("p");
const area = document.createElement("p");
const university = document.createElement("p");
const stars = document.createElement("p");
const sellsThisMonth = document.createElement("p");
const sellAllTime = document.createElement("p");
name.innerText = this.seller.name;
area.innerText = `Área: ${this.seller.area}`;
university.innerText = `Faculdade: ${this.seller.university}`;
stars.innerText = `Nota: ${this.seller.stars}`;
sellsThisMonth.innerText = `Vendas realizadas esse mês: ${this.seller.sellsThisMonth}`;
sellAllTime.innerText = `Vendas realizadas no total: ${this.seller.sellAllTime}`;
name.className = "menuBoxInfo";
area.className = "menuBoxInfo";
university.className = "menuBoxInfo";
stars.className = "menuBoxInfo";
sellsThisMonth.className = "menuBoxInfo end";
sellAllTime.className = "menuBoxInfo end";
const spacer = document.createElement("div");
spacer.className = "spacer";
infoLeft.appendChild(name);
infoLeft.appendChild(area);
infoLeft.appendChild(university);
infoLeft.appendChild(stars);
infoRight.appendChild(sellsThisMonth);
infoRight.appendChild(sellAllTime);
card.appendChild(infoLeft);
card.appendChild(spacer);
card.appendChild(infoRight);
return card;
}
get emptyCard() {
const card = document.createElement("div");
card.className = "menuBoxCard row justify";
const infoLeft = document.createElement("div");
infoLeft.className = "menuBoxInfo column justify";
const name = document.createElement("p");
name.innerText = "Infelizmente não possuímos um estudante dessa área [Card in WIP]";
name.className = "menuBoxInfo";
const spacer = document.createElement("div");
spacer.className = "spacer";
infoLeft.appendChild(name);
card.appendChild(infoLeft);
card.appendChild(spacer);
return card;
}
}