From 77415565134a12ca22182670ad92ce9b2774bf22 Mon Sep 17 00:00:00 2001 From: dsbilling Date: Thu, 9 Jan 2025 21:50:52 +0000 Subject: [PATCH 01/19] Update changelog --- CHANGELOG.md | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index d2eb032..e35a96b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,38 +2,76 @@ All notable changes to this project will be documented in this file. +## 3.0.0-alpha.3 - 2025-01-09 + +### Changed + +- **Enhanced GitHub Action Workflow**: + - Updated to use a new environment variable for more flexible management. + - Now handles updates to critical files (`package.json`, `backend/config.py`) that track software versioning. + - Improved automation ensures effective tracking and management of software changes. + +- **Frontend Markdown Component Styling**: + - Slight adjustments to the `ReactMarkdown` component for a more refined display experience. + +- **Styling Adjustments to the Changelog Page**: + - Increased the size of the main title (`CardTitle` component) to improve readability and visual appeal. + + +### Added + +- **Utility Function Simplification**: + - Consolidated date-utilities into `frontend/src/lib/utils.ts` for better organization and maintainability. + + +### Removed + +- **Redundant Files**: + - Deleted the redundant file `frontend/src/lib/date.ts` to eliminate duplications in the codebase. + + +**Full Changelog**: https://github.com/kilobyteno/LANMS/compare/3.0.0-alpha.2...3.0.0-alpha.3 + ## 3.0.0-alpha.2 - 2025-01-02 ### Changed - **Release Workflow Revamped**: + - Trigger for the release procedure updated from `released` to `published`. - Source data reference branch changed from `main` to `develop`. - **API Endpoints Enhanced**: + - Event interest endpoint routes updated from `/{event_id}` to `/events/{event_id}/interests` for improved clarity and coherence. - **Frontend API Calls Altered**: + - Updated paths in `event-interest.ts` to align with the new endpoint structure. - **Frontend Imports Reordered and Formatted**: + - Removed unnecessary import statements from `nav-user.tsx`. - Styled `changelog.tsx` file for consistency. - **Code Readability Enhanced**: + - Minor adjustments to indentation and line formatting across the codebase. ### Added - **New User Interest Feature**: + - Introduced `event_interests` table to capture user preferences related to events. - Ensured foreign key constraints are upheld. - **Healthchecks Implemented**: + - Added healthchecks to Docker Compose files for frontend and backend services. - **Docker Solutions for PostgreSQL**: + - Created Docker and Docker Compose files for PostgreSQL with optimized configurations. From 8a946b6d9998c52859d7b25311e19263d48bab12 Mon Sep 17 00:00:00 2001 From: "Daniel S. Billing" Date: Thu, 9 Jan 2025 23:07:51 +0100 Subject: [PATCH 02/19] Update release.yml --- .github/workflows/release.yml | 33 +++++++-------------------------- 1 file changed, 7 insertions(+), 26 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index bfc3f32..24464f0 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -22,23 +22,11 @@ jobs: npm version ${{ github.event.release.tag_name }} cd .. - - name: Commit updated package.json - uses: stefanzweifel/git-auto-commit-action@v5 - with: - branch: ${{ env.TARGET_BRANCH }} - commit_message: Update version in package.json - file_pattern: package.json - - name: Update version in backend/config.py run: | - sed -i "s/API_DOCS_VERSION = '.*'/API_DOCS_VERSION = '${{ github.event.release.tag_name }}'/g" backend/config.py - - - name: Commit updated backend/config.py - uses: stefanzweifel/git-auto-commit-action@v5 - with: - branch: ${{ env.TARGET_BRANCH }} - commit_message: Update version in backend/config.py - file_pattern: backend/config.py + cd backend + sed -i "s/API_DOCS_VERSION = '.*'/API_DOCS_VERSION = '${{ github.event.release.tag_name }}'/g" config.py + cd .. - name: Update changelog uses: stefanzweifel/changelog-updater-action@v1 @@ -50,17 +38,10 @@ jobs: uses: stefanzweifel/git-auto-commit-action@v5 with: branch: ${{ env.TARGET_BRANCH }} - commit_message: Update changelog - file_pattern: CHANGELOG.md - - - name: Move tag to current commit - run: | - git tag -f ${{ github.event.release.tag_name }} - - - name: Push changes - run: | - git push origin ${{ env.TARGET_BRANCH }} - git push origin ${{ github.event.release.tag_name }} + commit_message: Release version ${{ github.event.release.tag_name }} + file_pattern: 'CHANGELOG.md, frontend/package.json, backend/config.py' + tagging_message: ${{ github.event.release.tag_name }} + push_options: '--force' - name: "Send webhook to Discord" uses: sarisia/actions-status-discord@v1 From bb6cddf624a613589f3eb83cdddb65f95686eb27 Mon Sep 17 00:00:00 2001 From: "Daniel S. Billing" Date: Fri, 10 Jan 2025 11:28:32 +0100 Subject: [PATCH 03/19] Remove file pattern and commit all files changes --- .github/workflows/release.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 24464f0..6067088 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -39,7 +39,6 @@ jobs: with: branch: ${{ env.TARGET_BRANCH }} commit_message: Release version ${{ github.event.release.tag_name }} - file_pattern: 'CHANGELOG.md, frontend/package.json, backend/config.py' tagging_message: ${{ github.event.release.tag_name }} push_options: '--force' From 0418aec6e908071387343a3b50bfcf66f4cbeb94 Mon Sep 17 00:00:00 2001 From: "Daniel S. Billing" Date: Fri, 10 Jan 2025 11:28:57 +0100 Subject: [PATCH 04/19] Comment out browser icon until we have one --- frontend/index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/index.html b/frontend/index.html index c9f9430..a575ca3 100644 --- a/frontend/index.html +++ b/frontend/index.html @@ -2,7 +2,7 @@ - + LANMS From 47a1e9d1ca74f39c91d4dedc4ba90f783be75147 Mon Sep 17 00:00:00 2001 From: "Daniel S. Billing" Date: Fri, 10 Jan 2025 11:58:00 +0100 Subject: [PATCH 05/19] Add backend version to own file --- .github/workflows/release.yml | 2 +- backend/.version | 1 + backend/config.py | 5 +++++ 3 files changed, 7 insertions(+), 1 deletion(-) create mode 100644 backend/.version diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 6067088..45e587f 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -25,7 +25,7 @@ jobs: - name: Update version in backend/config.py run: | cd backend - sed -i "s/API_DOCS_VERSION = '.*'/API_DOCS_VERSION = '${{ github.event.release.tag_name }}'/g" config.py + echo ${{ github.event.release.tag_name }} > .version cd .. - name: Update changelog diff --git a/backend/.version b/backend/.version new file mode 100644 index 0000000..48e942c --- /dev/null +++ b/backend/.version @@ -0,0 +1 @@ +3.0.0-alpha.4 diff --git a/backend/config.py b/backend/config.py index 4cb917e..2781a9c 100644 --- a/backend/config.py +++ b/backend/config.py @@ -114,6 +114,11 @@ class Config: # API Docs API_DOCS_TITLE: str = f'{MICRO_SERVICE_NAME_FOR_HUMANS} API' API_DOCS_VERSION: str = '3.0.0-alpha.1' + try: + with open('.version', 'r') as version_file: + API_DOCS_VERSION: str = version_file.read().strip() + except Exception as e: + logging.error(f'Error reading version file: {e}') API_DOCS_DESCRIPTION: str = f'Endpoints for the {MICRO_SERVICE_NAME_FOR_HUMANS}' API_DOCS_OPENAPI_URL: Optional[str] = None if MICRO_SERVICE_IN_PRODUCTION else '/openapi.json' API_DOCS_URL: str = '/docs' From 1ac2f0f172b77bbd7922252633c4b80210af95b1 Mon Sep 17 00:00:00 2001 From: "Daniel S. Billing" Date: Fri, 10 Jan 2025 11:58:05 +0100 Subject: [PATCH 06/19] Update release.yml --- .github/workflows/release.yml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 45e587f..a74646c 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -39,8 +39,11 @@ jobs: with: branch: ${{ env.TARGET_BRANCH }} commit_message: Release version ${{ github.event.release.tag_name }} - tagging_message: ${{ github.event.release.tag_name }} - push_options: '--force' + + - name: Force move the tag to the current commit + run: | + git tag -fa ${{ github.event.release.tag_name }} + git push --tags - name: "Send webhook to Discord" uses: sarisia/actions-status-discord@v1 From a22a043ba3b8aca98212eb02e4350a478228ee07 Mon Sep 17 00:00:00 2001 From: dsbilling Date: Fri, 10 Jan 2025 10:59:04 +0000 Subject: [PATCH 07/19] Release version 3.0.0-alpha.5 --- CHANGELOG.md | 7 +++++++ backend/.version | 2 +- frontend/package-lock.json | 4 ++-- frontend/package.json | 2 +- 4 files changed, 11 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e35a96b..bc94a16 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,19 +2,26 @@ All notable changes to this project will be documented in this file. +## 3.0.0-alpha.5 - 2025-01-10 + +**Full Changelog**: https://github.com/kilobyteno/LANMS/compare/3.0.0-alpha.4...3.0.0-alpha.5 + ## 3.0.0-alpha.3 - 2025-01-09 ### Changed - **Enhanced GitHub Action Workflow**: + - Updated to use a new environment variable for more flexible management. - Now handles updates to critical files (`package.json`, `backend/config.py`) that track software versioning. - Improved automation ensures effective tracking and management of software changes. - **Frontend Markdown Component Styling**: + - Slight adjustments to the `ReactMarkdown` component for a more refined display experience. - **Styling Adjustments to the Changelog Page**: + - Increased the size of the main title (`CardTitle` component) to improve readability and visual appeal. diff --git a/backend/.version b/backend/.version index 48e942c..9398b07 100644 --- a/backend/.version +++ b/backend/.version @@ -1 +1 @@ -3.0.0-alpha.4 +3.0.0-alpha.5 diff --git a/frontend/package-lock.json b/frontend/package-lock.json index 1d331f4..9542d41 100644 --- a/frontend/package-lock.json +++ b/frontend/package-lock.json @@ -1,12 +1,12 @@ { "name": "lanms-portal", - "version": "3.0.0-alpha.1", + "version": "3.0.0-alpha.5", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "lanms-portal", - "version": "3.0.0-alpha.1", + "version": "3.0.0-alpha.5", "dependencies": { "@hookform/resolvers": "^3.9.1", "@phosphor-icons/react": "^2.0.15", diff --git a/frontend/package.json b/frontend/package.json index 22cc4b4..8f24cc0 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -1,7 +1,7 @@ { "name": "lanms-frontend", "private": true, - "version": "3.0.0-alpha.1", + "version": "3.0.0-alpha.5", "type": "module", "scripts": { "dev": "vite", From b4dd580fdad01727263e8782f51c3680c9d0e705 Mon Sep 17 00:00:00 2001 From: "Daniel S. Billing" Date: Fri, 10 Jan 2025 12:00:36 +0100 Subject: [PATCH 08/19] Update release.yml --- .github/workflows/release.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index a74646c..b5f70b7 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -42,6 +42,8 @@ jobs: - name: Force move the tag to the current commit run: | + git config user.name "github-actions[bot]" + git config user.email "41898282+github-actions[bot]@users.noreply.github.com" git tag -fa ${{ github.event.release.tag_name }} git push --tags From 1e096bb4fd91de57e21baf62eb90963743248289 Mon Sep 17 00:00:00 2001 From: dsbilling Date: Fri, 10 Jan 2025 11:02:15 +0000 Subject: [PATCH 09/19] Release version 3.0.0-alpha.6 --- CHANGELOG.md | 4 ++++ backend/.version | 2 +- frontend/package-lock.json | 4 ++-- frontend/package.json | 2 +- 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index bc94a16..09ef8c2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ All notable changes to this project will be documented in this file. +## 3.0.0-alpha.6 - 2025-01-10 + +**Full Changelog**: https://github.com/kilobyteno/LANMS/compare/3.0.0-alpha.5...3.0.0-alpha.6 + ## 3.0.0-alpha.5 - 2025-01-10 **Full Changelog**: https://github.com/kilobyteno/LANMS/compare/3.0.0-alpha.4...3.0.0-alpha.5 diff --git a/backend/.version b/backend/.version index 9398b07..5b8e82c 100644 --- a/backend/.version +++ b/backend/.version @@ -1 +1 @@ -3.0.0-alpha.5 +3.0.0-alpha.6 diff --git a/frontend/package-lock.json b/frontend/package-lock.json index 9542d41..39d9492 100644 --- a/frontend/package-lock.json +++ b/frontend/package-lock.json @@ -1,12 +1,12 @@ { "name": "lanms-portal", - "version": "3.0.0-alpha.5", + "version": "3.0.0-alpha.6", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "lanms-portal", - "version": "3.0.0-alpha.5", + "version": "3.0.0-alpha.6", "dependencies": { "@hookform/resolvers": "^3.9.1", "@phosphor-icons/react": "^2.0.15", diff --git a/frontend/package.json b/frontend/package.json index 8f24cc0..f32a342 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -1,7 +1,7 @@ { "name": "lanms-frontend", "private": true, - "version": "3.0.0-alpha.5", + "version": "3.0.0-alpha.6", "type": "module", "scripts": { "dev": "vite", From 17d428c61778b01d7a5dc2ebb232bce8819a7916 Mon Sep 17 00:00:00 2001 From: "Daniel S. Billing" Date: Fri, 10 Jan 2025 12:06:12 +0100 Subject: [PATCH 10/19] Update release.yml --- .github/workflows/release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index b5f70b7..4e3093e 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -44,7 +44,7 @@ jobs: run: | git config user.name "github-actions[bot]" git config user.email "41898282+github-actions[bot]@users.noreply.github.com" - git tag -fa ${{ github.event.release.tag_name }} + git tag -fa ${{ github.event.release.tag_name }} -m "Release version ${{ github.event.release.tag_name }}" git push --tags - name: "Send webhook to Discord" From 4783a28cfe26bc4f41ad73a6d0f2f8ad4400a0db Mon Sep 17 00:00:00 2001 From: dsbilling Date: Fri, 10 Jan 2025 11:07:13 +0000 Subject: [PATCH 11/19] Release version 3.0.0-alpha.7 --- CHANGELOG.md | 4 ++++ backend/.version | 2 +- frontend/package-lock.json | 4 ++-- frontend/package.json | 2 +- 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 09ef8c2..6e11c47 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ All notable changes to this project will be documented in this file. +## 3.0.0-alpha.7 - 2025-01-10 + +**Full Changelog**: https://github.com/kilobyteno/LANMS/compare/3.0.0-alpha.6...3.0.0-alpha.7 + ## 3.0.0-alpha.6 - 2025-01-10 **Full Changelog**: https://github.com/kilobyteno/LANMS/compare/3.0.0-alpha.5...3.0.0-alpha.6 diff --git a/backend/.version b/backend/.version index 5b8e82c..536f018 100644 --- a/backend/.version +++ b/backend/.version @@ -1 +1 @@ -3.0.0-alpha.6 +3.0.0-alpha.7 diff --git a/frontend/package-lock.json b/frontend/package-lock.json index 39d9492..80addad 100644 --- a/frontend/package-lock.json +++ b/frontend/package-lock.json @@ -1,12 +1,12 @@ { "name": "lanms-portal", - "version": "3.0.0-alpha.6", + "version": "3.0.0-alpha.7", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "lanms-portal", - "version": "3.0.0-alpha.6", + "version": "3.0.0-alpha.7", "dependencies": { "@hookform/resolvers": "^3.9.1", "@phosphor-icons/react": "^2.0.15", diff --git a/frontend/package.json b/frontend/package.json index f32a342..04d2361 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -1,7 +1,7 @@ { "name": "lanms-frontend", "private": true, - "version": "3.0.0-alpha.6", + "version": "3.0.0-alpha.7", "type": "module", "scripts": { "dev": "vite", From 9892c0676c433f1bb449578b73bfd498baa9d9f1 Mon Sep 17 00:00:00 2001 From: "Daniel S. Billing" Date: Fri, 10 Jan 2025 12:09:07 +0100 Subject: [PATCH 12/19] Update release.yml --- .github/workflows/release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 4e3093e..694d514 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -45,7 +45,7 @@ jobs: git config user.name "github-actions[bot]" git config user.email "41898282+github-actions[bot]@users.noreply.github.com" git tag -fa ${{ github.event.release.tag_name }} -m "Release version ${{ github.event.release.tag_name }}" - git push --tags + git push -f --tags - name: "Send webhook to Discord" uses: sarisia/actions-status-discord@v1 From 7336d3430d8d2e19e8aaf51ffa5772c9d26a805f Mon Sep 17 00:00:00 2001 From: dsbilling Date: Fri, 10 Jan 2025 11:10:35 +0000 Subject: [PATCH 13/19] Release version 3.0.0-alpha.8 --- CHANGELOG.md | 4 ++++ backend/.version | 2 +- frontend/package-lock.json | 4 ++-- frontend/package.json | 2 +- 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6e11c47..c90cacc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ All notable changes to this project will be documented in this file. +## 3.0.0-alpha.8 - 2025-01-10 + +**Full Changelog**: https://github.com/kilobyteno/LANMS/compare/3.0.0-alpha.7...3.0.0-alpha.8 + ## 3.0.0-alpha.7 - 2025-01-10 **Full Changelog**: https://github.com/kilobyteno/LANMS/compare/3.0.0-alpha.6...3.0.0-alpha.7 diff --git a/backend/.version b/backend/.version index 536f018..96bc4d7 100644 --- a/backend/.version +++ b/backend/.version @@ -1 +1 @@ -3.0.0-alpha.7 +3.0.0-alpha.8 diff --git a/frontend/package-lock.json b/frontend/package-lock.json index 80addad..3860431 100644 --- a/frontend/package-lock.json +++ b/frontend/package-lock.json @@ -1,12 +1,12 @@ { "name": "lanms-portal", - "version": "3.0.0-alpha.7", + "version": "3.0.0-alpha.8", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "lanms-portal", - "version": "3.0.0-alpha.7", + "version": "3.0.0-alpha.8", "dependencies": { "@hookform/resolvers": "^3.9.1", "@phosphor-icons/react": "^2.0.15", diff --git a/frontend/package.json b/frontend/package.json index 04d2361..66c9ab0 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -1,7 +1,7 @@ { "name": "lanms-frontend", "private": true, - "version": "3.0.0-alpha.7", + "version": "3.0.0-alpha.8", "type": "module", "scripts": { "dev": "vite", From d35c13253ee13bb4767fe0a7ec9936f79a4bc4c6 Mon Sep 17 00:00:00 2001 From: "Daniel S. Billing" Date: Fri, 10 Jan 2025 12:39:51 +0100 Subject: [PATCH 14/19] Update styling of version checker It was invisible in dark mode --- frontend/src/components/version-checker.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/src/components/version-checker.tsx b/frontend/src/components/version-checker.tsx index 4918c11..2706bbc 100644 --- a/frontend/src/components/version-checker.tsx +++ b/frontend/src/components/version-checker.tsx @@ -39,7 +39,7 @@ export function VersionChecker() { return ( <> - LANMS {CURRENT_VERSION} + LANMS {CURRENT_VERSION} {hasUpdate && ( Date: Fri, 10 Jan 2025 14:13:05 +0100 Subject: [PATCH 15/19] Reworked theme provider --- frontend/src/App.tsx | 4 +- frontend/src/components/nav-theme-switch.tsx | 2 +- frontend/src/components/theme-provider.tsx | 57 ++++++++----- frontend/src/hooks/useTheme.ts | 31 -------- frontend/src/providers/ThemeProvider.tsx | 27 ------- frontend/src/providers/theme-provider.tsx | 84 ++++++++++++++++++++ 6 files changed, 123 insertions(+), 82 deletions(-) delete mode 100644 frontend/src/hooks/useTheme.ts delete mode 100644 frontend/src/providers/ThemeProvider.tsx create mode 100644 frontend/src/providers/theme-provider.tsx diff --git a/frontend/src/App.tsx b/frontend/src/App.tsx index 916e680..06a271d 100644 --- a/frontend/src/App.tsx +++ b/frontend/src/App.tsx @@ -3,11 +3,11 @@ import {AuthProvider} from './context/AuthContext'; import {OrganisationProvider} from './context/OrganisationContext'; import {EventProvider} from './context/EventContext'; import {router} from './routes'; -import {ThemeProvider} from "@/components/theme-provider.tsx"; +import {ThemeProvider} from "@/providers/theme-provider"; function App() { return ( - + diff --git a/frontend/src/components/nav-theme-switch.tsx b/frontend/src/components/nav-theme-switch.tsx index d82985d..19e4a0d 100644 --- a/frontend/src/components/nav-theme-switch.tsx +++ b/frontend/src/components/nav-theme-switch.tsx @@ -5,10 +5,10 @@ import { DropdownMenuItem, DropdownMenuTrigger, } from "@/components/ui/dropdown-menu" -import {useTheme} from "@/components/theme-provider" import {DesktopTower, Moon, Sun} from "@phosphor-icons/react"; import {useTranslation} from "react-i18next"; import {Tooltip, TooltipContent, TooltipProvider, TooltipTrigger} from "@/components/ui/tooltip.tsx"; +import { useTheme } from "@/providers/theme-provider" export function NavThemeSwitch() { const {setTheme, theme} = useTheme() diff --git a/frontend/src/components/theme-provider.tsx b/frontend/src/components/theme-provider.tsx index 1b0adc8..58db6fd 100644 --- a/frontend/src/components/theme-provider.tsx +++ b/frontend/src/components/theme-provider.tsx @@ -1,4 +1,4 @@ -import {createContext, useContext, useEffect, useState} from "react" +import { createContext, useContext, useEffect, useState } from "react" type Theme = "dark" | "light" | "system" @@ -21,38 +21,52 @@ const initialState: ThemeProviderState = { const ThemeProviderContext = createContext(initialState) export function ThemeProvider({ - children, - defaultTheme = "system", - storageKey = "lanms-ui-theme", - ...props - }: ThemeProviderProps) { - const [theme, setTheme] = useState( - () => (localStorage.getItem(storageKey) as Theme) || defaultTheme - ) + children, + defaultTheme = "system", + storageKey = "theme", + ...props +}: ThemeProviderProps) { + const [theme, setTheme] = useState(() => { + const storedTheme = localStorage.getItem(storageKey) as Theme + return storedTheme || defaultTheme + }) useEffect(() => { const root = window.document.documentElement + const mediaQuery = window.matchMedia("(prefers-color-scheme: dark)") + // Remove existing theme classes root.classList.remove("light", "dark") - if (theme === "system") { - const systemTheme = window.matchMedia("(prefers-color-scheme: dark)") - .matches - ? "dark" - : "light" + // Apply theme + const applyTheme = (theme: Theme) => { + if (theme === "system") { + const systemTheme = mediaQuery.matches ? "dark" : "light" + root.classList.add(systemTheme) + } else { + root.classList.add(theme) + } + } + + // Initial theme application + applyTheme(theme) - root.classList.add(systemTheme) - return + // Listen for system theme changes + const handleChange = () => { + if (theme === "system") { + applyTheme("system") + } } - root.classList.add(theme) + mediaQuery.addEventListener("change", handleChange) + return () => mediaQuery.removeEventListener("change", handleChange) }, [theme]) const value = { theme, - setTheme: (theme: Theme) => { - localStorage.setItem(storageKey, theme) - setTheme(theme) + setTheme: (newTheme: Theme) => { + localStorage.setItem(storageKey, newTheme) + setTheme(newTheme) }, } @@ -66,8 +80,9 @@ export function ThemeProvider({ export const useTheme = () => { const context = useContext(ThemeProviderContext) - if (context === undefined) + if (context === undefined) { throw new Error("useTheme must be used within a ThemeProvider") + } return context } diff --git a/frontend/src/hooks/useTheme.ts b/frontend/src/hooks/useTheme.ts deleted file mode 100644 index c9a005a..0000000 --- a/frontend/src/hooks/useTheme.ts +++ /dev/null @@ -1,31 +0,0 @@ -import { useState, useEffect } from 'react'; - -type Theme = 'light' | 'dark'; - -export function useTheme() { - const [theme, setTheme] = useState(() => { - // Check local storage first - const savedTheme = localStorage.getItem('theme') as Theme; - if (savedTheme) return savedTheme; - - // Then check system preference - if (window.matchMedia('(prefers-color-scheme: dark)').matches) { - return 'dark'; - } - - return 'light'; - }); - - useEffect(() => { - const root = window.document.documentElement; - root.classList.remove('light', 'dark'); - root.classList.add(theme); - localStorage.setItem('theme', theme); - }, [theme]); - - const toggleTheme = () => { - setTheme(prev => prev === 'light' ? 'dark' : 'light'); - }; - - return { theme, toggleTheme }; -} \ No newline at end of file diff --git a/frontend/src/providers/ThemeProvider.tsx b/frontend/src/providers/ThemeProvider.tsx deleted file mode 100644 index 13138e5..0000000 --- a/frontend/src/providers/ThemeProvider.tsx +++ /dev/null @@ -1,27 +0,0 @@ -import React, { createContext, useContext } from 'react'; -import { useTheme } from '../hooks/useTheme'; - -interface ThemeContextType { - theme: 'light' | 'dark'; - toggleTheme: () => void; -} - -const ThemeContext = createContext(undefined); - -export function ThemeProvider({ children }: { children: React.ReactNode }) { - const themeValue = useTheme(); - - return ( - - {children} - - ); -} - -export const useThemeContext = () => { - const context = useContext(ThemeContext); - if (context === undefined) { - throw new Error('useThemeContext must be used within a ThemeProvider'); - } - return context; -}; \ No newline at end of file diff --git a/frontend/src/providers/theme-provider.tsx b/frontend/src/providers/theme-provider.tsx new file mode 100644 index 0000000..188d7f7 --- /dev/null +++ b/frontend/src/providers/theme-provider.tsx @@ -0,0 +1,84 @@ +import { createContext, useContext, useEffect, useState } from "react" + +type Theme = "dark" | "light" | "system" + +type ThemeProviderProps = { + children: React.ReactNode + defaultTheme?: Theme + storageKey?: string +} + +type ThemeProviderState = { + theme: Theme + setTheme: (theme: Theme) => void +} + +const initialState: ThemeProviderState = { + theme: "system", + setTheme: () => null, +} + +const ThemeProviderContext = createContext(initialState) + +export function ThemeProvider({ + children, + defaultTheme = "system", + storageKey = "theme", + ...props +}: ThemeProviderProps) { + const [theme, setTheme] = useState(() => { + const storedTheme = localStorage.getItem(storageKey) as Theme + return storedTheme || defaultTheme + }) + + useEffect(() => { + const root = window.document.documentElement + const mediaQuery = window.matchMedia("(prefers-color-scheme: dark)") + + root.classList.remove("light", "dark") + + const applyTheme = (theme: Theme) => { + if (theme === "system") { + const systemTheme = mediaQuery.matches ? "dark" : "light" + root.classList.add(systemTheme) + } else { + root.classList.add(theme) + } + } + + applyTheme(theme) + + const handleChange = () => { + if (theme === "system") { + applyTheme("system") + } + } + + mediaQuery.addEventListener("change", handleChange) + return () => mediaQuery.removeEventListener("change", handleChange) + }, [theme]) + + const value = { + theme, + setTheme: (newTheme: Theme) => { + localStorage.setItem(storageKey, newTheme) + setTheme(newTheme) + }, + } + + return ( + + {children} + + ) +} + +export const useTheme = () => { + const context = useContext(ThemeProviderContext) + + if (context === undefined) { + throw new Error("useTheme must be used within a ThemeProvider") + } + + return context +} \ No newline at end of file From 42d2961660e4ced593e51fa1c660fbba2d3a77dd Mon Sep 17 00:00:00 2001 From: "Daniel S. Billing" Date: Fri, 10 Jan 2025 22:35:29 +0100 Subject: [PATCH 16/19] Improvements to changelog page - Translated text - Add pre-release badge - Adjusted styling for cards --- frontend/src/components/ui/badge.tsx | 1 + frontend/src/i18n/locales/en.json | 1 + frontend/src/i18n/locales/no.json | 1 + frontend/src/i18n/locales/sv.json | 1 + frontend/src/lib/api/github.ts | 1 + frontend/src/pages/changelog.tsx | 6 +++--- 6 files changed, 8 insertions(+), 3 deletions(-) diff --git a/frontend/src/components/ui/badge.tsx b/frontend/src/components/ui/badge.tsx index f000e3e..da6f306 100644 --- a/frontend/src/components/ui/badge.tsx +++ b/frontend/src/components/ui/badge.tsx @@ -15,6 +15,7 @@ const badgeVariants = cva( destructive: "border-transparent bg-destructive text-destructive-foreground hover:bg-destructive/80", outline: "text-foreground", + prerelease: "bg-orange-50 dark:bg-orange-950 text-orange-400 dark:text-orange-400 border-orange-200 dark:border-orange-800 font-normal", }, }, defaultVariants: { diff --git a/frontend/src/i18n/locales/en.json b/frontend/src/i18n/locales/en.json index d5c4420..4270cf5 100644 --- a/frontend/src/i18n/locales/en.json +++ b/frontend/src/i18n/locales/en.json @@ -19,6 +19,7 @@ "back": "Back", "deleting": "Deleting...", "cancel": "Cancel", + "view_on_github": "View on GitHub", "saving": "Saving...", "save": "Save" }, diff --git a/frontend/src/i18n/locales/no.json b/frontend/src/i18n/locales/no.json index b7242cb..f1dbbcd 100644 --- a/frontend/src/i18n/locales/no.json +++ b/frontend/src/i18n/locales/no.json @@ -19,6 +19,7 @@ "back": "Tilbake", "deleting": "Sletter...", "cancel": "Avbryt", + "view_on_github": "Vis på GitHub", "saving": "Lagrer...", "save": "Lagre" }, diff --git a/frontend/src/i18n/locales/sv.json b/frontend/src/i18n/locales/sv.json index 9f2e1ba..eaa2a59 100644 --- a/frontend/src/i18n/locales/sv.json +++ b/frontend/src/i18n/locales/sv.json @@ -19,6 +19,7 @@ "back": "Tillbaka", "deleting": "Radering...", "cancel": "Avbryt", + "view_on_github": "Vis på GitHub", "saving": "Sparar...", "save": "Spara" }, diff --git a/frontend/src/lib/api/github.ts b/frontend/src/lib/api/github.ts index ff59113..ee0c5a1 100644 --- a/frontend/src/lib/api/github.ts +++ b/frontend/src/lib/api/github.ts @@ -7,6 +7,7 @@ export interface GitHubRelease { published_at: string; body: string; html_url: string; + prerelease: boolean; } export const fetchGitHubReleases = async (): Promise => { diff --git a/frontend/src/pages/changelog.tsx b/frontend/src/pages/changelog.tsx index a0ed3f8..95c14ca 100644 --- a/frontend/src/pages/changelog.tsx +++ b/frontend/src/pages/changelog.tsx @@ -61,7 +61,7 @@ export default function ChangelogPage() { - + From 1ec767fae59a811f6d62cff44d5539fbc272e6ee Mon Sep 17 00:00:00 2001 From: "Daniel S. Billing" Date: Fri, 10 Jan 2025 22:37:46 +0100 Subject: [PATCH 17/19] Use date utils on events page --- frontend/src/pages/attendee/events/index.tsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/frontend/src/pages/attendee/events/index.tsx b/frontend/src/pages/attendee/events/index.tsx index 6883cf9..b059056 100644 --- a/frontend/src/pages/attendee/events/index.tsx +++ b/frontend/src/pages/attendee/events/index.tsx @@ -10,6 +10,7 @@ import {useState, useEffect} from 'react'; import {Link} from 'react-router-dom'; import {Calendar} from "@phosphor-icons/react"; import { route, RouteConfig } from '@/routes/route-config'; +import { formatDate } from '@/lib/utils'; export default function EventsPage() { const {t} = useTranslation(); @@ -53,7 +54,7 @@ export default function EventsPage() {
- {new Date(event.start_at).toLocaleDateString()} — {new Date(event.end_at).toLocaleDateString()} + {formatDate(event.start_at)} — {formatDate(event.end_at)}

