-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtoothpaste.html
More file actions
131 lines (124 loc) · 3.86 KB
/
toothpaste.html
File metadata and controls
131 lines (124 loc) · 3.86 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Category - Boycott vs Alternatives</title>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
<style>
body {
margin: 0;
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
background-color: #e68e0c;
background-image: url('/static/bg.png');
background-repeat: repeat;
background-size: 100px;
color: #333;
}
header {
background-color: #fff;
padding: 15px 5%;
box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
display: flex;
justify-content: space-between;
align-items: center;
position: sticky;
top: 0;
z-index: 100;
}
.logo {
font-size: 24px;
font-weight: bold;
color: #2c3e50;
}
.logo span {
color: #e74c3c;
}
.content {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 30px;
padding: 100px 5% 50px;
}
.section {
background-color: #fff;
border-radius: 12px;
padding: 20px;
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}
.section h2 {
color: #e74c3c;
margin-bottom: 15px;
}
.product-list {
list-style: none;
padding: 0;
}
.product-item {
padding: 10px 0;
border-bottom: 1px solid #eee;
}
.product-item:last-child {
border-bottom: none;
}
.product-item a {
text-decoration: none;
color: #2c3e50;
font-weight: 500;
}
.product-item a:hover {
color: #e74c3c;
}
</style>
</head>
<body>
<header>
<a href="/" class="logo">Falas<span>طيني</span></a>
</header>
<div class="content">
<div class="section">
<h2>Boycotted Products</h2>
<ul id="boycott-list" class="product-list"></ul>
</div>
<div class="section">
<h2>Recommended Alternatives</h2>
<ul id="alt-list" class="product-list"></ul>
</div>
</div>
<script>
document.addEventListener('DOMContentLoaded', () => {
const categoryName = "Toothpaste";
fetch(`/api/category-id?name=${categoryName}`)
.then(res => res.json())
.then(result => {
if (result.error) {
alert(result.error);
return;
}
const categoryId = result.id;
return fetch(`/api/categories/${categoryId}/products`);
})
.then(res => res.json())
.then(data => {
const boycottList = document.getElementById('boycott-list');
const altList = document.getElementById('alt-list');
data.boycotted.forEach(p => {
const li = document.createElement('li');
li.className = 'product-item';
li.innerHTML = `<a href="/products/boycott/${p.product_id}">${p.product_name} (${p.brand_name})</a>`;
boycottList.appendChild(li);
});
data.alternatives.forEach(p => {
const li = document.createElement('li');
li.className = 'product-item';
li.innerHTML = `<a href="/products/alternative/${p.product_id}">${p.product_name} (${p.brand_name})</a>`;
altList.appendChild(li);
});
})
.catch(err => {
console.error('Error loading products:', err);
});
});
</script>
</body>
</html>