diff --git a/package-lock.json b/package-lock.json index 00f169e..f9cac62 100644 --- a/package-lock.json +++ b/package-lock.json @@ -15434,22 +15434,6 @@ } } }, - "node_modules/tailwindcss/node_modules/yaml": { - "version": "2.8.3", - "resolved": "https://registry.npmjs.org/yaml/-/yaml-2.8.3.tgz", - "integrity": "sha512-AvbaCLOO2Otw/lW5bmh9d/WEdcDFdQp2Z2ZUH3pX9U2ihyUY0nvLv7J6TrWowklRGPYbB/IuIMfYgxaCPg5Bpg==", - "extraneous": true, - "license": "ISC", - "bin": { - "yaml": "bin.mjs" - }, - "engines": { - "node": ">= 14.6" - }, - "funding": { - "url": "https://github.com/sponsors/eemeli" - } - }, "node_modules/tapable": { "version": "2.3.0", "resolved": "https://registry.npmjs.org/tapable/-/tapable-2.3.0.tgz", @@ -15938,9 +15922,9 @@ } }, "node_modules/typescript": { - "version": "5.9.3", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.9.3.tgz", - "integrity": "sha512-jl1vZzPDinLr9eUt3J/t7V6FgNEw9QjvBPdysz9KfQDD41fQrC2Y4vKQdiaUpFT4bXlb1RHhLpp8wtm6M5TgSw==", + "version": "4.9.5", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.9.5.tgz", + "integrity": "sha512-1FXk9E2Hm+QzZQ7z+McJiHL4NW1F2EzMu9Nq9i3zAaGqibafqYwCVU6WyWAuyQRRzOlxou8xZSyXLEN8oKj24g==", "license": "Apache-2.0", "peer": true, "bin": { @@ -15948,7 +15932,7 @@ "tsserver": "bin/tsserver" }, "engines": { - "node": ">=14.17" + "node": ">=4.2.0" } }, "node_modules/unbox-primitive": { diff --git a/src/App.css b/src/App.css index 50cda4c..af2ee2f 100644 --- a/src/App.css +++ b/src/App.css @@ -6,7 +6,7 @@ .main-content { flex: 1; - padding: 20px; + padding: 24px 20px; max-width: 1200px; margin: 0 auto; width: 100%; diff --git a/src/App.js b/src/App.js index 3adbaae..6be7935 100644 --- a/src/App.js +++ b/src/App.js @@ -1,19 +1,36 @@ import React, { useState } from 'react'; import './App.css'; +import { AuthProvider, useAuth } from './contexts/AuthContext'; import Header from './components/Header'; import Navigation from './components/Navigation'; +import Login from './pages/Login'; import Home from './pages/Home'; import Kids from './pages/Kids'; import Advanced from './pages/Advanced'; import SkillTest from './pages/SkillTest'; import FindTutor from './pages/FindTutor'; import Resources from './pages/Resources'; +import Admin from './pages/Admin'; -function App() { +function AppContent() { + const { user, loading } = useAuth(); const [currentPage, setCurrentPage] = useState('home'); + if (loading) { + return ( +
+
+

Učitavanje...

+
+ ); + } + + if (!user) { + return ; + } + const renderPage = () => { - switch(currentPage) { + switch (currentPage) { case 'home': return ; case 'kids': @@ -26,6 +43,8 @@ function App() { return ; case 'resources': return ; + case 'admin': + return user.role === 'admin' ? : ; default: return ; } @@ -33,7 +52,7 @@ function App() { return (
-
setCurrentPage('find-tutor')} /> +
setCurrentPage('find-tutor')} currentPage={currentPage} setCurrentPage={setCurrentPage} />
{renderPage()} @@ -42,4 +61,12 @@ function App() { ); } +function App() { + return ( + + + + ); +} + export default App; \ No newline at end of file diff --git a/src/components/Header.js b/src/components/Header.js index cf988ad..7f17ef4 100644 --- a/src/components/Header.js +++ b/src/components/Header.js @@ -1,16 +1,65 @@ -import React from 'react'; +import React, { useState } from 'react'; +import { useAuth } from '../contexts/AuthContext'; + +function Header({ onFindTutor, currentPage, setCurrentPage }) { + const { user, logout } = useAuth(); + const [menuOpen, setMenuOpen] = useState(false); -function Header({ onFindTutor }) { return ( -
-

🇩🇪 Blebetalo

-

Platforma za učenje nemačkog jezika na srpskom

- +
+
+ 🇩🇪 +
+ Blebetalo + Učenje nemačkog na srpskom +
+
+ +
+ + +
+ + + {menuOpen && ( +
+
+ {user?.name} + {user?.role === 'admin' ? '👑 Administrator' : '👤 Korisnik'} +
+ {user?.role === 'admin' && ( + + )} + +
+ )} +
+
); } diff --git a/src/components/Navigation.js b/src/components/Navigation.js index bbec25c..f9b6745 100644 --- a/src/components/Navigation.js +++ b/src/components/Navigation.js @@ -1,32 +1,31 @@ import React from 'react'; +import { useAuth } from '../contexts/AuthContext'; const navItems = [ - { id: 'home', label: '🏠 Početna' }, - { id: 'kids', label: '👦 Za Decu' }, - { id: 'advanced', label: '🎓 Napredni' }, - { id: 'skill-test', label: '📝 Test Znanja' }, - { id: 'find-tutor', label: '👨‍🏫 Tutor' }, - { id: 'resources', label: '📖 Resursi' }, + { id: 'home', label: '🏠', text: 'Početna' }, + { id: 'kids', label: '👦', text: 'Za Decu' }, + { id: 'advanced', label: '🎓', text: 'Napredni' }, + { id: 'skill-test', label: '📝', text: 'Test Znanja' }, + { id: 'find-tutor', label: '👨‍🏫', text: 'Tutori' }, + { id: 'resources', label: '📖', text: 'Resursi' }, ]; function Navigation({ currentPage, setCurrentPage }) { + const { user } = useAuth(); + const items = user?.role === 'admin' + ? [...navItems, { id: 'admin', label: '⚙️', text: 'Admin' }] + : navItems; + return ( -