From 126468fa1d8f0c51f32fad05596631101d73301a Mon Sep 17 00:00:00 2001 From: CorinaAdnana Date: Sat, 19 Nov 2022 08:06:47 +0000 Subject: [PATCH 1/9] Update App.jsx --- src/App.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/App.jsx b/src/App.jsx index 84162ae..7716c2b 100644 --- a/src/App.jsx +++ b/src/App.jsx @@ -5,7 +5,7 @@ function App() { <>
-

Welcome to the JSHeroes Bootcamp!

+

Welcome, Corina to the JSHeroes Bootcamp!

From 62eb8b63b5d03b30920f833b048abaf364392b52 Mon Sep 17 00:00:00 2001 From: CorinaAdnana Date: Sat, 19 Nov 2022 09:33:58 +0000 Subject: [PATCH 2/9] Update 4 files --- src/App.jsx | 46 +++++++----------------------------- src/components/card.jsx | 12 ++++++++++ src/components/header.jsx | 10 ++++++++ src/components/searchBar.jsx | 8 +++++++ 4 files changed, 38 insertions(+), 38 deletions(-) create mode 100644 src/components/card.jsx create mode 100644 src/components/header.jsx create mode 100644 src/components/searchBar.jsx diff --git a/src/App.jsx b/src/App.jsx index 7716c2b..96f7060 100644 --- a/src/App.jsx +++ b/src/App.jsx @@ -1,48 +1,18 @@ import "./App.css"; +import Header from "./components/header"; +import SearchBar from "./components/searchBar"; +import Card from "./components/card"; function App() { return ( <> -
-
-

Welcome, Corina to the JSHeroes Bootcamp!

-
- -
- +
-
- - -
- +
    -
  • - facebook/react - placeholder description -
    -
    Stars: 500
    -
    Forks: 100
    -
    -
  • - -
  • - vuejs/vue - placeholder description -
    -
    Stars: 500
    -
    Forks: 100
    -
    -
  • - -
  • - sveltejs/svelte - placeholder description -
    -
    Stars: 500
    -
    Forks: 100
    -
    -
  • + + +
diff --git a/src/components/card.jsx b/src/components/card.jsx new file mode 100644 index 0000000..26757b2 --- /dev/null +++ b/src/components/card.jsx @@ -0,0 +1,12 @@ +const Card = () => ( +
  • + facebook/react + placeholder description +
    +
    Stars: 500
    +
    Forks: 100
    +
    +
  • +); + +export default Card; diff --git a/src/components/header.jsx b/src/components/header.jsx new file mode 100644 index 0000000..6fe9a84 --- /dev/null +++ b/src/components/header.jsx @@ -0,0 +1,10 @@ +const Header = () => ( +
    +
    +

    Welcome to the JSHeroes Bootcamp!

    +
    + +
    +); + +export default Header; \ No newline at end of file diff --git a/src/components/searchBar.jsx b/src/components/searchBar.jsx new file mode 100644 index 0000000..bc92e49 --- /dev/null +++ b/src/components/searchBar.jsx @@ -0,0 +1,8 @@ +const SearchBar = () => ( +
    + + +
    +); + +export default SearchBar; From c3ec60e7b4a546f64beed279abff235063958dd1 Mon Sep 17 00:00:00 2001 From: CorinaAdnana Date: Sat, 19 Nov 2022 09:48:48 +0000 Subject: [PATCH 3/9] Update App.jsx --- src/App.jsx | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/App.jsx b/src/App.jsx index 96f7060..ddf1668 100644 --- a/src/App.jsx +++ b/src/App.jsx @@ -3,6 +3,27 @@ import Header from "./components/header"; import SearchBar from "./components/searchBar"; import Card from "./components/card"; +const cards = [ + { + title: "facebook/react", + description: "placeholder description", + stars: 500, + forks: 100, + }, + { + title: "vuejs/vue", + description: "placeholder description", + stars: 500, + forks: 100, + }, + { + title: "sveltejs/svelte", + description: "placeholder description", + stars: 500, + forks: 100, + }, +]; + function App() { return ( <> From 3c7188a8b336fbc167bc12f48a3bbb8acd4b439d Mon Sep 17 00:00:00 2001 From: CorinaAdnana Date: Sat, 19 Nov 2022 10:14:22 +0000 Subject: [PATCH 4/9] Update App.jsx and card.jsx --- src/App.jsx | 20 ++++++++++++++------ src/components/card.jsx | 10 +++++----- 2 files changed, 19 insertions(+), 11 deletions(-) diff --git a/src/App.jsx b/src/App.jsx index ddf1668..589f298 100644 --- a/src/App.jsx +++ b/src/App.jsx @@ -10,7 +10,7 @@ const cards = [ stars: 500, forks: 100, }, - { + { title: "vuejs/vue", description: "placeholder description", stars: 500, @@ -25,16 +25,24 @@ const cards = [ ]; function App() { + let arrayCards = []; + for (let i = 0; i < cards.length; i++) { + arrayCards.push( + + ); + } + return ( <>
    -
      - - - -
    +
      {arrayCards}
    ); diff --git a/src/components/card.jsx b/src/components/card.jsx index 26757b2..45b6280 100644 --- a/src/components/card.jsx +++ b/src/components/card.jsx @@ -1,10 +1,10 @@ -const Card = () => ( +const Card = (props) => (
  • - facebook/react - placeholder description + {props.title} + {props.description}
    -
    Stars: 500
    -
    Forks: 100
    +
    Stars: {props.stars}
    +
    Forks: {props.forks}
  • ); From b6d0e20571aedd35021e502def52311808e71e07 Mon Sep 17 00:00:00 2001 From: CorinaAdnana Date: Sat, 19 Nov 2022 10:23:31 +0000 Subject: [PATCH 5/9] Update App.jsx --- src/App.jsx | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/src/App.jsx b/src/App.jsx index 589f298..029fcd4 100644 --- a/src/App.jsx +++ b/src/App.jsx @@ -25,17 +25,14 @@ const cards = [ ]; function App() { - let arrayCards = []; - for (let i = 0; i < cards.length; i++) { - arrayCards.push( - - ); - } + const arrayCards = cards.map((card) => ( + + )); return ( <> From b68ea37c6a86a19dde611d2cbd0a6b17c98de000 Mon Sep 17 00:00:00 2001 From: CorinaAdnana Date: Sat, 19 Nov 2022 12:28:54 +0000 Subject: [PATCH 6/9] Update App.jsx and searchBar.jsx --- src/App.jsx | 25 ++++++++++++++++++++----- src/components/searchBar.jsx | 24 ++++++++++++++++++------ 2 files changed, 38 insertions(+), 11 deletions(-) diff --git a/src/App.jsx b/src/App.jsx index 029fcd4..2637629 100644 --- a/src/App.jsx +++ b/src/App.jsx @@ -1,4 +1,5 @@ import "./App.css"; +import { useState } from "react"; import Header from "./components/header"; import SearchBar from "./components/searchBar"; import Card from "./components/card"; @@ -12,7 +13,7 @@ const cards = [ }, { title: "vuejs/vue", - description: "placeholder description", + description: "vue vuejs", stars: 500, forks: 100, }, @@ -25,7 +26,8 @@ const cards = [ ]; function App() { - const arrayCards = cards.map((card) => ( + let filterCards = []; + const cardsJSX = filterCards.map((card) => ( )); - + console.log("render"); return ( <>
    - -
      {arrayCards}
    + { + console.log(value); + for (let i = 0; i < cards.length; i++) { + if ( + cards[i].title.includes(value) || + cards[i].description.includes(value) + ) { + filterCards.push(cards[i]); + } + } + console.log(filterCards); + }} + /> +
      {cardsJSX}
    ;
    ); diff --git a/src/components/searchBar.jsx b/src/components/searchBar.jsx index bc92e49..2315233 100644 --- a/src/components/searchBar.jsx +++ b/src/components/searchBar.jsx @@ -1,8 +1,20 @@ -const SearchBar = () => ( -
    - - -
    -); +import { useRef } from "react"; + +const SearchBar = (props) => { + let inputRef = useRef(null); + const handleSearch = (event) => { + event.preventDefault(); + props.onSearch(inputRef.current.value); + }; + + return ( +
    + + +
    + ); +}; export default SearchBar; From 53650ca2d7c63fcc42f4f3e4e18fdbab01a11526 Mon Sep 17 00:00:00 2001 From: CorinaAdnana Date: Sat, 19 Nov 2022 12:52:17 +0000 Subject: [PATCH 7/9] Update App.jsx --- src/App.jsx | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/App.jsx b/src/App.jsx index 2637629..e156ba2 100644 --- a/src/App.jsx +++ b/src/App.jsx @@ -26,7 +26,8 @@ const cards = [ ]; function App() { - let filterCards = []; + const [filterCards, setFilterCards] = useState(cards); + const cardsJSX = filterCards.map((card) => ( )); - console.log("render"); + console.log("render", filterCards); return ( <>
    @@ -43,18 +44,20 @@ function App() { { console.log(value); + const items = []; for (let i = 0; i < cards.length; i++) { if ( cards[i].title.includes(value) || cards[i].description.includes(value) ) { - filterCards.push(cards[i]); + items.push(cards[i]); } } - console.log(filterCards); + console.log(items); + setFilterCards(items); }} /> -
      {cardsJSX}
    ; +
      {cardsJSX}
    ); From 77c342c468ec0be1ce53a7eff85249ff1906de73 Mon Sep 17 00:00:00 2001 From: CorinaAdnana Date: Sat, 19 Nov 2022 13:33:18 +0000 Subject: [PATCH 8/9] Update App.jsx --- src/App.jsx | 57 +++++++++++++++++++++-------------------------------- 1 file changed, 23 insertions(+), 34 deletions(-) diff --git a/src/App.jsx b/src/App.jsx index e156ba2..d655e9e 100644 --- a/src/App.jsx +++ b/src/App.jsx @@ -1,42 +1,33 @@ import "./App.css"; -import { useState } from "react"; +import { useState, useEffect } from "react"; import Header from "./components/header"; import SearchBar from "./components/searchBar"; import Card from "./components/card"; -const cards = [ - { - title: "facebook/react", - description: "placeholder description", - stars: 500, - forks: 100, - }, - { - title: "vuejs/vue", - description: "vue vuejs", - stars: 500, - forks: 100, - }, - { - title: "sveltejs/svelte", - description: "placeholder description", - stars: 500, - forks: 100, - }, -]; - function App() { - const [filterCards, setFilterCards] = useState(cards); + const [filterCards, setFilterCards] = useState([]); const cardsJSX = filterCards.map((card) => ( )); - console.log("render", filterCards); + + useEffect(() => { + fetch("https://api.github.com/search/repositories?q=stars:>10000", { + headers: { + Authorization: "Bearer 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", + }, + }) + .then((response) => response.json()) + .then((data) => { + console.log(data); + setFilterCards(data.items); + }); + }, []); return ( <>
    @@ -45,14 +36,12 @@ function App() { onSearch={(value) => { console.log(value); const items = []; - for (let i = 0; i < cards.length; i++) { - if ( - cards[i].title.includes(value) || - cards[i].description.includes(value) - ) { - items.push(cards[i]); - } - } + fetch(`https://api.github.com/search/repositories?q=${value}`) + .then((response) => response.json()) + .then((data) => { + console.log(data); + setFilterCards(data.items); + }); console.log(items); setFilterCards(items); }} From c155040473741c0742bb74597c151b5b92383c27 Mon Sep 17 00:00:00 2001 From: Corina Morar Date: Tue, 10 Jan 2023 00:11:56 +0200 Subject: [PATCH 9/9] Add authorization token without expiration --- src/App.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/App.jsx b/src/App.jsx index d655e9e..907e52e 100644 --- a/src/App.jsx +++ b/src/App.jsx @@ -19,7 +19,7 @@ function App() { useEffect(() => { fetch("https://api.github.com/search/repositories?q=stars:>10000", { headers: { - Authorization: "Bearer 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", + Authorization: "Bearer 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", }, }) .then((response) => response.json())