-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
SerafimNikalayeu
committed
Dec 26, 2023
1 parent
77fbe38
commit fb92b07
Showing
6 changed files
with
63 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
const firebaseConfig = { | ||
apiKey: "AIzaSyCRpHkB3tswbonEIcVHBtJbPIb385uU3G0", | ||
authDomain: "iksha-country-club.firebaseapp.com", | ||
databaseURL: "https://iksha-country-club-default-rtdb.europe-west1.firebasedatabase.app", | ||
projectId: "iksha-country-club", | ||
storageBucket: "iksha-country-club.appspot.com", | ||
messagingSenderId: "149220009714", | ||
appId: "1:149220009714:web:c751f9e8ab961a9e10d26b" | ||
} | ||
|
||
export default firebaseConfig; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import firebaseConfig from './firebase-config.js'; | ||
import {initializeApp} from 'firebase/app'; | ||
import { getDatabase, ref, get } from 'firebase/database'; | ||
|
||
const app = initializeApp(firebaseConfig); | ||
|
||
export const db = getDatabase(app); | ||
|
||
export const fetchData = async (groupID, setState) => { | ||
try { | ||
const groupsRef = ref(db, 'groups'); | ||
const snapshot = await get(groupsRef); | ||
|
||
if (snapshot.exists()) { | ||
|
||
snapshot.forEach((childSnapshot) => { | ||
const childData = childSnapshot.val(); | ||
if (childData.groupId === groupID) { | ||
setState(childData.substt); | ||
} | ||
}); | ||
} else { | ||
console.log('Группа с указанным groupID не найдена.'); | ||
} | ||
} catch (error) { | ||
console.error('Ошибка при получении данных из Firebase:', error); | ||
} | ||
}; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters