From 428413e31e08cd6ac3fb85eba1295a9b0cb00ca9 Mon Sep 17 00:00:00 2001 From: Kanu Kingsley Date: Sat, 8 Nov 2025 16:57:03 +0100 Subject: [PATCH] Add dark and light themes across clients --- orderly/README.md | 71 +++++++ orderly/client/src/App.jsx | 85 ++++---- orderly/client/src/api/api.js | 61 +++++- orderly/client/src/components/Nav.jsx | 51 +++-- orderly/client/src/main.jsx | 11 +- orderly/client/src/pages/AccountsInvoices.jsx | 49 +++-- orderly/client/src/pages/AdminUsers.jsx | 37 +++- orderly/client/src/pages/Profile.jsx | 39 ++-- orderly/client/src/pages/SalesOrders.jsx | 47 +++-- orderly/client/src/styles/app.css | 166 ++++++++++++++++ orderly/client/src/styles/auth.css | 49 +++-- orderly/client/src/styles/theme.css | 58 ++++++ orderly/client/src/theme/ThemeProvider.jsx | 69 +++++++ orderly/client/src/theme/ThemeToggle.jsx | 18 ++ orderly/desktop/.env.example | 2 + orderly/desktop/README.md | 33 ++++ orderly/desktop/electron/main.js | 50 +++++ orderly/desktop/electron/preload.js | 7 + orderly/desktop/eslint.config.js | 29 +++ orderly/desktop/index.html | 13 ++ orderly/desktop/package.json | 68 +++++++ orderly/desktop/public/vite.svg | 1 + orderly/desktop/src/main.jsx | 29 +++ orderly/desktop/vite.config.js | 29 +++ orderly/mobile/.env.example | 2 + orderly/mobile/.gitignore | 9 + orderly/mobile/App.js | 24 +++ orderly/mobile/README.md | 59 ++++++ orderly/mobile/app.config.js | 29 +++ orderly/mobile/babel.config.js | 6 + orderly/mobile/package.json | 31 +++ orderly/mobile/src/api/api.js | 59 ++++++ .../mobile/src/components/LoadingOverlay.jsx | 28 +++ .../src/components/ThemeToggleButton.jsx | 31 +++ orderly/mobile/src/context/AuthContext.js | 171 ++++++++++++++++ orderly/mobile/src/context/ThemeContext.js | 111 +++++++++++ .../mobile/src/navigation/RootNavigator.jsx | 69 +++++++ orderly/mobile/src/screens/AccountsScreen.jsx | 151 ++++++++++++++ .../mobile/src/screens/AdminUsersScreen.jsx | 152 ++++++++++++++ orderly/mobile/src/screens/LoginScreen.jsx | 187 ++++++++++++++++++ orderly/mobile/src/screens/ProfileScreen.jsx | 123 ++++++++++++ orderly/mobile/src/screens/SalesScreen.jsx | 151 ++++++++++++++ 42 files changed, 2330 insertions(+), 135 deletions(-) create mode 100644 orderly/README.md create mode 100644 orderly/client/src/styles/app.css create mode 100644 orderly/client/src/styles/theme.css create mode 100644 orderly/client/src/theme/ThemeProvider.jsx create mode 100644 orderly/client/src/theme/ThemeToggle.jsx create mode 100644 orderly/desktop/.env.example create mode 100644 orderly/desktop/README.md create mode 100644 orderly/desktop/electron/main.js create mode 100644 orderly/desktop/electron/preload.js create mode 100644 orderly/desktop/eslint.config.js create mode 100644 orderly/desktop/index.html create mode 100644 orderly/desktop/package.json create mode 100644 orderly/desktop/public/vite.svg create mode 100644 orderly/desktop/src/main.jsx create mode 100644 orderly/desktop/vite.config.js create mode 100644 orderly/mobile/.env.example create mode 100644 orderly/mobile/.gitignore create mode 100644 orderly/mobile/App.js create mode 100644 orderly/mobile/README.md create mode 100644 orderly/mobile/app.config.js create mode 100644 orderly/mobile/babel.config.js create mode 100644 orderly/mobile/package.json create mode 100644 orderly/mobile/src/api/api.js create mode 100644 orderly/mobile/src/components/LoadingOverlay.jsx create mode 100644 orderly/mobile/src/components/ThemeToggleButton.jsx create mode 100644 orderly/mobile/src/context/AuthContext.js create mode 100644 orderly/mobile/src/context/ThemeContext.js create mode 100644 orderly/mobile/src/navigation/RootNavigator.jsx create mode 100644 orderly/mobile/src/screens/AccountsScreen.jsx create mode 100644 orderly/mobile/src/screens/AdminUsersScreen.jsx create mode 100644 orderly/mobile/src/screens/LoginScreen.jsx create mode 100644 orderly/mobile/src/screens/ProfileScreen.jsx create mode 100644 orderly/mobile/src/screens/SalesScreen.jsx diff --git a/orderly/README.md b/orderly/README.md new file mode 100644 index 0000000..1259293 --- /dev/null +++ b/orderly/README.md @@ -0,0 +1,71 @@ +# Orderly Authentication Demo + +This repository contains a full-stack authentication and authorization playground +built with a Node.js/Express API, MongoDB, and a React client. It now also +includes a cross-platform Electron desktop shell and a React Native (Expo) +mobile app that consume the same endpoints as the web front-end without +duplicating UI logic. + +## Projects + +- `server/` – Express API with JWT auth, refresh tokens, MFA, RBAC, and audit logging. +- `client/` – React + Vite SPA used as the primary reference implementation. +- `desktop/` – Electron + React desktop application targeting Windows, macOS, and Linux. +- `mobile/` – React Native (Expo) client for iOS, Android, and the web. + +## Desktop application + +1. Install dependencies and start the desktop shell in development mode: + + ```bash + cd desktop + npm install + npm run dev + ``` + + The script runs the Vite dev server on port `5173` and launches Electron once + the renderer is ready. + +2. Copy `.env.example` to `.env` and adjust `VITE_API_URL` so the desktop client + can talk to your API server. Packaged builds will fall back to the preload + bridge (`window.orderlyDesktop.apiBaseUrl`). + +3. Build installers for macOS, Windows, and Linux: + + ```bash + npm run build + ``` + + Packages are emitted to `desktop/release/` via `electron-builder` (`dmg`, + `nsis`, `AppImage`, `deb`). + +The renderer reuses the same auth flows and protected routes exported from the +web SPA so both surfaces stay aligned feature-for-feature. + +## Mobile application (React Native / Expo) + +1. Install dependencies and copy the example environment file: + + ```bash + cd mobile + npm install + cp .env.example .env + ``` + + Ensure `EXPO_PUBLIC_API_URL` points at your API server (defaults to + `http://localhost:3000/api`). + +2. Start the Expo dev server: + + ```bash + npm run start + ``` + + Use the Expo interface to launch iOS simulators, Android emulators/devices, + or the web preview. Convenience scripts `npm run ios`, `npm run android`, + and `npm run web` are also available. + +The mobile app mirrors the browser experience: it persists tokens in +`AsyncStorage`, reuses the API client with refresh-token retries, and exposes +profile, accounts, sales, and admin screens gated by the same permissions used +elsewhere in the project. diff --git a/orderly/client/src/App.jsx b/orderly/client/src/App.jsx index 8c94009..ea6e5bb 100644 --- a/orderly/client/src/App.jsx +++ b/orderly/client/src/App.jsx @@ -1,4 +1,4 @@ -import { Route, Routes, Navigate, Link } from "react-router-dom"; +import { Route, Routes, Navigate } from "react-router-dom"; import Login from "./pages/Login.jsx"; import ProtectedRoute from "./auth/ProtectedRoute.jsx"; import Profile from "./pages/Profile.jsx"; @@ -8,52 +8,49 @@ import SalesOrders from "./pages/SalesOrders"; import AdminUsers from './pages/AdminUsers'; import Nav from "./components/Nav.jsx"; - - - function App() { return ( - <> -