Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 additions & 0 deletions src/lib/api/admin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ import type {
ChallengeDifficulty,
ChallengeMode,
ChallengeTone,
ProjectListItem,
ProjectListFilters,
ProjectDetail,
ProjectCreateBody,
ProjectPatchBody,
Report,
ReportStatus,
ReportTargetType,
Expand Down Expand Up @@ -357,6 +362,45 @@ export const adminApi = {
return api.post<ApiResponse<{ message: string }>>('/admin/leaderboards/rebuild');
},

// --- Admin projects (content-strategy §4, annexes E + F) ---

listAdminProjects(filters?: ProjectListFilters) {
const params = new URLSearchParams();
if (filters?.is_flagship !== undefined) params.set('is_flagship', String(filters.is_flagship));
if (filters?.curated_by_admin !== undefined)
params.set('curated_by_admin', String(filters.curated_by_admin));
if (filters?.partnership_level !== undefined)
params.set('partnership_level', String(filters.partnership_level));
if (filters?.include_archived) params.set('include_archived', 'true');
if (filters?.page) params.set('page', String(filters.page));
if (filters?.per_page) params.set('per_page', String(filters.per_page));
const qs = params.toString();
return api.get<
ApiPaginatedResponse<ProjectListItem>
>(`/admin/projects${qs ? `?${qs}` : ''}`);
},

getAdminProject(slug: string) {
return api.get<ApiResponse<ProjectDetail>>(`/admin/projects/${slug}`);
},

createAdminProject(data: ProjectCreateBody) {
return api.post<ApiResponse<{ id: string; slug: string }>>('/admin/projects', data);
},

patchAdminProject(slug: string, data: ProjectPatchBody) {
return api.patch<ApiResponse<{ slug: string; updated: boolean }>>(
`/admin/projects/${slug}`,
data
);
},

archiveAdminProject(slug: string) {
return api.delete<ApiResponse<{ slug: string; archived: boolean }>>(
`/admin/projects/${slug}`
);
},

// --- Community ---

communityReview() {
Expand Down
76 changes: 76 additions & 0 deletions src/lib/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -734,3 +734,79 @@ export const ERROR_CODES = {
CONTACT_BLOCKED: 'CONTACT_BLOCKED',
CONVERSATION_CLOSED: 'CONVERSATION_CLOSED'
} as const;

// ─── Admin projects — content-strategy-2027-2028 §4 + annexes E, F ───────────

export type ProjectOwnerType = 'user' | 'guild';
export type PartnershipLevel = 1 | 2 | 3;

/** Row returned by `GET /admin/projects` list endpoint. */
export interface ProjectListItem {
id: string;
slug: string;
name: string;
description: string | null;
repo_url: string | null;
is_flagship: boolean;
curated_by_admin: boolean;
skilluv_partnership_level: PartnershipLevel | null;
flagship_steward_user_id: string | null;
created_at: string;
archived_at: string | null;
}

/** Full row returned by `GET /admin/projects/{slug}`. */
export interface ProjectDetail extends ProjectListItem {
demo_url: string | null;
tech_stack: string[];
is_oss: boolean;
looking_for_contributors: boolean;
owner_type: ProjectOwnerType;
owner_id: string;
skilluv_editorial_notes: string | null;
updated_at: string;
}

/** Payload for `POST /admin/projects`. */
export interface ProjectCreateBody {
slug: string;
name: string;
description?: string | null;
repo_url?: string | null;
demo_url?: string | null;
tech_stack?: string[];
is_oss?: boolean;
looking_for_contributors?: boolean;
owner_type: ProjectOwnerType;
owner_id: string;
curated_by_admin?: boolean;
is_flagship?: boolean;
flagship_steward_user_id?: string | null;
skilluv_partnership_level?: PartnershipLevel | null;
skilluv_editorial_notes?: string | null;
}

/** Payload for `PATCH /admin/projects/{slug}`. All fields optional. */
export interface ProjectPatchBody {
name?: string;
description?: string | null;
repo_url?: string | null;
demo_url?: string | null;
tech_stack?: string[];
is_oss?: boolean;
looking_for_contributors?: boolean;
curated_by_admin?: boolean;
is_flagship?: boolean;
flagship_steward_user_id?: string | null;
skilluv_partnership_level?: PartnershipLevel | null;
skilluv_editorial_notes?: string | null;
}

export interface ProjectListFilters {
is_flagship?: boolean;
curated_by_admin?: boolean;
partnership_level?: PartnershipLevel;
include_archived?: boolean;
page?: number;
per_page?: number;
}
2 changes: 2 additions & 0 deletions src/routes/+layout.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
BookMarked,
Briefcase,
Network,
FolderGit2,
LogOut
} from '@lucide/svelte';

Expand All @@ -45,6 +46,7 @@
{ href: '/reports', label: i18n.t('admin.reports.title'), icon: Flag },
{ href: '/fraud', label: i18n.t('admin.nav.fraud'), icon: Fingerprint },
{ href: '/challenges', label: i18n.t('admin.challenges.title'), icon: Code2 },
{ href: '/projects', label: 'Projets', icon: FolderGit2 },
{ href: '/community', label: i18n.t('admin.community.title'), icon: Star },
{ href: '/catalog', label: i18n.t('admin.nav.catalog'), icon: BookMarked },
{ href: '/skills', label: i18n.t('admin.nav.skills'), icon: Network },
Expand Down
Loading
Loading