관리자 페이지

상품 목록

body { font-family: Arial, sans-serif; margin: 0; padding: 0; background-color: #f4f4f4; } header { background-color: #333; color: white; padding: 10px 20px; } header h1 { margin: 0; } main { padding: 20px; } section { background: white; padding: 15px; border-radius: 8px; } // Firebase 설정 const firebaseConfig = { apiKey: "YOUR_API_KEY", authDomain: "YOUR_AUTH_DOMAIN", projectId: "YOUR_PROJECT_ID", storageBucket: "YOUR_STORAGE_BUCKET", messagingSenderId: "YOUR_MESSAGING_SENDER_ID", appId: "YOUR_APP_ID" }; firebase.initializeApp(firebaseConfig); const db = firebase.firestore(); // 실시간 상품 목록 db.collection("items").orderBy("createdAt", "desc") .onSnapshot((snapshot) => { const container = document.getElementById("admin-items-container"); container.innerHTML = ""; snapshot.forEach((doc) => { const item = doc.data(); const li = document.createElement("li"); li.innerHTML = ` ${item.title} - ${item.price}원 [${item.category}] `; container.appendChild(li); }); }); // 상품 삭제 function deleteItem(id) { db.collection("items").doc(id).delete() .then(() => { alert("상품이 삭제되었습니다."); }) .catch((error) => { console.error(error); alert("삭제 실패"); }); }