-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
256 lines (252 loc) · 8.47 KB
/
index.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
// Importar Firebase
const { initializeApp } = require('firebase/app');
const { getFirestore, collection, addDoc } = require('firebase/firestore');
// Configuración de Firebase (reemplaza con tus credenciales)
const firebaseConfig = {
apiKey: "tu-api-key",
authDomain: "tu-auth-domain",
projectId: "tu-project-id",
storageBucket: "tu-storage-bucket",
messagingSenderId: "tu-messaging-sender-id",
appId: "tu-app-id"
};
// Inicializar Firebase
const app = initializeApp(firebaseConfig);
const db = getFirestore(app);
// Array de productos de Amazon
const products = [
{
title: "Apple AirPods Pro (2nd Generation)",
price: 249.99,
description: "Auriculares inalámbricos con cancelación activa de ruido, audio espacial y resistencia al agua",
category: "Electrónicos",
image: "https://images.unsplash.com/photo-1603351154351-5e2d0600bb77?auto=format&fit=crop&w=800",
rating: {
rate: 4.7,
count: 2834
}
},
{
title: "Samsung Galaxy S23 Ultra",
price: 1199.99,
description: "Smartphone Android premium con S Pen, cámara de 200MP y pantalla Dynamic AMOLED 2X",
category: "Electrónicos",
image: "https://images.unsplash.com/photo-1610945265064-0e34e5519bbf?auto=format&fit=crop&w=800",
rating: {
rate: 4.6,
count: 1523
}
},
{
title: "Sony WH-1000XM4",
price: 348.00,
description: "Auriculares inalámbricos con cancelación de ruido líder en la industria",
category: "Electrónicos",
image: "https://images.unsplash.com/photo-1618366712010-f4ae9c647dcb?auto=format&fit=crop&w=800",
rating: {
rate: 4.8,
count: 3456
}
},
{
title: "LG OLED C3 65\" Smart TV",
price: 1796.99,
description: "TV OLED 4K con procesador α9 Gen6 AI, 120Hz, Dolby Vision y Gaming Features",
category: "Electrónicos",
image: "https://images.unsplash.com/photo-1593359677879-a4bb92f829d1?auto=format&fit=crop&w=800",
rating: {
rate: 4.8,
count: 1245
}
},
{
title: "MacBook Air M2",
price: 1099.99,
description: "Laptop Apple con chip M2, 13.6\" Liquid Retina Display, 8GB RAM, 256GB SSD",
category: "Electrónicos",
image: "https://images.unsplash.com/photo-1517336714731-489689fd1ca8?auto=format&fit=crop&w=800",
rating: {
rate: 4.9,
count: 2156
}
},
{
title: "Kindle Paperwhite",
price: 139.99,
description: "E-reader con pantalla de 6.8\", luz cálida ajustable y 8GB de almacenamiento",
category: "Electrónicos",
image: "https://m.media-amazon.com/images/I/712JlBgtkJL._AC_SX679_.jpg",
rating: {
rate: 4.7,
count: 5678
}
},
{
title: "Nintendo Switch OLED",
price: 349.99,
description: "Consola de videojuegos con pantalla OLED de 7 pulgadas y almacenamiento de 64GB",
category: "Videojuegos",
image: "https://images.unsplash.com/photo-1578303512597-81e6cc155b3e?auto=format&fit=crop&w=800",
rating: {
rate: 4.8,
count: 3421
}
},
{
title: "Bose QuietComfort 45",
price: 279.00,
description: "Auriculares inalámbricos con cancelación de ruido y hasta 24 horas de batería",
category: "Electrónicos",
image: "https://images.unsplash.com/photo-1546435770-a3e426bf472b?auto=format&fit=crop&w=800",
rating: {
rate: 4.7,
count: 1876
}
},
{
title: "Canon EOS R6 Mark II",
price: 2499.00,
description: "Cámara mirrorless full-frame con 24.2MP y grabación 4K 60p",
category: "Fotografía",
image: "https://images.unsplash.com/photo-1516035069371-29a1b244cc32?auto=format&fit=crop&w=800",
rating: {
rate: 4.9,
count: 892
}
},
{
title: "iPad Pro 12.9\"",
price: 1099.00,
description: "Tablet con chip M2, pantalla Liquid Retina XDR, 128GB",
category: "Electrónicos",
image: "https://images.unsplash.com/photo-1544244015-0df4b3ffc6b0?auto=format&fit=crop&w=800",
rating: {
rate: 4.8,
count: 1543
}
},
{
title: "Xbox Series X",
price: 499.99,
description: "Consola de nueva generación con 1TB SSD y 4K gaming",
category: "Videojuegos",
image: "https://images.unsplash.com/photo-1621259182978-fbf93132d53d?auto=format&fit=crop&w=800",
rating: {
rate: 4.8,
count: 2987
}
},
{
title: "DJI Mini 3 Pro",
price: 759.00,
description: "Drone ultraligero con cámara 4K, tiempo de vuelo de 34 minutos",
category: "Electrónicos",
image: "https://images.unsplash.com/photo-1473968512647-3e447244af8f?auto=format&fit=crop&w=800",
rating: {
rate: 4.7,
count: 756
}
},
{
title: "Samsung 49\" Odyssey G9",
price: 1199.99,
description: "Monitor gaming curvo ultrawide 5120x1440, 240Hz, 1ms",
category: "Electrónicos",
image: "https://images.unsplash.com/photo-1527443224154-c4a3942d3acf?auto=format&fit=crop&w=800",
rating: {
rate: 4.6,
count: 892
}
},
{
title: "Logitech MX Master 3S",
price: 99.99,
description: "Ratón inalámbrico premium con sensor de 8000 DPI",
category: "Electrónicos",
image: "https://images.unsplash.com/photo-1527864550417-7fd91fc51a46?auto=format&fit=crop&w=800",
rating: {
rate: 4.8,
count: 3456
}
},
{
title: "GoPro HERO11 Black",
price: 399.99,
description: "Cámara de acción con video 5.3K, fotos de 27MP y HyperSmooth 5.0",
category: "Fotografía",
image: "https://images.unsplash.com/photo-1565849904461-04a58ad377e0?auto=format&fit=crop&w=800",
rating: {
rate: 4.7,
count: 1234
}
},
{
title: "Sonos Arc",
price: 899.00,
description: "Barra de sonido premium con Dolby Atmos y control por voz",
category: "Audio",
image: "https://images.unsplash.com/photo-1545454675-3531b543be5d?auto=format&fit=crop&w=800",
rating: {
rate: 4.7,
count: 987
}
},
{
title: "Razer Blade 15",
price: 1999.99,
description: "Laptop gaming con RTX 4070, Intel i7, 16GB RAM, 1TB SSD",
category: "Electrónicos",
image: "https://images.unsplash.com/photo-1544731612-de7f96afe55f?auto=format&fit=crop&w=800",
rating: {
rate: 4.6,
count: 654
}
},
{
title: "Meta Quest 3",
price: 499.99,
description: "Casco de realidad virtual todo en uno con controladores Touch Plus",
category: "Videojuegos",
image: "https://images.unsplash.com/photo-1622979135225-d2ba269cf1ac?auto=format&fit=crop&w=800",
rating: {
rate: 4.7,
count: 1432
}
},
{
title: "Elgato Stream Deck MK.2",
price: 149.99,
description: "Controlador de contenido con 15 teclas LCD personalizables",
category: "Electrónicos",
image: "https://images.unsplash.com/photo-1561883088-039e53143d73?auto=format&fit=crop&w=800",
rating: {
rate: 4.8,
count: 876
}
},
{
title: "ASUS ROG Swift PG32UQ",
price: 999.99,
description: "Monitor gaming 4K 32\" IPS, 144Hz, 1ms, G-SYNC Compatible",
category: "Electrónicos",
image: "https://images.unsplash.com/photo-1527443224154-c4a3942d3acf?auto=format&fit=crop&w=800",
rating: {
rate: 4.7,
count: 543
}
}
];
// Función para cargar productos a Firestore
async function loadProductsToFirestore() {
try {
for (const product of products) {
const docRef = await addDoc(collection(db, "products"), product);
console.log("Producto añadido con ID: ", docRef.id);
}
console.log("Todos los productos han sido cargados exitosamente");
} catch (error) {
console.error("Error al cargar los productos: ", error);
}
}
// Ejecutar la función
loadProductsToFirestore();