react/src/App.js
2025-02-20 05:58:05 +03:00

87 lines
3.2 KiB
JavaScript

import React, { useEffect, useState } from 'react'
import Header from './components/Header';
import NavLeft from './components/NavLeft';
import ProfileMenuBox from './components/ProfileMenuBox';
import BottomBox from './components/BottomBox';
import Pages from './components/Pages';
import Login from './pages/Login';
import Cookies from 'universal-cookie';
import {FetchPOST} from './middlewares/Fetch';
import MusikBox from './components/MusikBox';
const cookie = new Cookies();
export default function App() {
const [backEnd_URL] = "http://localhost:3001/";
const [title] = useState("Wondanes");
const [description] = useState("Ele Mele Ǩismeti");
const [selectedMenu, setSelectedMenu] = useState("");
const [profile] = useState({
first_name: "Batuhan",
second_name: "Coşkun",
username: "batuhancoskun"
});
const [auth, setAuth] = useState(false);
useEffect(() => {
FetchPOST({
port: 3001,
pathname: "/login/control",
fetchData: {
method: "post",
credentials: 'include',
headers: {
'Accept' : 'application/json',
'Content-Type' : 'application/json'
},
body: JSON.stringify({
token: cookie.get("barbaros-sid")
})
}
}).then(res => setAuth(res.Status === "Success" && true));
},[]);
if(auth === false){
return (
<div>
<Header title={title} description={description} backEnd_URL={backEnd_URL}/>
<div className='flex flex-col h-screen overflow-hidden p-4'>
<div className='flex flex-col h-screen overflow-hidden gap-4'>
<div className='grid grid-cols-5 h-full overflow-hidden gap-4'>
<div className='flex items-center justify-center col-span-5 h-full overflow-y-scroll bg-white rounded-2xl p-4'>
<Login auth={auth} setAuth={setAuth}/>
</div>
</div>
</div>
</div>
</div>
)
}
return (
<div className='flex flex-col h-screen overflow-hidden'>
<Header title={title} description={description} backEnd_URL={backEnd_URL}/>
<div className='flex flex-col h-screen overflow-hidden p-4'>
<div className='flex flex-col h-screen overflow-hidden gap-4'>
<div className='grid grid-cols-5 h-full overflow-hidden gap-4'>
<div className='flex flex-col gap-4'>
<div className='flex bg-white h-full rounded-2xl overflow-hidden'>
<NavLeft selectedMenu={selectedMenu} setSelectedMenu={setSelectedMenu}/>
</div>
</div>
<div className='flex col-span-4 h-full overflow-y-scroll bg-white rounded-2xl p-4'>
<Pages selectedMenu={selectedMenu} setSelectedMenu={setSelectedMenu} profile={profile} auth={auth} setAuth={setAuth}/>
</div>
</div>
<div className='grid grid-cols-5 h-16 gap-4'>
<div className='flex bg-white rounded-2xl overflow-hidden'>
<ProfileMenuBox selectedMenu={selectedMenu} setSelectedMenu={setSelectedMenu} profile={profile}/>
</div>
<div className='flex col-span-4 bg-white rounded-2xl'>
<MusikBox/>
</div>
</div>
</div>
</div>
</div>
);
};