2026-01-09 21:56:32 +09:00
|
|
|
/**
|
|
|
|
|
* 일정 관련 공개 API
|
|
|
|
|
*/
|
2026-01-09 22:02:04 +09:00
|
|
|
import { fetchApi } from "../index";
|
|
|
|
|
import { getTodayKST } from "../../utils/date";
|
2026-01-09 21:56:32 +09:00
|
|
|
|
|
|
|
|
// 일정 목록 조회 (월별)
|
|
|
|
|
export async function getSchedules(year, month) {
|
2026-01-17 17:52:15 +09:00
|
|
|
const data = await fetchApi(`/api/schedules?year=${year}&month=${month}`);
|
|
|
|
|
|
|
|
|
|
// 날짜별 그룹화된 응답을 플랫 배열로 변환
|
|
|
|
|
const schedules = [];
|
|
|
|
|
for (const [date, dayData] of Object.entries(data)) {
|
|
|
|
|
for (const schedule of dayData.schedules) {
|
|
|
|
|
const category = schedule.category || {};
|
|
|
|
|
schedules.push({
|
|
|
|
|
...schedule,
|
|
|
|
|
date,
|
|
|
|
|
category_id: category.id,
|
|
|
|
|
category_name: category.name,
|
|
|
|
|
category_color: category.color,
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return schedules;
|
2026-01-09 21:56:32 +09:00
|
|
|
}
|
|
|
|
|
|
2026-01-09 22:02:04 +09:00
|
|
|
// 다가오는 일정 조회 (오늘 이후)
|
|
|
|
|
export async function getUpcomingSchedules(limit = 3) {
|
|
|
|
|
const todayStr = getTodayKST();
|
|
|
|
|
return fetchApi(`/api/schedules?startDate=${todayStr}&limit=${limit}`);
|
|
|
|
|
}
|
|
|
|
|
|
2026-01-09 21:56:32 +09:00
|
|
|
// 일정 검색 (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}`);
|
|
|
|
|
}
|
|
|
|
|
|
2026-01-15 14:51:59 +09:00
|
|
|
// X 프로필 정보 조회
|
|
|
|
|
export async function getXProfile(username) {
|
|
|
|
|
return fetchApi(`/api/schedules/x-profile/${encodeURIComponent(username)}`);
|
|
|
|
|
}
|