Fixes and change of Firebase API KEY

This commit is contained in:
2022-03-02 19:02:49 -03:00
parent 77d81c5cd2
commit 9cb74858e0
14 changed files with 48 additions and 73 deletions

1
.env
View File

@@ -1 +0,0 @@
SKIP_PREFLIGHT_CHECK=true

6
.gitignore vendored
View File

@@ -22,9 +22,11 @@ npm-debug.log*
yarn-debug.log*
yarn-error.log*
/src/Firebase/Firebase_Config.js
/public/Hover.css/css
# /src/Firebase/Firebase_Config.js
# /public/Hover.css/css
/package-lock.json
/package-lock.json.save
/package-lock.json.save.1
/.env

View File

@@ -7,7 +7,7 @@
"@testing-library/react": "^11.2.7",
"@testing-library/user-event": "^12.8.3",
"emailjs-com": "^3.2.0",
"firebase": "^9.1.3",
"firebase": "^9.6.7",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"react-router-dom": "^5.3.0",

View File

@@ -1,16 +1,15 @@
import {firestore} from '../Firebase/Firebase_Config'
import { getFirestore, collection, doc, getDocs, getDoc } from 'firebase/firestore/lite';
import { getFirestore, collection, doc, getDocs, getDoc } from 'firebase/firestore';
import GetRandomCategory from './GetRandomCategory';
import SelectRandomWord from './SelectRandomWord';
const BringTheWords = async (language = 'english', category = false, selectedWord) => {
const BringTheWords = async (language, category, selectedWord) => {
if (!selectedWord) {
if (!category || category === 'false') {
category = await GetRandomCategory(language)
}
try {
@@ -26,6 +25,7 @@ const BringTheWords = async (language = 'english', category = false, selectedWor
return await word
} catch (error) {
console.log(error)
}
}
}

View File

@@ -22,6 +22,7 @@ const GetRandomCategory = async (language) => {
return categoriesList[randomNumber].toLowerCase()
} catch (error) {
console.log(error)
}
}

View File

@@ -0,0 +1,19 @@
// Import the functions you need from the SDKs you need
import { initializeApp } from "firebase/app";
// TODO: Add SDKs for Firebase products that you want to use
// https://firebase.google.com/docs/web/setup#available-libraries
// Your web app's Firebase configuration
const firebaseConfig = {
apiKey: process.env.REACT_APP_FIREBASE_API_KEY,
authDomain: "hangman-game-with-react.firebaseapp.com",
projectId: "hangman-game-with-react",
storageBucket: "hangman-game-with-react.appspot.com",
messagingSenderId: "836415057159",
appId: process.env.REACT_APP_FIREBASE_APP_ID
};
// Initialize Firebase
const firestore = initializeApp(firebaseConfig);
export {firestore}

View File

@@ -1,16 +1,15 @@
export const RecoveryCurrentCategory = (setCategory) => {
if (localStorage.getItem('category')) {
if (localStorage.getItem('category')) {
const category = localStorage.getItem('category')
const category = localStorage.getItem('category')
setCategory(category)
localStorage.removeItem('category')
setCategory(category)
localStorage.removeItem('category')
if (localStorage.getItem('category') === 'false') {
if (localStorage.getItem('category') === 'false') {
//setCategory(false)
}
}
//setCategory(false)
}
}
}

View File

@@ -1,8 +1,10 @@
export const RecoveryCurrentLanguage = (setLanguage) => {
if (localStorage.getItem('language')) {
if (localStorage.getItem('language')) {
setLanguage(localStorage.getItem('language'))
localStorage.removeItem('language')
}
setLanguage(localStorage.getItem('language'))
localStorage.removeItem('language')
return
}
}

View File

@@ -96,8 +96,6 @@ const AddWord = () => {
splitedWords = splitedWords.map(word => word.toLowerCase())
splitedWords = splitedWords.map(word => capitalize(word))
console.log(categoryForDatabase);
const uploadWordsPromise = new Promise((resolve, reject) => {
splitedWords.forEach(async (word, index) => {

View File

@@ -12,7 +12,6 @@ const getCategoryForDatabase = async (categorySelection, LanguageSelection) => {
const categoryLocalizated = categoryFirebase.data()[LanguageSelection]
return await categoryLocalizated
console.log(categoryLocalizated)
} catch (error) {

View File

@@ -6,39 +6,6 @@ const DeleteCategoryFirebase = async (category, setData) => {
try {
const db = getFirestore(firestore)
// const categoryEnglishRef = await doc(db, 'categories', category)
// const categoryEnglishSnap = await getDoc(categoryEnglishRef)
// const categoryEnglish = categoryEnglishSnap.data()['english'].toLowerCase()
// const categorySpanishRef = await doc(db, 'categories', category)
// const categorySpanishSnap = await getDoc(categorySpanishRef)
// const categorySpanish = categorySpanishSnap.data()['spanish'].toLowerCase()
// console.log(categoryEnglish)
// console.log(categorySpanish)
// const collectionWordsCategoryEnglish = await collection(db, `hangman_words/english/${categoryEnglish}`)
// const wordsCategoryEnglishRef = await getDocs(collectionWordsCategoryEnglish)
// const wordsCategoryEnglish = await wordsCategoryEnglishRef.docs
// console.log(wordsCategoryEnglish)
// const deleteWordsCategoryEnglishPromise = new Promise((resolve, reject) => {
// wordsCategoryEnglish.forEach(async (documentInCategory, index) => {
// console.log(await documentInCategory.id)
// await deleteDoc(doc(db, `hangman_words/english/${categoryEnglish}`, documentInCategory.id))
// if (index === wordsCategoryEnglish.length -1) resolve();
// })
// })
// deleteWordsCategoryEnglishPromise.then(() => {
// deleteDoc(doc(db, `hangman_words/english/`, categoryEnglish))
// })
await deleteDoc(doc(db, 'categories', category))
} catch (error) {

View File

@@ -65,10 +65,10 @@ function Game() {
setSelectedWord('a')
let word = await BringTheWords(language, category, selectedWord)
word = word.toLowerCase()
word = word.toLowerCase()
await setSelectedWord(word)
await setDisplayApp(true)
setSelectedWord(word)
setDisplayApp(true)
}
}
@@ -172,7 +172,7 @@ function Game() {
AlmacenateLanguage(language)
window.location.reload(false)
}, 3000)
}, 3000)
}
return (

View File

@@ -3,8 +3,6 @@ import {getFirestore, collection, doc, setDoc } from "firebase/firestore/lite";
const AddPokemonToFirebaseQuery = async (language, pokemon) => {
console.log(pokemon)
console.log(language)
try {
const db = await getFirestore(firestore)
const result = await setDoc(doc(db, `hangman_words/${language}/pokemons`, pokemon.name), {

View File

@@ -10,7 +10,6 @@ const PokemonScripts = () => {
const response = await fetch('https://pokeapi.co/api/v2/pokemon?limit=151')
const pokemons = await response.json()
console.log(pokemons)
const uploadWordsPromise = new Promise((resolve, reject) => {
@@ -24,14 +23,6 @@ const PokemonScripts = () => {
await uploadWordsPromise.then(() => {})
// await pokemons.results.forEach(async (pokemon) => {
// console.log(pokemon.name)
// await AddPokemonToFirebaseQuery('english', pokemon)
// });
console.log(pokemons.results.length)
} catch (error) {
}