提交
This commit is contained in:
@@ -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))
|
||||
}
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
export {
|
||||
getCustomerDimensionConfig,
|
||||
updateCustomerDimensionConfig,
|
||||
updateCustomerDimensionDefaultCalculationMode,
|
||||
} from './api'
|
||||
|
||||
export type {
|
||||
CustomerDimensionBoxType,
|
||||
CustomerDimensionCalculationMode,
|
||||
CustomerDimensionConfig,
|
||||
CustomerDimensionConfigFormModel,
|
||||
CustomerDimensionRule,
|
||||
|
||||
@@ -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[]
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user