29 lines
849 B
TypeScript
29 lines
849 B
TypeScript
import { NextResponse } from "next/server"
|
|
import { executeQuery } from "@/lib/database"
|
|
|
|
export async function GET() {
|
|
try {
|
|
const results = (await executeQuery(`
|
|
SELECT aa.timestamp, u.name
|
|
FROM admin_actions aa
|
|
JOIN users u ON aa.admin_id = u.national_id
|
|
WHERE aa.action_type = 'reset_all'
|
|
ORDER BY aa.timestamp DESC
|
|
LIMIT 1
|
|
`)) as any[]
|
|
|
|
if (results.length > 0) {
|
|
const result = results[0]
|
|
return NextResponse.json({
|
|
lastReset: `${result.name} - ${new Date(result.timestamp).toLocaleString("he-IL")}`,
|
|
timestamp: result.timestamp,
|
|
})
|
|
}
|
|
|
|
return NextResponse.json({ lastReset: null })
|
|
} catch (error) {
|
|
console.error("Last reset error:", error)
|
|
return NextResponse.json({ error: "שגיאה בטעינת נתונים" }, { status: 500 })
|
|
}
|
|
}
|