From 9d2e2c223c4bf099e35c43e5101f7814c80189f6 Mon Sep 17 00:00:00 2001 From: ghazall-ag Date: Sun, 30 Nov 2025 21:05:37 +0330 Subject: [PATCH] feat(Issuers): add , edit, delete , toggle ,capability and currencies functionality --- src/App.jsx | 14 + src/components/Navbar.jsx | 17 +- src/components/Sidebar.jsx | 4 +- src/pages/Issuer.jsx | 667 +++++++++++++++++++++++++++++++++++++ src/pages/Roles.jsx | 114 ++++--- src/pages/Users.jsx | 51 +-- src/services/api.js | 1 + src/services/issuerAPI.js | 194 +++++++++++ src/services/usersAPI.js | 10 +- 9 files changed, 1004 insertions(+), 68 deletions(-) create mode 100644 src/pages/Issuer.jsx create mode 100644 src/services/issuerAPI.js diff --git a/src/App.jsx b/src/App.jsx index d9e4a91..1495186 100644 --- a/src/App.jsx +++ b/src/App.jsx @@ -12,6 +12,8 @@ import Roles from './pages/Roles'; import Users from './pages/Users'; import Currency from './pages/Currency'; import Location from './pages/Location'; +import Issuer from './pages/Issuer'; +import { AuthProvider } from './context/AuthContext'; // Protected Route Component const ProtectedRoute = ({ children }) => { @@ -135,6 +137,16 @@ const AppRoutes = () => { } + /> + + + + + + } /> @@ -147,9 +159,11 @@ const AppRoutes = () => { const App = () => { return ( +
+
); }; diff --git a/src/components/Navbar.jsx b/src/components/Navbar.jsx index 175dab2..99dabbd 100644 --- a/src/components/Navbar.jsx +++ b/src/components/Navbar.jsx @@ -2,8 +2,19 @@ import React, { useState } from 'react'; import { Menu, Sun, Moon, User, LogOut, ChevronDown } from 'lucide-react'; import { signOut } from '../services/api'; import { useAuthStore } from '../store/authStore'; +import { useAuth } from '../context/AuthContext'; const Navbar = ({ onSidebarToggle }) => { + let user = null; + try { + const authContext = useAuth(); + user = authContext?.user || null; + } catch (e) { + // useAuth not available, will use localStorage + } + const userData = user || JSON.parse(localStorage.getItem('user') || '{}') || {}; + const userName = userData.name && userData.name !== '...' ? userData.name : (userData.email || '...'); + const userEmail = userData.email || ''; const isLoggedIn = useAuthStore((s) => s.isLoggedIn); const [isDarkMode, setIsDarkMode] = useState(() => { return localStorage.getItem('theme') === 'dark' || @@ -77,7 +88,7 @@ const Navbar = ({ onSidebarToggle }) => { - {isLoggedIn ? 'Admin' : 'Guest'} + {isLoggedIn ? userName : 'Guest'} @@ -87,10 +98,10 @@ const Navbar = ({ onSidebarToggle }) => {

- {isLoggedIn ? 'Admin User' : 'Guest'} + {isLoggedIn ? userName : 'Guest'}

- {isLoggedIn ? 'admin@example.com' : ''} + {isLoggedIn ? userEmail : ''}

+ + + + +
+ ), + }, + ], []); + + // --- مودال اضافه و ویرایش --- + const renderModal = (isOpen, title, onSubmit, formState, setFormState, onClose) => { + if (!isOpen) return null; + return ( + <> +
+
+
+

{title}

+
+
+ + setFormState({ ...formState, name: e.target.value })} + className="w-full p-2 border rounded-lg" + placeholder="Issuer name" + required + /> +
+
+ + setFormState({ ...formState, supportEmail: e.target.value })} + className="w-full p-2 border rounded-lg" + placeholder="support@example.com" + required + /> +
+ {title.includes('Edit') && ( + <> +
+ + +
+
+ + setFormState({ ...formState, postalCode: e.target.value })} + className="w-full p-2 border rounded-lg" + placeholder="Postal code" + /> +
+
+ +