mirror of
https://git.coastit.co.za/caitlin/CRM_ENVR.git
synced 2026-07-15 05:27:07 +02:00
feat: Enhance provider components with detailed documentation and comments
- Added comprehensive comments and JSDoc-style documentation to NotificationProvider, ThemeProvider, UserProvider, and WebsiteThemeProvider for better clarity and maintainability. - Improved type definitions in index.ts for better code understanding and usage. - Introduced Docker support with Dockerfiles for various services including AI server, signaling server, and browser-use service. - Created a docker-compose.yml file to orchestrate multiple services including PostgreSQL, AI, scraper, and frontend. - Added a startup guide (startup.txt) for setting up the CRM environment on Ubuntu with Docker. - Included a .dockerignore file to exclude unnecessary files from Docker builds.
This commit is contained in:
@@ -1,12 +1,23 @@
|
||||
// ── Settings: Website Theme ──────────────────────────────────────────────────
|
||||
// GET /api/settings/website-theme — Get the current user's theme preference
|
||||
// PUT /api/settings/website-theme — Update theme preference (stored in JSONB)
|
||||
//
|
||||
// Auth: authenticated
|
||||
// Reads and writes the website_theme and color_theme keys inside the user's
|
||||
// preferences JSONB column, preserving other preference data.
|
||||
|
||||
import { NextRequest, NextResponse } from "next/server"
|
||||
import { getSessionUser } from "@/lib/auth"
|
||||
import { query } from "@/lib/db"
|
||||
|
||||
// ── GET ──────────────────────────────────────────────────────────────────────
|
||||
|
||||
export async function GET() {
|
||||
try {
|
||||
const user = await getSessionUser()
|
||||
if (!user) return NextResponse.json({ error: "Unauthorized" }, { status: 401 })
|
||||
|
||||
// Extract website_theme and color_theme from the JSONB preferences column
|
||||
const result = await query(
|
||||
`SELECT preferences->>'website_theme' AS website_theme, preferences->>'color_theme' AS color_theme FROM users WHERE id = $1`,
|
||||
[user.id],
|
||||
@@ -21,6 +32,8 @@ export async function GET() {
|
||||
}
|
||||
}
|
||||
|
||||
// ── PUT ──────────────────────────────────────────────────────────────────────
|
||||
|
||||
export async function PUT(request: NextRequest) {
|
||||
try {
|
||||
const user = await getSessionUser()
|
||||
@@ -35,6 +48,7 @@ export async function PUT(request: NextRequest) {
|
||||
update.color_theme = body.colorTheme || "default"
|
||||
}
|
||||
|
||||
// Merge into the existing JSONB preferences using || operator
|
||||
if (Object.keys(update).length > 0) {
|
||||
await query(
|
||||
`UPDATE users SET preferences = preferences || $2::jsonb WHERE id = $1`,
|
||||
@@ -42,6 +56,7 @@ export async function PUT(request: NextRequest) {
|
||||
)
|
||||
}
|
||||
|
||||
// Return the updated values
|
||||
const result = await query(
|
||||
`SELECT preferences->>'website_theme' AS website_theme, preferences->>'color_theme' AS color_theme FROM users WHERE id = $1`,
|
||||
[user.id],
|
||||
|
||||
Reference in New Issue
Block a user