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))
}
+2
View File
@@ -1,10 +1,12 @@
export {
getCustomerDimensionConfig,
updateCustomerDimensionConfig,
updateCustomerDimensionDefaultCalculationMode,
} from './api'
export type {
CustomerDimensionBoxType,
CustomerDimensionCalculationMode,
CustomerDimensionConfig,
CustomerDimensionConfigFormModel,
CustomerDimensionRule,
+2
View File
@@ -1,4 +1,5 @@
export type CustomerDimensionBoxType = 'SMALL' | 'MEDIUM' | 'LARGE' | 'EXTRA_LARGE'
export type CustomerDimensionCalculationMode = 'ADD' | 'MULTIPLY'
export interface CustomerDimensionRule {
id: string
@@ -20,6 +21,7 @@ export interface CustomerDimensionRule {
export interface CustomerDimensionConfig {
tenantId: string
defaultCalculationMode: CustomerDimensionCalculationMode
rules: CustomerDimensionRule[]
}