1.1.4 - updated user modals
This commit is contained in:
@@ -11,7 +11,7 @@ export async function POST(request: Request) {
|
||||
|
||||
// Get admin's field, department, and team
|
||||
const adminData = (await executeQuery(
|
||||
"SELECT field, department, team FROM users WHERE national_id = ? AND role IS NOT NULL AND role != 'user'",
|
||||
"SELECT role, field, department, team FROM users WHERE national_id = ? AND role IS NOT NULL AND role != 'user'",
|
||||
[adminId],
|
||||
)) as any[]
|
||||
|
||||
@@ -19,10 +19,19 @@ export async function POST(request: Request) {
|
||||
return NextResponse.json({ error: "מנהל לא נמצא" }, { status: 404 })
|
||||
}
|
||||
|
||||
const { field: adminField, department: adminDepartment, team: adminTeam } = adminData[0]
|
||||
const { role: adminRole, field: adminField, department: adminDepartment, team: adminTeam } = adminData[0]
|
||||
|
||||
if (!adminField || !adminDepartment || !adminTeam) {
|
||||
return NextResponse.json({ error: "למנהל לא הוגדרו תחום, מסגרת וצוות" }, { status: 400 })
|
||||
if (adminRole !== "team_admin" && adminRole !== "global_admin" || !adminField || !adminDepartment || !adminTeam) {
|
||||
return NextResponse.json({
|
||||
no_report: 0,
|
||||
in_shelter: 0,
|
||||
not_in_shelter: 0,
|
||||
no_alarm: 0,
|
||||
safe_after_exit: 0,
|
||||
field: adminField,
|
||||
department: adminDepartment,
|
||||
team: adminTeam,
|
||||
})
|
||||
}
|
||||
|
||||
// Get team stats with full context (field + department + team)
|
||||
|
||||
Reference in New Issue
Block a user