All files / src/lib/api/admin feedback.ts

100% Statements 11/11
100% Branches 8/8
100% Functions 2/2
100% Lines 8/8

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41                                  95x           4x 4x 4x 4x 4x 4x           2x            
import { request } from "../base";
 
export type FeedbackEntry = {
	id: number;
	userId: string | null;
	proId: string | null;
	category: string;
	message: string;
	pageUrl: string | null;
	userEmail: string | null;
	browser: string | null;
	screenResolution: string | null;
	location: string | null;
	status: string;
	createdAt: string;
};
 
export const adminFeedbackApi = {
	listFeedback(filters?: {
		page?: number;
		limit?: number;
		status?: string;
	}) {
		const params = new URLSearchParams();
		if (filters?.page) params.set("page", String(filters.page));
		if (filters?.limit) params.set("limit", String(filters.limit));
		if (filters?.status) params.set("status", filters.status);
		const qs = params.toString();
		return request<FeedbackEntry[]>(
			`/api/admin/feedback${qs ? `?${qs}` : ""}`,
		);
	},
 
	updateFeedbackStatus(id: number, status: string) {
		return request<FeedbackEntry>(`/api/admin/feedback/${id}`, {
			method: "PATCH",
			body: { status },
		});
	},
};