- api/public/ import 경로 ../index로 수정 - schedules.js에 getUpcomingSchedules 함수 추가 - Home.jsx API 모듈 적용
35 lines
954 B
JavaScript
35 lines
954 B
JavaScript
/**
|
|
* 일정 관련 공개 API
|
|
*/
|
|
import { fetchApi } from "../index";
|
|
import { getTodayKST } from "../../utils/date";
|
|
|
|
// 일정 목록 조회 (월별)
|
|
export async function getSchedules(year, month) {
|
|
return fetchApi(`/api/schedules?year=${year}&month=${month}`);
|
|
}
|
|
|
|
// 다가오는 일정 조회 (오늘 이후)
|
|
export async function getUpcomingSchedules(limit = 3) {
|
|
const todayStr = getTodayKST();
|
|
return fetchApi(`/api/schedules?startDate=${todayStr}&limit=${limit}`);
|
|
}
|
|
|
|
// 일정 검색 (Meilisearch)
|
|
export async function searchSchedules(query, { offset = 0, limit = 20 } = {}) {
|
|
return fetchApi(
|
|
`/api/schedules?search=${encodeURIComponent(
|
|
query
|
|
)}&offset=${offset}&limit=${limit}`
|
|
);
|
|
}
|
|
|
|
// 일정 상세 조회
|
|
export async function getSchedule(id) {
|
|
return fetchApi(`/api/schedules/${id}`);
|
|
}
|
|
|
|
// 카테고리 목록 조회
|
|
export async function getCategories() {
|
|
return fetchApi("/api/schedule-categories");
|
|
}
|