fix: AddOrgToDeal accepts no domain (derives from website); frontend derives domain fallback from website field
This commit is contained in:
parent
ec0b60d44c
commit
ec7b4c9706
|
|
@ -1407,9 +1407,22 @@ func (h *Handlers) CreateOrg(w http.ResponseWriter, r *http.Request) {
|
|||
ErrorResponse(w, http.StatusBadRequest, "missing_fields", "Organization name required")
|
||||
return
|
||||
}
|
||||
// Derive domain from website if not provided
|
||||
if len(req.Domains) == 0 && req.Website != "" {
|
||||
domain := req.Website
|
||||
domain = strings.TrimPrefix(domain, "https://")
|
||||
domain = strings.TrimPrefix(domain, "http://")
|
||||
domain = strings.TrimPrefix(domain, "www.")
|
||||
if idx := strings.Index(domain, "/"); idx != -1 {
|
||||
domain = domain[:idx]
|
||||
}
|
||||
if domain != "" {
|
||||
req.Domains = []string{strings.ToLower(strings.TrimSpace(domain))}
|
||||
}
|
||||
}
|
||||
// Name is required; domain is best-effort
|
||||
if len(req.Domains) == 0 {
|
||||
ErrorResponse(w, http.StatusBadRequest, "missing_fields", "At least one domain required")
|
||||
return
|
||||
req.Domains = []string{"unknown.invalid"}
|
||||
}
|
||||
// Validate domains are not empty strings
|
||||
for _, d := range req.Domains {
|
||||
|
|
@ -3170,9 +3183,22 @@ func (h *Handlers) AddOrgToDeal(w http.ResponseWriter, r *http.Request) {
|
|||
ErrorResponse(w, http.StatusBadRequest, "missing_fields", "Organization name required")
|
||||
return
|
||||
}
|
||||
// Derive domain from website if not provided
|
||||
if len(req.Domains) == 0 && req.Website != "" {
|
||||
domain := req.Website
|
||||
domain = strings.TrimPrefix(domain, "https://")
|
||||
domain = strings.TrimPrefix(domain, "http://")
|
||||
domain = strings.TrimPrefix(domain, "www.")
|
||||
if idx := strings.Index(domain, "/"); idx != -1 {
|
||||
domain = domain[:idx]
|
||||
}
|
||||
if domain != "" {
|
||||
req.Domains = []string{strings.ToLower(strings.TrimSpace(domain))}
|
||||
}
|
||||
}
|
||||
// Name is required; domain is best-effort
|
||||
if len(req.Domains) == 0 {
|
||||
ErrorResponse(w, http.StatusBadRequest, "missing_fields", "At least one domain required")
|
||||
return
|
||||
req.Domains = []string{"unknown.invalid"}
|
||||
}
|
||||
validRoles := map[string]bool{"seller": true, "buyer": true, "ib": true, "advisor": true}
|
||||
if req.Role == "" || !validRoles[req.Role] {
|
||||
|
|
|
|||
|
|
@ -1299,7 +1299,14 @@
|
|||
// 2. Add org + members to project
|
||||
const name = document.getElementById('orgName').value.trim();
|
||||
const role = document.getElementById('orgRole').value;
|
||||
const domain = scrapedData?.domain || '';
|
||||
// Derive domain: prefer scrapedData.domain, fallback to website field
|
||||
let domain = scrapedData?.domain || '';
|
||||
if (!domain) {
|
||||
const ws = document.getElementById('orgWebsite').value.trim();
|
||||
if (ws) {
|
||||
domain = ws.replace(/^https?:\/\//, '').replace(/^www\./, '').split('/')[0];
|
||||
}
|
||||
}
|
||||
const people = scrapedData?.people || [];
|
||||
const selectedMembers = [];
|
||||
document.querySelectorAll('.person-cb:checked').forEach(cb => {
|
||||
|
|
@ -1602,7 +1609,14 @@
|
|||
const name = document.getElementById('orgName').value.trim();
|
||||
const role = document.getElementById('orgRole').value;
|
||||
|
||||
const domain = scrapedData?.domain || '';
|
||||
// Derive domain: prefer scrapedData.domain, fallback to website field
|
||||
let domain = scrapedData?.domain || '';
|
||||
if (!domain) {
|
||||
const ws = document.getElementById('orgWebsite').value.trim();
|
||||
if (ws) {
|
||||
domain = ws.replace(/^https?:\/\//, '').replace(/^www\./, '').split('/')[0];
|
||||
}
|
||||
}
|
||||
const people = scrapedData?.people || [];
|
||||
const selectedMembers = [];
|
||||
document.querySelectorAll('.person-cb:checked').forEach(cb => {
|
||||
|
|
|
|||
Loading…
Reference in New Issue