Skip to content

Commit

Permalink
add admin p2
Browse files Browse the repository at this point in the history
  • Loading branch information
Aweiro committed Nov 1, 2024
1 parent 6ee069e commit 5c90bc9
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
3 changes: 2 additions & 1 deletion js/firebase.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,6 @@ const firebaseConfig = {
// Ініціалізація Firebase
const app = initializeApp(firebaseConfig);
const storage = getStorage(app);
const db = getFirestore(app);

export { storage };
export { storage, db };
18 changes: 9 additions & 9 deletions js/photocard.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { initializeApp } from 'https://www.gstatic.com/firebasejs/9.6.1/firebase-app.js';
import { getStorage, ref, uploadBytes, getDownloadURL } from 'https://www.gstatic.com/firebasejs/9.6.1/firebase-storage.js';
import { getFirestore, collection, addDoc } from 'https://www.gstatic.com/firebasejs/9.6.1/firebase-firestore.js';
// import { initializeApp } from 'https://www.gstatic.com/firebasejs/9.6.1/firebase-app.js';
// import { getStorage, ref, uploadBytes, getDownloadURL } from 'https://www.gstatic.com/firebasejs/9.6.1/firebase-storage.js';
// import { getFirestore, collection, addDoc } from 'https://www.gstatic.com/firebasejs/9.6.1/firebase-firestore.js';
import { storage } from './firebase.js';


Expand Down Expand Up @@ -166,22 +166,21 @@ document.getElementById('uploadForm').addEventListener('submit', async function

// Завантаження фотографій
function loadPhotos() {
const requestUrl = `${baseUrl}/photos`;
console.log(`Fetching photos from: ${requestUrl}`);

fetch(requestUrl)
console.log("Завантаження фотографій...");
fetch(`${baseUrl}/photos`)
.then(response => {
if (!response.ok) {
console.error('Відповідь мережі не була нормальною:', response);
throw new Error('Network response was not ok');
}
return response.json();
})
.then(photos => {
console.log('Отримані фотографії:', photos);
const photosContainer = document.getElementById('photosContainer');
photosContainer.innerHTML = ''; // Очищаємо контейнер перед додаванням нових фото
photos.forEach(photo => {
console.log('Фото:', photo);

const photoCard = document.createElement('div');
photoCard.className = 'photo-card';

Expand Down Expand Up @@ -210,7 +209,7 @@ function loadPhotos() {
const deleteButton = document.createElement('button');
deleteButton.innerText = 'Видалити';
deleteButton.className = 'card-delete-button button';
deleteButton.onclick = () => deletePhoto(photo.id);
deleteButton.onclick = () => deletePhoto(photo.id); // Замініть на правильний ідентифікатор

imgWrapper.appendChild(img);
photoBody.appendChild(description);
Expand All @@ -227,6 +226,7 @@ function loadPhotos() {




// Видалення фотографії
function deletePhoto(photoId) {
fetch(`${baseUrl}/photos/${photoId}`, {
Expand Down

0 comments on commit 5c90bc9

Please sign in to comment.