update issue assignee full implementation

This commit is contained in:
Oliver Bryan
2026-01-06 15:51:32 +00:00
parent b7a53d2d8a
commit 610cd4199b
7 changed files with 166 additions and 13 deletions

View File

@@ -1,2 +1,3 @@
export { byProject } from "@/lib/server/issue/byProject";
export { create } from "@/lib/server/issue/create";
export { update } from "@/lib/server/issue/update";

View File

@@ -0,0 +1,36 @@
import { getAuthHeaders, getServerURL } from "@/lib/utils";
import type { ServerQueryInput } from "..";
export async function update({
issueId,
title,
description,
assigneeId,
onSuccess,
onError,
}: {
issueId: number;
title?: string;
description?: string;
assigneeId?: number | null;
} & ServerQueryInput) {
const url = new URL(`${getServerURL()}/issue/update`);
url.searchParams.set("id", `${issueId}`);
if (title !== undefined) url.searchParams.set("title", title);
if (description !== undefined) url.searchParams.set("description", description);
if (assigneeId !== undefined) {
url.searchParams.set("assigneeId", assigneeId === null ? "null" : `${assigneeId}`);
}
const res = await fetch(url.toString(), {
headers: getAuthHeaders(),
});
if (!res.ok) {
const error = await res.text();
onError?.(error || `failed to update issue (${res.status})`);
} else {
const data = await res.json();
onSuccess?.(data, res);
}
}