This commit is contained in:
2026-09-03 10:46:07 +08:00
parent 913a8df7f3
commit 176f815519
17 changed files with 1128 additions and 44 deletions
+14
View File
@@ -1,6 +1,7 @@
import { http, unwrapApiResponse, type ApiEnvelope } from '@/shared/api/http'
import type {
CustomerDimensionConfig,
CustomerDimensionCalculationMode,
CustomerDimensionRule,
UpdateCustomerDimensionConfigRequest,
} from './types'
@@ -23,6 +24,7 @@ function normalizeRule(rule: RawRule): CustomerDimensionRule {
function normalizeConfig(config: RawConfig): CustomerDimensionConfig {
return {
tenantId: String(config.tenantId),
defaultCalculationMode: config.defaultCalculationMode === 'MULTIPLY' ? 'MULTIPLY' : 'ADD',
rules: config.rules.map(normalizeRule),
}
}
@@ -43,3 +45,15 @@ export async function updateCustomerDimensionConfig(
})
return normalizeConfig(unwrapApiResponse(response))
}
export async function updateCustomerDimensionDefaultCalculationMode(
tenantId: string,
defaultCalculationMode: CustomerDimensionCalculationMode,
): Promise<CustomerDimensionConfig> {
const response = await http.put<never, ApiEnvelope<RawConfig>>(
`${dimensionConfigPath}/default-calculation-mode`,
{ defaultCalculationMode },
{ params: { tenantId } },
)
return normalizeConfig(unwrapApiResponse(response))
}