2025-05-19 16:57:10 +00:00
|
|
|
---
|
|
|
|
|
import { Icon } from 'astro-icon/components'
|
|
|
|
|
import { Markdown } from 'astro-remote'
|
|
|
|
|
|
2025-05-20 08:02:55 +00:00
|
|
|
import { getAnnouncementTypeInfo } from '../constants/announcementTypes'
|
|
|
|
|
import { cn } from '../lib/cn'
|
2025-05-19 16:57:10 +00:00
|
|
|
|
2025-05-20 08:02:55 +00:00
|
|
|
import type { Prisma } from '@prisma/client'
|
2025-05-19 16:57:10 +00:00
|
|
|
|
2025-05-20 08:02:55 +00:00
|
|
|
type Props = {
|
|
|
|
|
announcements:
|
|
|
|
|
| Prisma.AnnouncementGetPayload<{
|
|
|
|
|
select: {
|
|
|
|
|
id: true
|
|
|
|
|
title: true
|
|
|
|
|
content: true
|
|
|
|
|
type: true
|
|
|
|
|
startDate: true
|
|
|
|
|
endDate: true
|
|
|
|
|
isActive: true
|
|
|
|
|
}
|
|
|
|
|
}>[]
|
|
|
|
|
| null
|
|
|
|
|
| undefined
|
2025-05-19 16:57:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const { announcements } = Astro.props
|
|
|
|
|
---
|
|
|
|
|
|
|
|
|
|
{
|
2025-05-20 08:02:55 +00:00
|
|
|
!!announcements && announcements.length > 0 && (
|
2025-05-19 16:57:10 +00:00
|
|
|
<div class="mb-4 flex flex-col items-center space-y-1">
|
|
|
|
|
{announcements.map((announcement) => {
|
2025-05-20 08:02:55 +00:00
|
|
|
const typeInfo = getAnnouncementTypeInfo(announcement.type)
|
2025-05-19 16:57:10 +00:00
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<div
|
2025-05-20 08:02:55 +00:00
|
|
|
class={cn(
|
|
|
|
|
'mx-auto flex w-auto max-w-full flex-row items-center rounded border px-3 py-2',
|
|
|
|
|
typeInfo.classNames.container
|
|
|
|
|
)}
|
2025-05-19 16:57:10 +00:00
|
|
|
>
|
2025-05-20 08:02:55 +00:00
|
|
|
<Icon name={typeInfo.icon} class={cn('mr-2 size-4 flex-shrink-0', typeInfo.classNames.title)} />
|
2025-05-19 16:57:10 +00:00
|
|
|
<div class="flex min-w-0 flex-col">
|
2025-05-20 08:02:55 +00:00
|
|
|
<span class={cn('truncate text-sm leading-tight font-bold', typeInfo.classNames.title)}>
|
2025-05-19 16:57:10 +00:00
|
|
|
{announcement.title}
|
|
|
|
|
</span>
|
2025-05-20 08:02:55 +00:00
|
|
|
<span class={cn('truncate text-xs leading-snug [&_a]:underline', typeInfo.classNames.content)}>
|
2025-05-19 16:57:10 +00:00
|
|
|
<Markdown content={announcement.content} />
|
|
|
|
|
</span>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
)
|
|
|
|
|
})}
|
|
|
|
|
</div>
|
|
|
|
|
)
|
|
|
|
|
}
|