mirror of
https://github.com/hex248/sprint.git
synced 2026-02-07 18:23:03 +00:00
27 lines
713 B
TypeScript
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);
|
|
}
|
|
}
|