32 lines
No EOL
897 B
TypeScript
32 lines
No EOL
897 B
TypeScript
import { Worship } from '@/payload-types'
|
|
import { EventRowProps } from '@/components/EventRow/EventRow'
|
|
|
|
/**
|
|
* Transform the worship category to a readable string
|
|
*/
|
|
export const transformCategory = (category: "MASS" | "FAMILY" | "WORD"): string => {
|
|
const type = {
|
|
'MASS': 'Eucharistiefeier',
|
|
'FAMILY': 'Familienmesse',
|
|
'WORD': 'Wort-Gottes-Feier',
|
|
}
|
|
|
|
return type[category]
|
|
}
|
|
|
|
/**
|
|
* Transform worship data to `EventRow` component properties
|
|
*/
|
|
export const tranformWorship = (worship: Worship[]): (EventRowProps & {id: string})[] => {
|
|
|
|
return worship.map(w => {
|
|
return {
|
|
id: w.id,
|
|
title: typeof w.title === "string" && w.title.length > 0 ? w.title : transformCategory(w.type),
|
|
date: w.date,
|
|
href: `/gottesdienst/${w.id}`,
|
|
location: typeof w.location === 'string' ? w.location : w.location.name,
|
|
cancelled: w.cancelled,
|
|
}
|
|
})
|
|
} |