import { queryAnnouncement } from '@/services/user/announcement'; import { Card } from '@workspace/ui/components/card'; import { Dialog, DialogContent, DialogHeader, DialogTitle } from '@workspace/ui/components/dialog'; import { Icon } from '@workspace/ui/custom-components/icon'; import { Markdown } from '@workspace/ui/custom-components/markdown'; import { getTranslations } from 'next-intl/server'; import { Empty } from '../empty'; export default async function Announcement({ type, Authorization, }: { type: 'popup' | 'pinned'; Authorization?: string; }) { let data; try { data = await queryAnnouncement( { page: 1, size: 10, pinned: type === 'pinned', popup: type === 'popup', }, { skipErrorHandler: true, Authorization, }, ).then((res) => { return res.data.data?.announcements.find((item) => item[type]); }); } catch (error) { /* empty */ } if (!data) return null; const t = await getTranslations('dashboard'); if (type === 'popup') { return ( ); } if (type === 'pinned') { return ( <>