-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlisting-create.js
More file actions
30 lines (23 loc) · 1.06 KB
/
listing-create.js
File metadata and controls
30 lines (23 loc) · 1.06 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
import { notificationController } from "./notification/notification-controller.js";
import { listingCreationController } from "./listing-creation/listing-creation-controller.js";
const notificationList = document.querySelector(".notification-list");
const listingCreation = document.querySelector("#listing-creation-form");
const { showNotification } = notificationController(notificationList);
listingCreation.addEventListener("create-listing-notification", (event) => {
showNotification(event.detail.message, event.detail.type);
event.stopPropagation();
});
document.addEventListener("DOMContentLoaded", () => {
const token = localStorage.getItem("token");
if (!token) {
showNotification("Necesitas estar registrado y autenticado como usuario para crear un anuncio", "error");
listingCreation.classList.add("hidden");
setTimeout(() => {
window.location.href = "index.html";
}, 3000);
}
listingCreationController(listingCreation);
});
window.addEventListener("offline", () => {
showNotification("Has perdido la conexión!", "error");
});