Initial commit
This commit is contained in:
28
app/api/admin/last-reset/route.ts
Normal file
28
app/api/admin/last-reset/route.ts
Normal file
@@ -0,0 +1,28 @@
|
||||
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 })
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user