From 80033a15dd9d995b7b37da17a88bb51965ca6e02 Mon Sep 17 00:00:00 2001 From: bytesparallel Date: Mon, 13 Dec 2021 21:18:24 -0600 Subject: [PATCH] Homepage content completeexcept for logout button and CSS --- src/components/ApplicationViews.js | 4 ++ src/components/auth/Logout.js | 8 ++- src/components/home/GraphicsBayTrackerHome.js | 56 ++++++++++++++++--- src/components/home/NewsStories.js | 34 ++++++++++- src/components/nav/NavBar.js | 19 ++----- src/components/pricing/GPUDataInterface.js | 25 +++++++++ 6 files changed, 120 insertions(+), 26 deletions(-) diff --git a/src/components/ApplicationViews.js b/src/components/ApplicationViews.js index 12bfc58..b8ebf48 100644 --- a/src/components/ApplicationViews.js +++ b/src/components/ApplicationViews.js @@ -2,6 +2,7 @@ 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 = () => { @@ -18,6 +19,9 @@ export const ApplicationViews = () => { + + + ) } diff --git a/src/components/auth/Logout.js b/src/components/auth/Logout.js index 1a3f6dd..3738f08 100644 --- a/src/components/auth/Logout.js +++ b/src/components/auth/Logout.js @@ -3,11 +3,15 @@ import {useState, useEffect} from "react" import { useHistory } from "react-router-dom" export const Logout = () => { - const [loggedincustomer, setloggedincustomer] = useState(localStorage.graphicsbaytracker_customer) + const [loggedincustomer, setloggedincustomer] = useState(localStorage.getItem("graphicsbaytracker_customer")) + + const setItemFromLocalStorage = () => { + setloggedincustomer() + } return ( <>
- +
) diff --git a/src/components/home/GraphicsBayTrackerHome.js b/src/components/home/GraphicsBayTrackerHome.js index ad4e68d..70358ae 100644 --- a/src/components/home/GraphicsBayTrackerHome.js +++ b/src/components/home/GraphicsBayTrackerHome.js @@ -1,16 +1,54 @@ import React from "react" -import { Route } from "react-router-dom/cjs/react-router-dom.min" -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" export const GraphicsBayTrackerHome = () => { - // const [ keyprices, setkeyprices] = useState({}) - return ( - <> - {/* */} -

Display

+ const [keyprices, fetchkeyprices] = useState([]) + + 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..59a636d 100644 --- a/src/components/nav/NavBar.js +++ b/src/components/nav/NavBar.js @@ -2,44 +2,37 @@ 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 "./NavBar.css" export const NavBar = () => { - const history = useHistory() return (
diff --git a/src/components/pricing/GPUDataInterface.js b/src/components/pricing/GPUDataInterface.js index e69de29..d87dca5 100644 --- a/src/components/pricing/GPUDataInterface.js +++ b/src/components/pricing/GPUDataInterface.js @@ -0,0 +1,25 @@ +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

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