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