




import dayjs from "dayjs";




export function getOrderServiceText(petId, orderServiceList) {

	let YYYY = undefined

	return orderServiceList
		.filter(service => service.petId == petId) //过滤
		.map(service => dayjs(service.serviceDate)) //转成时间
		.sort((a, b) => a.valueOf() - b.valueOf()) //排序
		.map((service, i) => {
			// if(YYYY && YYYY.format('YYYY-MM') == service.format('YYYY-MM')){
			// 	return service.format('DD')
			// }
			// if(YYYY && YYYY.format('YYYY') == service.format('YYYY')){
			// 	return service.format('MM-DD')
			// }
			// YYYY = service
			return service.format('MM-DD')
		})
}

export function getProductNameText(petId, productList, orderServiceList) {

	let orderService = orderServiceList.filter(service => service.petId == petId)
	
	let list = (productList
		.filter(product => orderService.filter(service => service.id == product.orderServiceId).length > 0)
		.map(product => product.productName))
		
	list = list.reverse();

	return [...new Set(list)]
}

export default {
	getProductNameText,
	getOrderServiceText,
}