обновление бизнес логики

This commit is contained in:
2026-02-05 18:53:25 +03:00
parent f275db88c9
commit 44473a8d9d
24 changed files with 712 additions and 5397 deletions

View File

@@ -3,7 +3,7 @@ import { getServerSession } from 'next-auth'
import { authOptions } from '@/lib/auth'
import * as statusColors from '@/lib/statusColors'
export async function GET() {
export async function GET(request: Request) {
try {
const session = await getServerSession(authOptions)
if (!session?.accessToken) {
@@ -11,9 +11,20 @@ export async function GET() {
}
const backendUrl = process.env.BACKEND_URL
// Получаем zone_id из query параметров
const { searchParams } = new URL(request.url)
const zoneId = searchParams.get('zone_id')
// Формируем URL для бэкенда с zone_id если он есть
const detectorsUrl = zoneId
? `${backendUrl}/account/get-detectors/?zone_id=${zoneId}`
: `${backendUrl}/account/get-detectors/`
console.log('[get-detectors] Fetching from backend:', detectorsUrl)
const [detectorsRes, objectsRes] = await Promise.all([
fetch(`${backendUrl}/account/get-detectors/`, {
fetch(detectorsUrl, {
headers: {
'Content-Type': 'application/json',
Authorization: `Bearer ${session.accessToken}`,