refactor: restructure in entirety
This commit is contained in:
53
internal/handler/modal.go
Normal file
53
internal/handler/modal.go
Normal file
@@ -0,0 +1,53 @@
|
||||
package handler
|
||||
|
||||
import (
|
||||
"billit/internal/view"
|
||||
"strings"
|
||||
|
||||
"github.com/labstack/echo/v4"
|
||||
)
|
||||
|
||||
// ModalHandlers holds dependencies
|
||||
type ModalHandlers struct{}
|
||||
|
||||
// NewModalHandlers creates new handlers
|
||||
func NewModalHandlers() *ModalHandlers {
|
||||
return &ModalHandlers{}
|
||||
}
|
||||
|
||||
// ConfirmHandler renders the confirmation modal
|
||||
func (h *ModalHandlers) ConfirmHandler(c echo.Context) error {
|
||||
title := c.QueryParam("title")
|
||||
if title == "" {
|
||||
title = "Confirm Action"
|
||||
}
|
||||
|
||||
message := c.QueryParam("message")
|
||||
if message == "" {
|
||||
message = "Are you sure you want to proceed?"
|
||||
}
|
||||
|
||||
confirmText := c.QueryParam("confirm_text")
|
||||
if confirmText == "" {
|
||||
confirmText = "Confirm"
|
||||
}
|
||||
|
||||
url := c.QueryParam("url")
|
||||
method := c.QueryParam("method")
|
||||
if method == "" {
|
||||
method = "delete" // Default to delete
|
||||
}
|
||||
|
||||
target := c.QueryParam("target")
|
||||
|
||||
props := view.ModalProps{
|
||||
Title: title,
|
||||
Message: message,
|
||||
ConfirmText: confirmText,
|
||||
ConfirmURL: url,
|
||||
Method: strings.ToLower(method),
|
||||
Target: target,
|
||||
}
|
||||
|
||||
return view.Render(c, view.Modal(props))
|
||||
}
|
||||
Reference in New Issue
Block a user