full status implementation

This commit is contained in:
Oliver Bryan
2026-01-10 16:26:57 +00:00
parent fb96486da8
commit 364e4e0f64
22 changed files with 711 additions and 126 deletions

View File

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

View File

@@ -0,0 +1,36 @@
import { getCsrfToken, getServerURL } from "@/lib/utils";
import type { ServerQueryInput } from "..";
export async function replaceStatus({
organisationId,
oldStatus,
newStatus,
onSuccess,
onError,
}: {
organisationId: number;
oldStatus: string;
newStatus: string;
} & ServerQueryInput) {
const url = new URL(`${getServerURL()}/issues/replace-status`);
url.searchParams.set("organisationId", `${organisationId}`);
url.searchParams.set("oldStatus", oldStatus);
url.searchParams.set("newStatus", newStatus);
const csrfToken = getCsrfToken();
const headers: HeadersInit = {};
if (csrfToken) headers["X-CSRF-Token"] = csrfToken;
const res = await fetch(url.toString(), {
headers,
credentials: "include",
});
if (!res.ok) {
const error = await res.text();
onError?.(error || `failed to replace status (${res.status})`);
} else {
const data = await res.json();
onSuccess?.(data, res);
}
}

View File

@@ -6,6 +6,7 @@ export async function update({
title,
description,
assigneeId,
status,
onSuccess,
onError,
}: {
@@ -13,6 +14,7 @@ export async function update({
title?: string;
description?: string;
assigneeId?: number | null;
status?: string;
} & ServerQueryInput) {
const url = new URL(`${getServerURL()}/issue/update`);
url.searchParams.set("id", `${issueId}`);
@@ -21,6 +23,7 @@ export async function update({
if (assigneeId !== undefined) {
url.searchParams.set("assigneeId", assigneeId === null ? "null" : `${assigneeId}`);
}
if (status !== undefined) url.searchParams.set("status", status);
const csrfToken = getCsrfToken();
const headers: HeadersInit = {};