mirror of
https://github.com/hex248/sprint.git
synced 2026-02-08 10:33:01 +00:00
update issue assignee full implementation
This commit is contained in:
@@ -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";
|
||||
|
||||
36
packages/frontend/src/lib/server/issue/update.ts
Normal file
36
packages/frontend/src/lib/server/issue/update.ts
Normal 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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user