From 3108882fd50308ed1e3d0a587ce2709aa12a6d9e Mon Sep 17 00:00:00 2001 From: realtradam Date: Sat, 27 Apr 2024 21:18:00 -0400 Subject: tailwind and auth tweaks --- app/javascript/application.js | 2 +- app/javascript/components/Home.jsx | 2 +- app/javascript/components/Layout.jsx | 56 ++++++++++++++++++++++++++++++++++++ app/javascript/routes/index.jsx | 16 +++++++---- 4 files changed, 68 insertions(+), 8 deletions(-) create mode 100644 app/javascript/components/Layout.jsx (limited to 'app/javascript') diff --git a/app/javascript/application.js b/app/javascript/application.js index 85b9adf..d635261 100644 --- a/app/javascript/application.js +++ b/app/javascript/application.js @@ -1,5 +1,5 @@ // Entry point for the build script in your package.json import "@hotwired/turbo-rails" import "./controllers" -import * as bootstrap from "bootstrap" +//import * as bootstrap from "bootstrap" import "./components" diff --git a/app/javascript/components/Home.jsx b/app/javascript/components/Home.jsx index 563ec88..efe3cd5 100644 --- a/app/javascript/components/Home.jsx +++ b/app/javascript/components/Home.jsx @@ -2,7 +2,7 @@ import React from "react"; import { Link } from "react-router-dom"; export default () => ( -
+

Games!

diff --git a/app/javascript/components/Layout.jsx b/app/javascript/components/Layout.jsx new file mode 100644 index 0000000..74568cd --- /dev/null +++ b/app/javascript/components/Layout.jsx @@ -0,0 +1,56 @@ +import React from "react"; +import { Outlet, Link } from "react-router-dom"; + +export default function Layout ({userData}) +{ + //console.log(userData); + //const [userData, setUserData] = useState({ login: "" }); + return ( + <> +
+ + +
+ + ) +}; diff --git a/app/javascript/routes/index.jsx b/app/javascript/routes/index.jsx index be928fc..bc5d541 100644 --- a/app/javascript/routes/index.jsx +++ b/app/javascript/routes/index.jsx @@ -1,26 +1,30 @@ import React, { useState, useEffect } from "react"; -import { BrowserRouter as Router, Routes, Route } from "react-router-dom"; +import { BrowserRouter as Router, Routes, Route, Link } from "react-router-dom"; import Home from "../components/Home"; import Blogs from "../components/Blogs"; +import Layout from "../components/Layout"; export default function index() { const [userData, setUserData] = useState({ login: "" }); const url = "/api/v1/auth/data"; - fetch(url).then((response) => { + useEffect(() => { + fetch(url).then((response) => { if(response.ok) { return response.json(); } throw new Error("Network response was not ok."); - }).then((response) => setUserData(response)); + }).then((response) => setUserData(response));}, []); // get user data here // then pass it in as 'props' into the components return (<> -

{userData.login}

+ {/*

{userData.login}

*/} - } /> - } /> + }> + } /> + } /> + ); -- cgit v1.2.3