feat: redesign superadmin agencies list, implement flat design, add date filters, and fix UI bugs
This commit is contained in:
@@ -22,34 +22,50 @@ func NewAgencyHandler(tenantRepo *repository.TenantRepository) *AgencyHandler {
|
||||
}
|
||||
|
||||
type AgencyProfileResponse struct {
|
||||
ID string `json:"id"`
|
||||
Name string `json:"name"`
|
||||
CNPJ string `json:"cnpj"`
|
||||
Email string `json:"email"`
|
||||
Phone string `json:"phone"`
|
||||
Website string `json:"website"`
|
||||
Address string `json:"address"`
|
||||
City string `json:"city"`
|
||||
State string `json:"state"`
|
||||
Zip string `json:"zip"`
|
||||
RazaoSocial string `json:"razao_social"`
|
||||
Description string `json:"description"`
|
||||
Industry string `json:"industry"`
|
||||
ID string `json:"id"`
|
||||
Name string `json:"name"`
|
||||
CNPJ string `json:"cnpj"`
|
||||
Email string `json:"email"`
|
||||
Phone string `json:"phone"`
|
||||
Website string `json:"website"`
|
||||
Address string `json:"address"`
|
||||
Neighborhood string `json:"neighborhood"`
|
||||
Number string `json:"number"`
|
||||
Complement string `json:"complement"`
|
||||
City string `json:"city"`
|
||||
State string `json:"state"`
|
||||
Zip string `json:"zip"`
|
||||
RazaoSocial string `json:"razao_social"`
|
||||
Description string `json:"description"`
|
||||
Industry string `json:"industry"`
|
||||
TeamSize string `json:"team_size"`
|
||||
PrimaryColor string `json:"primary_color"`
|
||||
SecondaryColor string `json:"secondary_color"`
|
||||
LogoURL string `json:"logo_url"`
|
||||
LogoHorizontalURL string `json:"logo_horizontal_url"`
|
||||
}
|
||||
|
||||
type UpdateAgencyProfileRequest struct {
|
||||
Name string `json:"name"`
|
||||
CNPJ string `json:"cnpj"`
|
||||
Email string `json:"email"`
|
||||
Phone string `json:"phone"`
|
||||
Website string `json:"website"`
|
||||
Address string `json:"address"`
|
||||
City string `json:"city"`
|
||||
State string `json:"state"`
|
||||
Zip string `json:"zip"`
|
||||
RazaoSocial string `json:"razao_social"`
|
||||
Description string `json:"description"`
|
||||
Industry string `json:"industry"`
|
||||
Name string `json:"name"`
|
||||
CNPJ string `json:"cnpj"`
|
||||
Email string `json:"email"`
|
||||
Phone string `json:"phone"`
|
||||
Website string `json:"website"`
|
||||
Address string `json:"address"`
|
||||
Neighborhood string `json:"neighborhood"`
|
||||
Number string `json:"number"`
|
||||
Complement string `json:"complement"`
|
||||
City string `json:"city"`
|
||||
State string `json:"state"`
|
||||
Zip string `json:"zip"`
|
||||
RazaoSocial string `json:"razao_social"`
|
||||
Description string `json:"description"`
|
||||
Industry string `json:"industry"`
|
||||
TeamSize string `json:"team_size"`
|
||||
PrimaryColor string `json:"primary_color"`
|
||||
SecondaryColor string `json:"secondary_color"`
|
||||
LogoURL string `json:"logo_url"`
|
||||
LogoHorizontalURL string `json:"logo_horizontal_url"`
|
||||
}
|
||||
|
||||
// GetProfile returns the current agency profile
|
||||
@@ -61,10 +77,8 @@ func (h *AgencyHandler) GetProfile(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
// Get tenant from context (set by auth middleware)
|
||||
tenantID := r.Context().Value(middleware.TenantIDKey)
|
||||
log.Printf("DEBUG GetProfile: tenantID from context = %v (type: %T)", tenantID, tenantID)
|
||||
|
||||
if tenantID == nil {
|
||||
log.Printf("DEBUG GetProfile: tenantID is nil from auth middleware")
|
||||
http.Error(w, "Tenant not found in context", http.StatusUnauthorized)
|
||||
return
|
||||
}
|
||||
@@ -87,20 +101,32 @@ func (h *AgencyHandler) GetProfile(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
log.Printf("🔍 GetProfile for tenant %s: Found %s", tid, tenant.Name)
|
||||
log.Printf("📄 Tenant Data: Address=%s, Number=%s, TeamSize=%s, RazaoSocial=%s",
|
||||
tenant.Address, tenant.Number, tenant.TeamSize, tenant.RazaoSocial)
|
||||
|
||||
response := AgencyProfileResponse{
|
||||
ID: tenant.ID.String(),
|
||||
Name: tenant.Name,
|
||||
CNPJ: tenant.CNPJ,
|
||||
Email: tenant.Email,
|
||||
Phone: tenant.Phone,
|
||||
Website: tenant.Website,
|
||||
Address: tenant.Address,
|
||||
City: tenant.City,
|
||||
State: tenant.State,
|
||||
Zip: tenant.Zip,
|
||||
RazaoSocial: tenant.RazaoSocial,
|
||||
Description: tenant.Description,
|
||||
Industry: tenant.Industry,
|
||||
ID: tenant.ID.String(),
|
||||
Name: tenant.Name,
|
||||
CNPJ: tenant.CNPJ,
|
||||
Email: tenant.Email,
|
||||
Phone: tenant.Phone,
|
||||
Website: tenant.Website,
|
||||
Address: tenant.Address,
|
||||
Neighborhood: tenant.Neighborhood,
|
||||
Number: tenant.Number,
|
||||
Complement: tenant.Complement,
|
||||
City: tenant.City,
|
||||
State: tenant.State,
|
||||
Zip: tenant.Zip,
|
||||
RazaoSocial: tenant.RazaoSocial,
|
||||
Description: tenant.Description,
|
||||
Industry: tenant.Industry,
|
||||
TeamSize: tenant.TeamSize,
|
||||
PrimaryColor: tenant.PrimaryColor,
|
||||
SecondaryColor: tenant.SecondaryColor,
|
||||
LogoURL: tenant.LogoURL,
|
||||
LogoHorizontalURL: tenant.LogoHorizontalURL,
|
||||
}
|
||||
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
@@ -136,18 +162,26 @@ func (h *AgencyHandler) UpdateProfile(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
// Prepare updates
|
||||
updates := map[string]interface{}{
|
||||
"name": req.Name,
|
||||
"cnpj": req.CNPJ,
|
||||
"razao_social": req.RazaoSocial,
|
||||
"email": req.Email,
|
||||
"phone": req.Phone,
|
||||
"website": req.Website,
|
||||
"address": req.Address,
|
||||
"city": req.City,
|
||||
"state": req.State,
|
||||
"zip": req.Zip,
|
||||
"description": req.Description,
|
||||
"industry": req.Industry,
|
||||
"name": req.Name,
|
||||
"cnpj": req.CNPJ,
|
||||
"razao_social": req.RazaoSocial,
|
||||
"email": req.Email,
|
||||
"phone": req.Phone,
|
||||
"website": req.Website,
|
||||
"address": req.Address,
|
||||
"neighborhood": req.Neighborhood,
|
||||
"number": req.Number,
|
||||
"complement": req.Complement,
|
||||
"city": req.City,
|
||||
"state": req.State,
|
||||
"zip": req.Zip,
|
||||
"description": req.Description,
|
||||
"industry": req.Industry,
|
||||
"team_size": req.TeamSize,
|
||||
"primary_color": req.PrimaryColor,
|
||||
"secondary_color": req.SecondaryColor,
|
||||
"logo_url": req.LogoURL,
|
||||
"logo_horizontal_url": req.LogoHorizontalURL,
|
||||
}
|
||||
|
||||
// Update in database
|
||||
@@ -164,21 +198,30 @@ func (h *AgencyHandler) UpdateProfile(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
|
||||
response := AgencyProfileResponse{
|
||||
ID: tenant.ID.String(),
|
||||
Name: tenant.Name,
|
||||
CNPJ: tenant.CNPJ,
|
||||
Email: tenant.Email,
|
||||
Phone: tenant.Phone,
|
||||
Website: tenant.Website,
|
||||
Address: tenant.Address,
|
||||
City: tenant.City,
|
||||
State: tenant.State,
|
||||
Zip: tenant.Zip,
|
||||
RazaoSocial: tenant.RazaoSocial,
|
||||
Description: tenant.Description,
|
||||
Industry: tenant.Industry,
|
||||
ID: tenant.ID.String(),
|
||||
Name: tenant.Name,
|
||||
CNPJ: tenant.CNPJ,
|
||||
Email: tenant.Email,
|
||||
Phone: tenant.Phone,
|
||||
Website: tenant.Website,
|
||||
Address: tenant.Address,
|
||||
Neighborhood: tenant.Neighborhood,
|
||||
Number: tenant.Number,
|
||||
Complement: tenant.Complement,
|
||||
City: tenant.City,
|
||||
State: tenant.State,
|
||||
Zip: tenant.Zip,
|
||||
RazaoSocial: tenant.RazaoSocial,
|
||||
Description: tenant.Description,
|
||||
Industry: tenant.Industry,
|
||||
TeamSize: tenant.TeamSize,
|
||||
PrimaryColor: tenant.PrimaryColor,
|
||||
SecondaryColor: tenant.SecondaryColor,
|
||||
LogoURL: tenant.LogoURL,
|
||||
LogoHorizontalURL: tenant.LogoHorizontalURL,
|
||||
}
|
||||
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
json.NewEncoder(w).Encode(response)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user