Files
sprint/packages/frontend/src/lib/server/sprint/byProject.ts
2026-01-13 15:33:55 +00:00

27 lines
713 B
TypeScript

import type { SprintRecord } from "@issue/shared";
import { getServerURL } from "@/lib/utils";
import type { ServerQueryInput } from "..";
export async function byProject({
projectId,
onSuccess,
onError,
}: {
projectId: number;
} & ServerQueryInput<SprintRecord[]>) {
const url = new URL(`${getServerURL()}/sprints/by-project`);
url.searchParams.set("projectId", `${projectId}`);
const res = await fetch(url.toString(), {
credentials: "include",
});
if (!res.ok) {
const error = await res.text();
onError?.(error || `failed to get sprints (${res.status})`);
} else {
const data = await res.json();
onSuccess?.(data, res);
}
}