History Table is now functioning completely

This commit is contained in:
2024-07-30 10:02:27 -05:00
parent b14383f8fd
commit 44497ebe7b
7 changed files with 440 additions and 281 deletions

View File

@@ -1,12 +1,13 @@
"use server";
import { NextResponse } from 'next/server';
import { getHistory } from '~/server/functions';
import { get_history } from '~/server/functions';
import { auth } from '~/auth';
export const GET = async (request: Request) => {
try {
const url = new URL(request.url);
const apiKey = url.searchParams.get('apikey');
const userId = Number(url.searchParams.get('user_id')) || -1;
const page = Number(url.searchParams.get('page')) || 1;
const perPage = Number(url.searchParams.get('per_page')) || 50;
if (apiKey !== process.env.API_KEY) {
@@ -17,7 +18,7 @@ export const GET = async (request: Request) => {
{ status: 401 }
);
}
const historyData = await getHistory(page, perPage);
const historyData = await get_history(userId, page, perPage);
return NextResponse.json(historyData, { status: 200 });
} catch (error) {
console.error('Error fetching history data:', error);