fix. 운영 api 수정된 구조에 맞춰 코드 수정

This commit is contained in:
clkim
2025-10-16 19:11:36 +09:00
parent 7b72319377
commit 2b2d33734e
9 changed files with 89 additions and 70 deletions

View File

@@ -10,6 +10,10 @@ import type {
PageDataTemplateComponentSet,
PageDataResourceGroupType,
} from '#layers/types/api/pageData'
import type {
OperateComponents,
OperateGroupItem,
} from '#layers/types/api/resourcesData'
/**
* 페이지 데이터를 기반으로 레이아웃 타입을 결정합니다.
@@ -93,7 +97,7 @@ export const hasComponentGroup = (
* @returns 첫 번째 그룹 데이터 또는 null
*/
export const getComponentGroup = (
components: PageDataTemplateComponents,
components: PageDataTemplateComponents | OperateComponents,
componentName: string
) => {
if (!components) return null
@@ -109,7 +113,7 @@ export const getComponentGroup = (
* @returns 그룹 배열 데이터
*/
export const getComponentGroupAry = (
components: PageDataTemplateComponents,
components: PageDataTemplateComponents | OperateComponents,
componentName: string
) => {
if (!components) return []
@@ -118,7 +122,7 @@ export const getComponentGroupAry = (
}
/**
* 슬라이드 데이터를 최소 개수로 보장합니다.
* 슬라이드 데이터를 최소 개수로 보장합니다. (페이지 데이터용)
* @param components 원본 데이터 배열 또는 객체
* @param minCount 최소 보장할 개수 (기본값: 3)
* @returns 최소 개수가 보장된 데이터 배열
@@ -133,18 +137,34 @@ export const ensureMinimumSlideData = (
? components.group_sets
: []
if (arrayData.length === 0) return []
if (arrayData.length >= minCount) {
// 빈 배열이거나 이미 최소 개수를 만족하면 그대로 반환
if (arrayData.length === 0 || arrayData.length >= minCount) {
return arrayData
}
const result = [...arrayData]
while (result.length < minCount) {
result.push(...arrayData)
// 최소 개수를 보장하기 위해 데이터 반복
const repeatTimes = Math.ceil(minCount / arrayData.length)
return Array(repeatTimes).fill(arrayData).flat()
}
/**
* 슬라이드 데이터를 최소 개수로 보장합니다. (운영 그룹용)
* @param data 원본 데이터 배열
* @param minCount 최소 보장할 개수 (기본값: 3)
* @returns 최소 개수가 보장된 데이터 배열
*/
export const ensureMinimumSlideOperateData = (
data: OperateGroupItem[],
minCount: number = 3
): OperateGroupItem[] => {
// 빈 배열이거나 이미 최소 개수를 만족하면 그대로 반환
if (data.length === 0 || data.length >= minCount) {
return data
}
return result
// 최소 개수를 보장하기 위해 데이터 반복
const repeatTimes = Math.ceil(minCount / data.length)
return Array(repeatTimes).fill(data).flat()
}
/**