diff --git a/src/components/ApplicationViews.js b/src/components/ApplicationViews.js index 32486ed..f89353c 100644 --- a/src/components/ApplicationViews.js +++ b/src/components/ApplicationViews.js @@ -2,17 +2,24 @@ import React from "react" import { Route } from "react-router-dom" import { GraphicsBayTrackerHome } from "./home/GraphicsBayTrackerHome" import { Profile } from "./profile/Profile" +import { GPUDataInterface } from "./pricing/GPUDataInterface" + export const ApplicationViews = () => { return ( <> - + + - + + + + + ) } diff --git a/src/components/auth/Login.js b/src/components/auth/Login.js index 49538a0..d584ebf 100644 --- a/src/components/auth/Login.js +++ b/src/components/auth/Login.js @@ -42,7 +42,7 @@ const redirectToRegister = () => { } return ( - + <>
User does not exist
@@ -68,13 +68,9 @@ const redirectToRegister = () => { -
-
- - - -
+ + ) } diff --git a/src/components/auth/Logout.js b/src/components/auth/Logout.js index 1a3f6dd..d3229c4 100644 --- a/src/components/auth/Logout.js +++ b/src/components/auth/Logout.js @@ -1,16 +1,25 @@ import React from "react" import {useState, useEffect} from "react" import { useHistory } from "react-router-dom" +import { props } from "react" -export const Logout = () => { - const [loggedincustomer, setloggedincustomer] = useState(localStorage.graphicsbaytracker_customer) - return ( - <> -
- -
- - ) +export const Logout = (props) => { + const [loggedIn, setLoggedIn] = useState(true) + + + + useEffect(() => { + if (localStorage.getItem("graphicsbaytracker_customer") !== "1") { + setLoggedIn(true) + } + }, []); + + const logOutCustomer = () => { + localStorage.removeItem("graphicsbaytracker_customer"); + setLoggedIn(false) + + } + } \ No newline at end of file diff --git a/src/components/home/GraphicsBayTrackerHome.js b/src/components/home/GraphicsBayTrackerHome.js index 9148378..6cdeb24 100644 --- a/src/components/home/GraphicsBayTrackerHome.js +++ b/src/components/home/GraphicsBayTrackerHome.js @@ -1,15 +1,50 @@ import React from "react" -import { useState, useEffect } from "react" -import { NewsStories } from "./NewsStories" +import { Link } from "react-router-dom" +import {Route} from "react-router-dom/cjs/react-router-dom.min" +import {useState,useEffect } from "react" +import {NewsStories} from "./NewsStories" +import { GPUDataInterface } from "../pricing/GPUDataInterface" +import { useHistory } from "react-router-dom/cjs/react-router-dom.min" export const GraphicsBayTrackerHome = () => { - const [ keyprices, setkeyprices] = useState({}) - return ( - <> + const [keyprices, fetchkeyprices] = useState([]) + const history = useHistory() + + useEffect( + () => { + fetch("http://localhost:8088/cardData") + .then(res => res.json()) + .then(fetchkeyprices) + },[]) + + -
- -
- ) + return ( <> + +

GraphicsBay Tracker

+ + {NewsStories()} +
+ + + + ) } \ No newline at end of file diff --git a/src/components/home/NewsStories.js b/src/components/home/NewsStories.js index 18ee440..b94a3f1 100644 --- a/src/components/home/NewsStories.js +++ b/src/components/home/NewsStories.js @@ -1,4 +1,34 @@ - +import { + useEffect, + useState +} from "react" export const NewsStories = () => { - return

This is a news story

+ const [newsstories, setNewsStories] = useState([]) + + + + useEffect( + () => { + fetch("http://localhost:8088/newsstories") + .then(res => res.json()) + .then((data) => { + setNewsStories(data) + }) + }, + [] + ) + + + return ( <> +
{newsstories.map( + (newsOBJ) => { + return

{newsOBJ.storyText}

+ {newsOBJ.link} +
+ } + )} +
+ + + ) } \ No newline at end of file diff --git a/src/components/nav/NavBar.js b/src/components/nav/NavBar.js index 3c1468c..c84527c 100644 --- a/src/components/nav/NavBar.js +++ b/src/components/nav/NavBar.js @@ -1,48 +1,47 @@ import React, { useEffect, useState } from "react" import { Link, useHistory } from "react-router-dom" import { Login } from "../auth/Login" -import { Logout } from "../auth/Logout" + +import { Profile } from "../profile/Profile" +import { GPUDataInterface } from "../pricing/GPUDataInterface" +import { Props } from "react" import "./NavBar.css" -export const NavBar = () => { - const history = useHistory() - +export const NavBar = (props) => { + + + + + return ( + <>
-
+ < li className = "nav-item" > { + + + } + + + + + + + ) } diff --git a/src/components/pricing/GPUDataInterface.js b/src/components/pricing/GPUDataInterface.js index e69de29..af8f2b4 100644 --- a/src/components/pricing/GPUDataInterface.js +++ b/src/components/pricing/GPUDataInterface.js @@ -0,0 +1,31 @@ +import { React } from "react" +import { useState,useEffect } from "react" +import { Link } from "react-router-dom" +export const GPUDataInterface = () => { + const [gpucarddata, fetchgpucarddata] = useState([]) + useEffect( + () => { + fetch("http://localhost:8088/cardData") + .then(res => res.json()) + .then((data) => { + fetchgpucarddata(data) + }) + }, + [] + ) + return ( + <> +

GPUDataInterface

+ + + + + + + + {gpucarddata.map(gpudataobj => {return (

{gpudataobj.brand} {gpudataobj.model} {gpudataobj.price.toLocaleString('en-US', { style: 'currency', currency: 'USD' })}

)})} + +
BrandModelPrice
+ + + )} \ No newline at end of file