added organ

This commit is contained in:
2024-10-28 10:46:04 +08:00
parent aa8d8a7185
commit 3c88624095
9 changed files with 360 additions and 3 deletions

View File

@@ -1,5 +1,5 @@
import { CoursesProps, CoursesArrayProps, SettingsProps, MessageProps, AboutusProps } from "@/types";
import { CoursesProps, CoursesArrayProps, SettingsProps, MessageProps, AboutusProps, OrganProps } from "@/types";
@@ -37,6 +37,28 @@ export async function postMessage(data: MessageProps) {
}
}
export async function fetchOrgan() {
const headers: HeadersInit = {
accept: "application/json"
};
const url = `${process.env.NEXT_PUBLIC_API_URL}organ/`;
try {
const response = await fetch(url, { headers });
const result = await response.json();
// Sort the result by index
const sortedResult: OrganProps[] = result.data.sort((a: any, b: any) => a.index - b.index);
return sortedResult;
}
catch (error) {
console.error('Fetch error:', error);
throw error;
}
}
export async function fetchAboutus() {
const headers: HeadersInit = {
accept: "application/json"