mirror of
https://github.com/hex248/sprint.git
synced 2026-02-07 18:23:03 +00:00
sprintId can now be updated on Issue
This commit is contained in:
@@ -45,7 +45,13 @@ export async function deleteIssue(id: number) {
|
||||
|
||||
export async function updateIssue(
|
||||
id: number,
|
||||
updates: { title?: string; description?: string; assigneeId?: number | null; status?: string },
|
||||
updates: {
|
||||
title?: string;
|
||||
description?: string;
|
||||
sprintId?: number | null;
|
||||
assigneeId?: number | null;
|
||||
status?: string;
|
||||
},
|
||||
) {
|
||||
return await db.update(Issue).set(updates).where(eq(Issue.id, id)).returning();
|
||||
}
|
||||
|
||||
@@ -12,10 +12,18 @@ export default async function issueUpdate(req: BunRequest) {
|
||||
|
||||
const title = url.searchParams.get("title") || undefined;
|
||||
const description = url.searchParams.get("description") || undefined;
|
||||
const sprintIdParam = url.searchParams.get("sprintId");
|
||||
const assigneeIdParam = url.searchParams.get("assigneeId");
|
||||
const status = url.searchParams.get("status") || undefined;
|
||||
|
||||
// Parse assigneeId: "null" means unassign, number means assign, undefined means no change
|
||||
// parse sprintId: "null" means unassign, number means assign, undefined means no change
|
||||
let sprintId: number | null | undefined;
|
||||
if (sprintIdParam === "null") {
|
||||
sprintId = null;
|
||||
} else if (sprintIdParam) {
|
||||
sprintId = Number(sprintIdParam);
|
||||
}
|
||||
// same for assigneeId
|
||||
let assigneeId: number | null | undefined;
|
||||
if (assigneeIdParam === "null") {
|
||||
assigneeId = null;
|
||||
@@ -23,13 +31,14 @@ export default async function issueUpdate(req: BunRequest) {
|
||||
assigneeId = Number(assigneeIdParam);
|
||||
}
|
||||
|
||||
if (!title && !description && assigneeId === undefined && !status) {
|
||||
if (!title && !description && sprintId === undefined && assigneeId === undefined && !status) {
|
||||
return new Response("no updates provided", { status: 400 });
|
||||
}
|
||||
|
||||
const issue = await updateIssue(Number(id), {
|
||||
title,
|
||||
description,
|
||||
sprintId,
|
||||
assigneeId,
|
||||
status,
|
||||
});
|
||||
|
||||
@@ -5,6 +5,7 @@ export async function update({
|
||||
issueId,
|
||||
title,
|
||||
description,
|
||||
sprintId,
|
||||
assigneeId,
|
||||
status,
|
||||
onSuccess,
|
||||
@@ -13,6 +14,7 @@ export async function update({
|
||||
issueId: number;
|
||||
title?: string;
|
||||
description?: string;
|
||||
sprintId?: number | null;
|
||||
assigneeId?: number | null;
|
||||
status?: string;
|
||||
} & ServerQueryInput) {
|
||||
@@ -20,6 +22,9 @@ export async function update({
|
||||
url.searchParams.set("id", `${issueId}`);
|
||||
if (title !== undefined) url.searchParams.set("title", title);
|
||||
if (description !== undefined) url.searchParams.set("description", description);
|
||||
if (sprintId !== undefined) {
|
||||
url.searchParams.set("sprintId", sprintId === null ? "null" : `${sprintId}`);
|
||||
}
|
||||
if (assigneeId !== undefined) {
|
||||
url.searchParams.set("assigneeId", assigneeId === null ? "null" : `${assigneeId}`);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user