{event.description} From 1a3f59719075736e9ccadfa279ccc726c0e6bc0d Mon Sep 17 00:00:00 2001 From: "Daniel S. Billing" Date: Fri, 10 Jan 2025 23:26:21 +0100 Subject: [PATCH 18/19] Add save icon to save button --- frontend/src/pages/organiser/event/event-form.tsx | 2 ++ frontend/src/pages/organiser/organisation/organisation-form.tsx | 2 ++ 2 files changed, 4 insertions(+) diff --git a/frontend/src/pages/organiser/event/event-form.tsx b/frontend/src/pages/organiser/event/event-form.tsx index 20f57d8..a174791 100644 --- a/frontend/src/pages/organiser/event/event-form.tsx +++ b/frontend/src/pages/organiser/event/event-form.tsx @@ -16,6 +16,7 @@ import { eventsApi } from '@/lib/api/events'; import { route } from '@/routes/route-config'; import { RouteConfig } from '@/routes/route-config'; import {parsePhoneNumber} from "react-phone-number-input"; +import { FloppyDisk } from '@phosphor-icons/react'; const FormSchema = z.object({ title: z.string().min(1, "Title is required"), @@ -350,6 +351,7 @@ export function EventForm() {

diff --git a/frontend/src/pages/organiser/organisation/organisation-form.tsx b/frontend/src/pages/organiser/organisation/organisation-form.tsx index 3a7842a..5c9dc8b 100644 --- a/frontend/src/pages/organiser/organisation/organisation-form.tsx +++ b/frontend/src/pages/organiser/organisation/organisation-form.tsx @@ -12,6 +12,7 @@ import { useState, useEffect } from "react"; import { Button } from "@/components/ui/button"; import { useOrganisation } from '@/context/OrganisationContext'; import { PhoneInput } from '@/components/ui/phone-input'; +import { FloppyDisk } from '@phosphor-icons/react'; const FormSchema = z.object({ name: z.string().min(1, "Name is required"), @@ -282,6 +283,7 @@ export function OrganisationForm() {
From 54f1b8ade2ced6735a4e48150c45c768f4fa1b3f Mon Sep 17 00:00:00 2001 From: "Daniel S. Billing" Date: Fri, 10 Jan 2025 23:40:30 +0100 Subject: [PATCH 19/19] Remove unnecessary open mode parameters --- backend/config.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/config.py b/backend/config.py index 2781a9c..9972166 100644 --- a/backend/config.py +++ b/backend/config.py @@ -115,7 +115,7 @@ class Config: API_DOCS_TITLE: str = f'{MICRO_SERVICE_NAME_FOR_HUMANS} API' API_DOCS_VERSION: str = '3.0.0-alpha.1' try: - with open('.version', 'r') as version_file: + with open('.version') as version_file: API_DOCS_VERSION: str = version_file.read().strip() except Exception as e: logging.error(f'Error reading version file: {e}')