Skip to content

Commit

Permalink
add update starter code
Browse files Browse the repository at this point in the history
  • Loading branch information
pwjablonski committed Nov 29, 2018
1 parent 672745a commit 87f958c
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 28 deletions.
18 changes: 10 additions & 8 deletions src/clients/firebase.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ const loadDatabase = buildFirebase();

function buildFirebase() {
const app = firebase.initializeApp({
apiKey: "AIzaSyCpc1noPpADSu0vm5AYdUmNSnjEUMt5ZQI",
authDomain: "studio2-331cf.firebaseapp.com",
databaseURL: "https://studio2-331cf.firebaseio.com",
projectId: "studio2-331cf",
storageBucket: "studio2-331cf.appspot.com",
messagingSenderId: "1016551157105"
apiKey: "AIzaSyADAYC7lX5QVEspv8BUeV2uDqrFle8yQpk",
authDomain: "studio-trivia-db.firebaseapp.com",
databaseURL: "https://studio-trivia-db.firebaseio.com",
projectId: "studio-trivia-db",
storageBucket: "studio-trivia-db.appspot.com",
messagingSenderId: "736024037811"
});

return once(async() => {
Expand All @@ -21,11 +21,13 @@ function buildFirebase() {
export async function getQuestions() {
const database = await loadDatabase();
const questions = await database.ref('/questions').once('value');
console.log(questions.val());
return questions.val();
}

export async function getRandomQuestion() {
const questions = await getQuestions();
const randomIndex = Math.floor(Math.random() * questions.length);
return questions[randomIndex];
var keys = Object.keys(questions)
const randomIndex = Math.floor(Math.random() * keys.length);
return questions[keys[randomIndex]];
}
10 changes: 7 additions & 3 deletions src/components/App.jsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,21 @@
import React, { Component } from 'react';
import '../css/App.css';
// import the question display component
// import components

class App extends Component {
// add your constructor
constructor(props) {
super(props);
this.state = {

};
}

render() {
return (
<div className="app">
Kahoot!
{/* Add your question display component */}

</div>
);
}
Expand Down
40 changes: 40 additions & 0 deletions src/components/Question.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import React, { Component } from 'react';
// import components

class Question extends Component {

render() {
return (
<div className="question">
Question Display
{/* Add QuestionStem */}
{/* Add Reset Button */}
<div className="buttons">
{/* Add Buttons */}
</div>
</div>
);
}
}

export default Question;




// import React from 'react';
// // import your components here


// export default function Question() {
// return (
// <div className="question">
// Question Display
// {/* Add QuestionStem */}
// {/* Add Reset Button */}
// <div className="buttons">
// {/* Add Buttons */}
// </div>
// </div>
// );
// }
16 changes: 0 additions & 16 deletions src/components/QuestionDisplay.jsx

This file was deleted.

2 changes: 1 addition & 1 deletion src/css/App.css
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ code {
text-align: center;
}

.questionDisplay {
.question {
background-color: purple;
min-height: 100vh;
display: flex;
Expand Down

0 comments on commit 87f958c

Please sign in to comment.