add reygiri page

This commit is contained in:
2026-07-12 18:11:42 +02:00
parent b2e59464a4
commit 4b59444e7d
4 changed files with 116 additions and 48 deletions
+23 -12
View File
@@ -1,20 +1,23 @@
import type { Const } from '@/model/const'
import type { Const } from '@/model/configuration'
import type { CaptureSite } from '@/model/captureSite'
import { isSwitchOn, switchToString } from '@/pages/menuPages/configuration/settingTypes'
export const REYGIri_SITES_KEY = 'reygiri_sites'
export const TRACKING_SYSTEMS_KEY = 'tracking_systems'
export const TRACKING_SYSTEMS_ENABLED_KEY = 'tracking_systems_enabled'
export function normalizeReygiriSitesConst(response: Const | Const[] | null | undefined): {
constId: number | null
sites: CaptureSite[]
} {
const record = Array.isArray(response) ? response[0] : response
if (!record) {
return { constId: null, sites: [] }
}
export function findSettingRow(rows: Const[], key: string): Const | undefined {
return rows.find((row) => row.key === key)
}
export function buildSettingSavePayload(row: Const, value: string): Const {
return {
constId: record.id ?? record.const_id ?? null,
sites: parseReygiriSitesValue(record.value),
id: row.id,
key: row.key,
value,
description: row.description ?? '',
is_active: true,
title_fa: row.title_fa ?? '',
type: row.type ?? 'text',
}
}
@@ -46,3 +49,11 @@ export function serializeReygiriSites(sites: CaptureSite[]): string {
}))
)
}
export function parseTrackingSystemsEnabled(value: string | null | undefined): boolean {
return isSwitchOn(value ?? undefined)
}
export function serializeTrackingSystemsEnabled(enabled: boolean): string {
return switchToString(enabled)
}