17 lines
501 B
TypeScript
17 lines
501 B
TypeScript
import type { FacilityCards } from "@/types/components/hotelPage/facilities"
|
|
import type { CardProps } from "@/components/TempDesignSystem/Card/card"
|
|
|
|
export function sortCards(cards: FacilityCards) {
|
|
const sortedCards = cards.slice(0).sort((a: CardProps, b: CardProps) => {
|
|
if (!a.backgroundImage && b.backgroundImage) {
|
|
return 1
|
|
}
|
|
if (a.backgroundImage && !b.backgroundImage) {
|
|
return -1
|
|
}
|
|
return 0
|
|
})
|
|
|
|
return { card: sortedCards.pop(), images: sortedCards }
|
|
}
|