-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #95 from MinaFoundation/feature/ocv-consideration-…
…votes-dashboard Feature/ocv consideration votes dashboard
- Loading branch information
Showing
11 changed files
with
634 additions
and
13 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { OCVVotesTable } from "@/components/admin/ocv-votes/OCVVotesTable"; | ||
import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card"; | ||
import { Metadata } from "next"; | ||
|
||
export const metadata: Metadata = { | ||
title: "OCV Votes | MEF Admin", | ||
description: "Monitor OCV consideration votes and project eligibility", | ||
}; | ||
|
||
export default function OCVVotesPage() { | ||
return ( | ||
<div className="container mx-auto p-6 max-w-7xl"> | ||
<Card> | ||
<CardHeader> | ||
<CardTitle className="text-2xl font-bold">OCV Consideration Votes</CardTitle> | ||
</CardHeader> | ||
<CardContent> | ||
<OCVVotesTable /> | ||
</CardContent> | ||
</Card> | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import { NextResponse } from "next/server"; | ||
import prisma from "@/lib/prisma"; | ||
import { getOrCreateUserFromRequest } from "@/lib/auth"; | ||
import { AdminService } from "@/services/AdminService"; | ||
import { OCVVotesService } from "@/services/OCVVotesService"; | ||
import { ApiResponse } from "@/lib/api-response"; | ||
import { AppError } from "@/lib/errors"; | ||
import { AuthErrors } from "@/constants/errors"; | ||
|
||
const adminService = new AdminService(prisma); | ||
const ocvVotesService = new OCVVotesService(prisma); | ||
|
||
export async function GET(request: Request) { | ||
try { | ||
const user = await getOrCreateUserFromRequest(request); | ||
if (!user) { | ||
throw AppError.unauthorized(AuthErrors.UNAUTHORIZED); | ||
} | ||
|
||
const isAdmin = await adminService.checkAdminStatus(user.id, user.linkId); | ||
if (!isAdmin) { | ||
throw AppError.forbidden(AuthErrors.FORBIDDEN); | ||
} | ||
|
||
const { searchParams } = new URL(request.url); | ||
const page = Math.max(1, Number(searchParams.get('page')) || 1); | ||
const pageSize = Math.max(1, Number(searchParams.get('pageSize')) || 25); | ||
const sortField = searchParams.get('sortField') || 'updatedAt'; | ||
const sortOrder = (searchParams.get('sortOrder') || 'desc') as 'asc' | 'desc'; | ||
|
||
const votes = await ocvVotesService.getOCVVotes( | ||
page, | ||
pageSize, | ||
sortField, | ||
sortOrder | ||
); | ||
|
||
return ApiResponse.success(votes); | ||
} catch (error) { | ||
return ApiResponse.error(error); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.