package com.betriebsratkanzlei.legalconsenthub.application_form

import com.betriebsratkanzlei.legalconsenthub_api.model.ApplicationFormDto
import com.betriebsratkanzlei.legalconsenthub_api.model.CreateApplicationFormDto
import com.betriebsratkanzlei.legalconsenthub_api.model.PagedApplicationFormDto
import org.springframework.data.domain.Page
import org.springframework.stereotype.Component

@Component
class PagedApplicationFormMapper(private val applicationFormMapper: ApplicationFormMapper) {
    fun toPagedApplicationFormDto(pagedApplicationForm: Page<ApplicationForm>): PagedApplicationFormDto {
        return PagedApplicationFormDto(
            content = pagedApplicationForm.content.map { applicationFormMapper.toApplicationFormDto(it) },
            number = pagedApplicationForm.number,
            propertySize = pagedApplicationForm.size,
            numberOfElements = pagedApplicationForm.numberOfElements,
            last = pagedApplicationForm.isLast,
            totalPages = pagedApplicationForm.totalPages,
            totalElements = pagedApplicationForm.totalElements,
            empty = pagedApplicationForm.isEmpty,
            first = pagedApplicationForm.isFirst,
        )
    }
}
