fix build issues

This commit is contained in:
2024-02-21 14:45:33 +01:00
parent 72313304fe
commit 2553ab41c1
6 changed files with 6183 additions and 25 deletions

View File

@@ -1,6 +1,7 @@
import { useState, useEffect } from 'react'
import type { NextPage } from 'next'
import Head from 'next/head'
import Link from 'next/link'
interface DashboardStats {
total_sources: number
@@ -90,7 +91,7 @@ const AdminDashboard: NextPage = () => {
<div style={{ marginTop: '40px' }}>
<h2>Rýchle akcie</h2>
<div style={{ display: 'flex', gap: '15px', marginTop: '20px' }}>
<a href="/admin/sources" style={{
<Link href="/admin/sources" style={{
padding: '12px 24px',
backgroundColor: '#3b82f6',
color: 'white',
@@ -98,8 +99,8 @@ const AdminDashboard: NextPage = () => {
borderRadius: '6px'
}}>
Správa zdrojov
</a>
<a href="/admin/reports" style={{
</Link>
<Link href="/admin/reports" style={{
padding: '12px 24px',
backgroundColor: '#10b981',
color: 'white',
@@ -107,7 +108,7 @@ const AdminDashboard: NextPage = () => {
borderRadius: '6px'
}}>
Hlásenia
</a>
</Link>
</div>
</div>
</div>

View File

@@ -1,6 +1,7 @@
import { useState, useEffect } from 'react'
import { useState, useEffect, useCallback } from 'react'
import type { NextPage } from 'next'
import Head from 'next/head'
import Link from 'next/link'
interface Source {
id: number
@@ -18,11 +19,7 @@ const SourcesManagement: NextPage = () => {
const [loading, setLoading] = useState(true)
const [filter, setFilter] = useState('pending')
useEffect(() => {
fetchSources()
}, [filter])
const fetchSources = async () => {
const fetchSources = useCallback(async () => {
try {
const response = await fetch(`/api/admin/sources?status=${filter}`)
if (response.ok) {
@@ -34,7 +31,11 @@ const SourcesManagement: NextPage = () => {
} finally {
setLoading(false)
}
}
}, [filter])
useEffect(() => {
fetchSources()
}, [fetchSources])
const updateSource = async (id: number, status: string, riskLevel: number) => {
try {
@@ -158,7 +159,7 @@ const SourcesManagement: NextPage = () => {
)}
<div style={{ marginTop: '30px' }}>
<a href="/admin" style={{
<Link href="/admin" style={{
padding: '10px 20px',
backgroundColor: '#6b7280',
color: 'white',
@@ -166,7 +167,7 @@ const SourcesManagement: NextPage = () => {
borderRadius: '6px'
}}>
Späť na dashboard
</a>
</Link>
</div>
</div>
</div>

View File

@@ -76,7 +76,7 @@ export default async function handler(
.split(',')
.filter(Boolean)
const uniqueCategories = [...new Set(allCategories)]
const uniqueCategories = Array.from(new Set(allCategories))
let message = ''
if (maxRiskLevel >= 4) {