This commit is contained in:
2024-10-06 11:52:45 +08:00
parent ee746cd61d
commit 3272da0b2b
16 changed files with 483 additions and 81 deletions

View File

@@ -1,5 +1,5 @@
import { CoursesProps, CoursesArrayProps, SettingsProps, MessageProps } from "@/types";
import { CoursesProps, CoursesArrayProps, SettingsProps, MessageProps, AboutusProps } from "@/types";
@@ -37,6 +37,30 @@ export async function postMessage(data: MessageProps) {
}
}
export async function fetchAboutus() {
const headers: HeadersInit = {
accept: "application/json"
};
const url = `${process.env.api_url}aboutUs`;
console.log('Fetching from URL:', url);
try {
const response = await fetch(url, { headers });
console.log('Response status:', response.status);
const result = await response.json();
console.log('Fetched data:', result);
// Sort the result by index
const sortedResult: AboutusProps[] = 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 fetchCourses() {
const headers: HeadersInit = {