Added announcement pages and api changes and types to fix announcements
This commit is contained in:
parent
c32020aa47
commit
879dc44284
@ -1,6 +1,7 @@
|
||||
import { formatDateToMonthDayYear } from "@/lib/utils";
|
||||
import { Announcement } from "@/lib/types";
|
||||
import { fetchAnnouncements } from "@/lib/api";
|
||||
import Link from "next/link";
|
||||
|
||||
|
||||
export const metadata = {
|
||||
@ -27,10 +28,12 @@ export default async function AnnouncementPage() {
|
||||
return (
|
||||
<div className="max-w-6xl mx-auto py-10 px-4">
|
||||
{sorted_announcements.map((announcement) => (
|
||||
<li key={announcement.id} className="mb-2 list-none">
|
||||
<div className="text-lg font-semibold">{announcement.title}</div>
|
||||
<div className="text-sm text-gray-500">{formatDateToMonthDayYear(new Date(announcement.datetime))}</div>
|
||||
</li>
|
||||
<Link href = {`/announcements/${announcement.documentId}`} key={announcement.documentId}>
|
||||
<li key={announcement.id} className="mb-2 list-none">
|
||||
<div className="text-lg font-semibold">{announcement.title}</div>
|
||||
<div className="text-sm text-gray-500">{formatDateToMonthDayYear(new Date(announcement.datetime))}</div>
|
||||
</li>
|
||||
</Link>
|
||||
))}
|
||||
</div>
|
||||
);
|
||||
|
@ -124,6 +124,6 @@ export async function fetchReleases(): Promise<{current_chapters:Chapter[],futur
|
||||
}
|
||||
|
||||
export async function fetchAnnouncementById(announcementId: string): Promise<Announcement> {
|
||||
const data = await fetchFromAPI<Announcement>(`/api/announcements/${announcementId}`);
|
||||
const data = await fetchFromAPI<Announcement>(`/api/announcements/${announcementId}?`);
|
||||
return data[0];
|
||||
}
|
@ -65,6 +65,7 @@ export interface Book {
|
||||
|
||||
export interface Announcement {
|
||||
id: number;
|
||||
documentId: string;
|
||||
title: string;
|
||||
content: string;
|
||||
datetime: string;
|
||||
|
Loading…
Reference in New Issue
Block a user