feat: validate user availability

This commit is contained in:
Mann Patel
2025-09-09 10:42:24 -06:00
parent 287068becf
commit 144436bbf3
13 changed files with 544 additions and 704 deletions

View File

@@ -2,10 +2,33 @@ package handlers
import (
"fmt"
"net/http"
"time"
"github.com/patel-mann/poll-system/app/internal/models"
)
func VolunteerSchedualHandler(w *http.ResponseWriter, r http.Request) {
func ValidatedFreeTime(parsedDate time.Time, assignTime time.Time, userID int) (bool) {
var startTime, endTime time.Time
fmt.Print("Not Implementated Yet!!!")
dateOnly := parsedDate.Format("2006-01-02")
err := models.DB.QueryRow(
`SELECT start_time, end_time
FROM availability
WHERE user_id = $1 AND day = $2`,
userID, dateOnly,
).Scan(&startTime, &endTime)
if err != nil {
fmt.Printf("Database query failed: %v\n", err)
return false
}
if assignTime.After(startTime) && assignTime.Before(endTime) {
return true
}else{
return false
}
return false
}