add reygiri page
This commit is contained in:
+23
-12
@@ -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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user