All files / src/lib/api/admin home-page.ts

100% Statements 3/3
100% Branches 0/0
100% Functions 2/2
100% Lines 3/3

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   1x       2x                  
// Admin marketplace-home-page curation API client.
//
// Backed by:
//   GET  /api/admin/home-page          → current hero + featured list
//   PUT  /api/admin/home-page/hero     → set/clear hero (singleton)
// The "featured projects" toggle uses the pre-existing
// PUT /api/admin/projects/:id/featured (adminProjectsApi.setProjectFeatured).
import { request } from "../base";
 
export type HomePageProjectSummary = {
	id: string;
	title: string;
	slug: string | null;
	status: string;
	coverImage: string | null;
	proId: string;
	isFeatured: boolean;
	isHero: boolean;
};
 
export type HomePageCuration = {
	hero: HomePageProjectSummary | null;
	featured: HomePageProjectSummary[];
};
 
export const adminHomePageApi = {
	async getHomePageCuration() {
		return request<HomePageCuration>(`/api/admin/home-page`);
	},
 
	async setHero(projectId: string | null) {
		return request<{ hero: HomePageProjectSummary | null }>(
			`/api/admin/home-page/hero`,
			{
				method: "PUT",
				body: { projectId },
			},
		);
	},
};