- Removed obsolete PDF file from the mock directory. - Updated index.html to change the favicon and title for the application. - Deleted unused vite.svg file and replaced it with shapes.svg. - Enhanced App component layout and styling. - Refined Form1 component with better spacing and updated styles. - Improved Form2 component to enhance item selection UI and responsiveness. - Updated Form4 component to improve loan display and interaction. - Enhanced Header component styling for better visibility. - Refined LoginForm component for a more modern look. - Updated Object component styles for better text visibility. - Improved Sidebar component layout and item display. - Updated global CSS for better touch target improvements. - Enhanced Layout component for better responsiveness and structure. - Updated main.tsx to change toast notification theme. - Updated tailwind.config.js to include index.html for Tailwind CSS processing.
52 lines
1.4 KiB
TypeScript
52 lines
1.4 KiB
TypeScript
import "./App.css";
|
|
import Layout from "./layout/Layout";
|
|
import { useEffect, useState } from "react";
|
|
import Form1 from "./components/Form1";
|
|
import Form2 from "./components/Form2";
|
|
import Form4 from "./components/Form4";
|
|
import LoginForm from "./components/LoginForm";
|
|
import Cookies from "js-cookie";
|
|
import { fetchAllData, ALL_ITEMS_UPDATED_EVENT } from "./utils/fetchData";
|
|
import { myToast } from "./utils/toastify";
|
|
|
|
function App() {
|
|
const [isLoggedIn, setIsLoggedIn] = useState(false);
|
|
|
|
useEffect(() => {
|
|
const token = Cookies.get("token");
|
|
if (token) {
|
|
setIsLoggedIn(true);
|
|
fetchAllData(token);
|
|
}
|
|
|
|
localStorage.setItem("borrowableItems", JSON.stringify([]));
|
|
}, []);
|
|
|
|
const handleLogout = () => {
|
|
Cookies.remove("token");
|
|
localStorage.removeItem("allItems");
|
|
localStorage.removeItem("allLoans");
|
|
localStorage.removeItem("userLoans");
|
|
localStorage.removeItem("borrowableItems");
|
|
window.dispatchEvent(new Event(ALL_ITEMS_UPDATED_EVENT));
|
|
myToast("Logged out successfully!", "success");
|
|
setIsLoggedIn(false);
|
|
};
|
|
|
|
return isLoggedIn ? (
|
|
<Layout onLogout={handleLogout}>
|
|
<div className="space-y-6">
|
|
<Form1 />
|
|
<div className="h-px bg-slate-200" />
|
|
<Form2 />
|
|
<div className="h-px bg-slate-200" />
|
|
<Form4 />
|
|
</div>
|
|
</Layout>
|
|
) : (
|
|
<LoginForm onLogin={() => setIsLoggedIn(true)} />
|
|
);
|
|
}
|
|
|
|
export default App;
|