From 06089c39ed9e35832f6187e9a5403e6ede286532 Mon Sep 17 00:00:00 2001 From: Mavrik Date: Tue, 25 Jun 2024 11:59:09 +0200 Subject: [PATCH] fix: fixed all dynamic server warnings --- app/api/dismiss-log/{ => [index]}/route.ts | 9 ++++----- app/api/validator-graffiti/{ => [index]}/route.ts | 9 ++++----- app/api/validator-metrics/{ => [[...index]]}/route.ts | 9 ++++----- src/components/AlertInfo/PriorityLogAlerts.tsx | 2 +- src/components/ValidatorGraffiti/ValidatorGraffiti.tsx | 2 +- src/components/ValidatorModal/ValidatorModal.tsx | 2 +- 6 files changed, 15 insertions(+), 18 deletions(-) rename app/api/dismiss-log/{ => [index]}/route.ts (73%) rename app/api/validator-graffiti/{ => [index]}/route.ts (73%) rename app/api/validator-metrics/{ => [[...index]]}/route.ts (69%) diff --git a/app/api/dismiss-log/route.ts b/app/api/dismiss-log/[index]/route.ts similarity index 73% rename from app/api/dismiss-log/route.ts rename to app/api/dismiss-log/[index]/route.ts index 49aae2b9..5dfa1eeb 100644 --- a/app/api/dismiss-log/route.ts +++ b/app/api/dismiss-log/[index]/route.ts @@ -1,11 +1,10 @@ import { NextResponse } from 'next/server' -import getReqAuthToken from '../../../utilities/getReqAuthToken'; -import { dismissLogAlert } from '../logs'; +import getReqAuthToken from '../../../../utilities/getReqAuthToken'; +import { dismissLogAlert } from '../../logs'; -export async function GET(req: Request) { +export async function PUT(req: Request, context: any) { try { - const url = new URL(req.url); - const index = url.searchParams.get('index'); + const { index } = context.params; const token = getReqAuthToken(req); if (!index) { diff --git a/app/api/validator-graffiti/route.ts b/app/api/validator-graffiti/[index]/route.ts similarity index 73% rename from app/api/validator-graffiti/route.ts rename to app/api/validator-graffiti/[index]/route.ts index f36e44dc..38539e26 100644 --- a/app/api/validator-graffiti/route.ts +++ b/app/api/validator-graffiti/[index]/route.ts @@ -1,11 +1,10 @@ import { NextResponse } from 'next/server' -import getReqAuthToken from '../../../utilities/getReqAuthToken'; -import { fetchValGraffiti } from '../validator'; +import getReqAuthToken from '../../../../utilities/getReqAuthToken'; +import { fetchValGraffiti } from '../../validator'; -export async function GET(req: Request) { +export async function GET(req: Request, context: any) { try { - const url = new URL(req.url) - const index = url.searchParams.get('index') + const { index } = context.params; const token = getReqAuthToken(req) if (!index) { diff --git a/app/api/validator-metrics/route.ts b/app/api/validator-metrics/[[...index]]/route.ts similarity index 69% rename from app/api/validator-metrics/route.ts rename to app/api/validator-metrics/[[...index]]/route.ts index 75ca0c47..2d87a939 100644 --- a/app/api/validator-metrics/route.ts +++ b/app/api/validator-metrics/[[...index]]/route.ts @@ -1,11 +1,10 @@ import { NextResponse } from 'next/server' -import getReqAuthToken from '../../../utilities/getReqAuthToken'; -import { fetchValMetrics } from '../validator'; +import getReqAuthToken from '../../../../utilities/getReqAuthToken'; +import { fetchValMetrics } from '../../validator'; -export async function GET(req: Request) { +export async function GET(req: Request, context: any) { try { - const url = new URL(req.url) - const index = url.searchParams.get('index') + const { index } = context.params; const token = getReqAuthToken(req) if (!token) { diff --git a/src/components/AlertInfo/PriorityLogAlerts.tsx b/src/components/AlertInfo/PriorityLogAlerts.tsx index 78360eaa..8458b7e5 100644 --- a/src/components/AlertInfo/PriorityLogAlerts.tsx +++ b/src/components/AlertInfo/PriorityLogAlerts.tsx @@ -27,7 +27,7 @@ const PriorityLogAlerts:FC = ({alerts}) => { const dismissAlert = async (id: number) => { try { const token = Cookies.get('session-token') - const {status} = await axios.get(`/api/dismiss-log?index=${id}`, { + const {status} = await axios.put(`/api/dismiss-log/${id}`, undefined,{ headers: { Authorization: `Bearer ${token}` } diff --git a/src/components/ValidatorGraffiti/ValidatorGraffiti.tsx b/src/components/ValidatorGraffiti/ValidatorGraffiti.tsx index 85bb7455..828832bb 100644 --- a/src/components/ValidatorGraffiti/ValidatorGraffiti.tsx +++ b/src/components/ValidatorGraffiti/ValidatorGraffiti.tsx @@ -37,7 +37,7 @@ const ValidatorGraffiti:FC = ({validator}) => { const fetchGraffiti = async () => { try { - const { data } = await axios.get(`/api/validator-graffiti?index=${index}`, config) + const { data } = await axios.get(`/api/validator-graffiti/${index}`, config) if (data) { setGraffiti(data.data) diff --git a/src/components/ValidatorModal/ValidatorModal.tsx b/src/components/ValidatorModal/ValidatorModal.tsx index dac24696..3e333b92 100644 --- a/src/components/ValidatorModal/ValidatorModal.tsx +++ b/src/components/ValidatorModal/ValidatorModal.tsx @@ -42,7 +42,7 @@ const ValidatorModal: FC = ({ const { index, status } = validator const { data: validatorMetric } = useSWRPolling( - status !== 'withdrawal_done' ? `/api/validator-metrics?index=${index}` : null, + status !== 'withdrawal_done' ? `/api/validator-metrics/${index}` : null, { refreshInterval: 5 * 1000 }, )