/*
DESCRIPTION:
Any functions that are used internally by the use-case
*/
package regency

import (
	e "simrs-vx/internal/domain/main-entities/regency"
)

func setData[T *e.CreateDto | *e.UpdateDto](input T, data *e.Regency) {
	var inputSrc *e.CreateDto
	if inputT, ok := any(input).(*e.CreateDto); ok {
		inputSrc = inputT
	} else {
		inputTemp := any(input).(*e.UpdateDto)
		inputSrc = &inputTemp.CreateDto
	}
	data.Province_Code = inputSrc.Province_Code
	data.Code = *inputSrc.Code
	data.Name = inputSrc.Name
}

func toResponseOrNil(data interface{ ToResponse() any }) any {
	if data == nil {
		return nil
	}
	return data.ToResponse()
}
