feat: redesign superadmin agencies list, implement flat design, add date filters, and fix UI bugs
This commit is contained in:
@@ -60,24 +60,30 @@ func (s *AgencyService) RegisterAgency(req domain.RegisterAgencyRequest) (*domai
|
||||
if req.Complement != "" {
|
||||
address += " - " + req.Complement
|
||||
}
|
||||
if req.Neighborhood != "" {
|
||||
address += " - " + req.Neighborhood
|
||||
}
|
||||
|
||||
tenant := &domain.Tenant{
|
||||
Name: req.AgencyName,
|
||||
Domain: fmt.Sprintf("%s.%s", req.Subdomain, s.cfg.App.BaseDomain),
|
||||
Subdomain: req.Subdomain,
|
||||
CNPJ: req.CNPJ,
|
||||
RazaoSocial: req.RazaoSocial,
|
||||
Email: req.AdminEmail,
|
||||
Website: req.Website,
|
||||
Address: address,
|
||||
City: req.City,
|
||||
State: req.State,
|
||||
Zip: req.CEP,
|
||||
Description: req.Description,
|
||||
Industry: req.Industry,
|
||||
Name: req.AgencyName,
|
||||
Domain: fmt.Sprintf("%s.%s", req.Subdomain, s.cfg.App.BaseDomain),
|
||||
Subdomain: req.Subdomain,
|
||||
CNPJ: req.CNPJ,
|
||||
RazaoSocial: req.RazaoSocial,
|
||||
Email: req.AdminEmail,
|
||||
Phone: req.Phone,
|
||||
Website: req.Website,
|
||||
Address: address,
|
||||
Neighborhood: req.Neighborhood,
|
||||
Number: req.Number,
|
||||
Complement: req.Complement,
|
||||
City: req.City,
|
||||
State: req.State,
|
||||
Zip: req.CEP,
|
||||
Description: req.Description,
|
||||
Industry: req.Industry,
|
||||
TeamSize: req.TeamSize,
|
||||
PrimaryColor: req.PrimaryColor,
|
||||
SecondaryColor: req.SecondaryColor,
|
||||
LogoURL: req.LogoURL,
|
||||
LogoHorizontalURL: req.LogoHorizontalURL,
|
||||
}
|
||||
|
||||
if err := s.tenantRepo.Create(tenant); err != nil {
|
||||
@@ -189,3 +195,16 @@ func (s *AgencyService) DeleteAgency(id uuid.UUID) error {
|
||||
|
||||
return s.tenantRepo.Delete(id)
|
||||
}
|
||||
|
||||
// UpdateAgencyStatus updates the is_active status of a tenant
|
||||
func (s *AgencyService) UpdateAgencyStatus(id uuid.UUID, isActive bool) error {
|
||||
tenant, err := s.tenantRepo.FindByID(id)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if tenant == nil {
|
||||
return ErrTenantNotFound
|
||||
}
|
||||
|
||||
return s.tenantRepo.UpdateStatus(id, isActive)
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package service
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"log"
|
||||
"time"
|
||||
|
||||
"aggios-app/backend/internal/config"
|
||||
@@ -78,14 +79,20 @@ func (s *AuthService) Login(req domain.LoginRequest) (*domain.LoginResponse, err
|
||||
// Find user by email
|
||||
user, err := s.userRepo.FindByEmail(req.Email)
|
||||
if err != nil {
|
||||
log.Printf("❌ DB error finding user %s: %v", req.Email, err)
|
||||
return nil, err
|
||||
}
|
||||
if user == nil {
|
||||
log.Printf("❌ User not found: %s", req.Email)
|
||||
return nil, ErrInvalidCredentials
|
||||
}
|
||||
|
||||
log.Printf("🔍 Attempting login for %s with password_hash: %.10s...", req.Email, user.Password)
|
||||
log.Printf("🔍 Provided password length: %d", len(req.Password))
|
||||
|
||||
// Verify password
|
||||
if err := bcrypt.CompareHashAndPassword([]byte(user.Password), []byte(req.Password)); err != nil {
|
||||
log.Printf("❌ Password mismatch for %s: %v", req.Email, err)
|
||||
return nil, ErrInvalidCredentials
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user