admin core func done
This commit is contained in:
@@ -22,6 +22,8 @@ func VolunteerPostsHandler(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
// Get user info from context
|
||||
role := r.Context().Value("user_role").(int)
|
||||
CurrentUserID := models.GetCurrentUserID(w, r)
|
||||
username,_ := models.GetCurrentUserName(r)
|
||||
|
||||
// Fetch posts from database
|
||||
rows, err := models.DB.Query(`
|
||||
@@ -29,8 +31,10 @@ func VolunteerPostsHandler(w http.ResponseWriter, r *http.Request) {
|
||||
p.content, COALESCE(p.image_url, '') as image_url, p.created_at
|
||||
FROM post p
|
||||
JOIN users u ON p.author_id = u.user_id
|
||||
JOIN admin_volunteers x ON u.user_id = x.admin_id
|
||||
WHERE x.volunteer_id = $1
|
||||
ORDER BY p.created_at DESC
|
||||
`)
|
||||
`,CurrentUserID)
|
||||
if err != nil {
|
||||
fmt.Printf("Database query error: %v\n", err)
|
||||
http.Error(w, "Failed to fetch posts", http.StatusInternalServerError)
|
||||
@@ -66,6 +70,7 @@ func VolunteerPostsHandler(w http.ResponseWriter, r *http.Request) {
|
||||
"IsAuthenticated": true,
|
||||
"ShowAdminNav": showAdminNav,
|
||||
"ShowVolunteerNav": showVolunteerNav,
|
||||
"UserName": username,
|
||||
"Posts": posts,
|
||||
"ActiveSection": "posts",
|
||||
"IsVolunteer": true, // Flag to indicate this is volunteer view
|
||||
|
||||
Reference in New Issue
Block a user