Seth Claude Sonnet 5 commited on
Commit Β·
fe7e466
1
Parent(s): c40de6e
Add Type field (Existing/New) to Contacts/Companies/Leads/Deals, synced like Category
Browse filesCompany gets a new type column, wired through the existing generic
COMPANY_DETAIL_PATCH_FIELDS propagation so it syncs bidirectionally across
Company/Contact/Lead/Deal exactly like Category. Companies page also gets a
Type filter, table column, and inline-add-row selector matching Category's
existing footprint there.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
backend/app/database.py
CHANGED
|
@@ -194,6 +194,7 @@ class Company(Base):
|
|
| 194 |
tenant_id = Column(Integer, ForeignKey("tenants.id"), nullable=True, index=True)
|
| 195 |
name = Column(String, nullable=False, index=True)
|
| 196 |
category = Column(String, default="") # A | B | C | ""
|
|
|
|
| 197 |
company_name_for_emails = Column(String, default="")
|
| 198 |
industry = Column(String, default="")
|
| 199 |
employees = Column(String, default="")
|
|
@@ -792,6 +793,8 @@ def run_migrations(connection_engine):
|
|
| 792 |
compcols = [c["name"] for c in insp.get_columns("companies")]
|
| 793 |
if "phone" not in compcols:
|
| 794 |
conn.execute(text("ALTER TABLE companies ADD COLUMN phone TEXT DEFAULT ''"))
|
|
|
|
|
|
|
| 795 |
|
| 796 |
insp = inspect(connection_engine)
|
| 797 |
if insp.has_table("file_outreach_executions"):
|
|
|
|
| 194 |
tenant_id = Column(Integer, ForeignKey("tenants.id"), nullable=True, index=True)
|
| 195 |
name = Column(String, nullable=False, index=True)
|
| 196 |
category = Column(String, default="") # A | B | C | ""
|
| 197 |
+
type = Column(String, default="") # Existing | New | ""
|
| 198 |
company_name_for_emails = Column(String, default="")
|
| 199 |
industry = Column(String, default="")
|
| 200 |
employees = Column(String, default="")
|
|
|
|
| 793 |
compcols = [c["name"] for c in insp.get_columns("companies")]
|
| 794 |
if "phone" not in compcols:
|
| 795 |
conn.execute(text("ALTER TABLE companies ADD COLUMN phone TEXT DEFAULT ''"))
|
| 796 |
+
if "type" not in compcols:
|
| 797 |
+
conn.execute(text("ALTER TABLE companies ADD COLUMN type TEXT DEFAULT ''"))
|
| 798 |
|
| 799 |
insp = inspect(connection_engine)
|
| 800 |
if insp.has_table("file_outreach_executions"):
|
backend/app/main.py
CHANGED
|
@@ -1048,6 +1048,7 @@ def _convert_contact_to_lead_core(db: Session, contact: Contact) -> dict:
|
|
| 1048 |
"State": _safe_str(rd.get("State")),
|
| 1049 |
"Country": _safe_str(rd.get("Country")),
|
| 1050 |
"Category": _safe_str(rd.get("Category")),
|
|
|
|
| 1051 |
"Phone": _safe_str(rd.get("Phone")),
|
| 1052 |
}
|
| 1053 |
raw = {
|
|
@@ -3753,6 +3754,7 @@ COMPANY_DETAIL_PATCH_FIELDS = {
|
|
| 3753 |
"state": "State",
|
| 3754 |
"country_region": "Country",
|
| 3755 |
"category": "Category",
|
|
|
|
| 3756 |
"company_phone": "Phone",
|
| 3757 |
}
|
| 3758 |
|
|
@@ -3771,6 +3773,7 @@ def _contact_company_details_dict(c: Contact) -> dict:
|
|
| 3771 |
"State": _safe_str(rd.get("State")),
|
| 3772 |
"Country": _safe_str(rd.get("Country")),
|
| 3773 |
"Category": _safe_str(rd.get("Category")),
|
|
|
|
| 3774 |
"Phone": _safe_str(rd.get("Phone")),
|
| 3775 |
}
|
| 3776 |
|
|
@@ -3798,6 +3801,7 @@ def _lead_company_details_dict(row: CrmLead) -> dict:
|
|
| 3798 |
"State": _safe_str(cd.get("State")),
|
| 3799 |
"Country": _safe_str(cd.get("Country")),
|
| 3800 |
"Category": _safe_str(cd.get("Category")),
|
|
|
|
| 3801 |
"Phone": _safe_str(cd.get("Phone")),
|
| 3802 |
}
|
| 3803 |
|
|
@@ -3815,6 +3819,7 @@ def _deal_fallback_company_details(d: CrmDeal) -> dict:
|
|
| 3815 |
"State": "",
|
| 3816 |
"Country": _safe_str(d.country),
|
| 3817 |
"Category": "",
|
|
|
|
| 3818 |
"Phone": "",
|
| 3819 |
}
|
| 3820 |
|
|
@@ -4120,6 +4125,7 @@ def _company_to_dict(c: Company, contact_count: int = None) -> dict:
|
|
| 4120 |
"id": c.id,
|
| 4121 |
"name": c.name or "",
|
| 4122 |
"category": c.category or "",
|
|
|
|
| 4123 |
"company_name_for_emails": c.company_name_for_emails or "",
|
| 4124 |
"industry": c.industry or "",
|
| 4125 |
"employees": c.employees or "",
|
|
@@ -4195,6 +4201,7 @@ def _sync_companies_from_contacts(db: Session, tenant_id: int) -> int:
|
|
| 4195 |
tenant_id=tenant_id,
|
| 4196 |
name=name,
|
| 4197 |
category=details.get("Category", ""),
|
|
|
|
| 4198 |
company_name_for_emails=details.get("Company Name for Emails", ""),
|
| 4199 |
industry=details.get("Industry", ""),
|
| 4200 |
employees=details.get("# Employees", ""),
|
|
@@ -4317,6 +4324,7 @@ def _propagate_company_fields_everywhere(
|
|
| 4317 |
async def list_companies(
|
| 4318 |
search: str = Query("", description="Search by name/industry/city/country"),
|
| 4319 |
category: str = Query("", description="Filter by category: A|B|C"),
|
|
|
|
| 4320 |
sort_by: str = Query("name", description="Sort field: name|created_at|updated_at"),
|
| 4321 |
sort_dir: str = Query("asc", description="Sort direction: asc|desc"),
|
| 4322 |
limit: int = Query(200, ge=1, le=1000),
|
|
@@ -4337,6 +4345,8 @@ async def list_companies(
|
|
| 4337 |
)
|
| 4338 |
if category and category != "all":
|
| 4339 |
query = query.filter(Company.category == category)
|
|
|
|
|
|
|
| 4340 |
|
| 4341 |
sort_col = {
|
| 4342 |
"name": Company.name,
|
|
@@ -4382,6 +4392,7 @@ async def create_company(body: CompanyCreateRequest, t: TenantContext = Depends(
|
|
| 4382 |
tenant_id=t.tenant_id,
|
| 4383 |
name=name,
|
| 4384 |
category=_safe_str(body.category),
|
|
|
|
| 4385 |
company_name_for_emails=_safe_str(body.company_name_for_emails),
|
| 4386 |
industry=_safe_str(body.industry),
|
| 4387 |
employees=_safe_str(body.employees),
|
|
@@ -4483,6 +4494,7 @@ async def patch_company(
|
|
| 4483 |
company.name = name
|
| 4484 |
company_columns = (
|
| 4485 |
"category",
|
|
|
|
| 4486 |
"company_name_for_emails",
|
| 4487 |
"industry",
|
| 4488 |
"employees",
|
|
|
|
| 1048 |
"State": _safe_str(rd.get("State")),
|
| 1049 |
"Country": _safe_str(rd.get("Country")),
|
| 1050 |
"Category": _safe_str(rd.get("Category")),
|
| 1051 |
+
"Type": _safe_str(rd.get("Type")),
|
| 1052 |
"Phone": _safe_str(rd.get("Phone")),
|
| 1053 |
}
|
| 1054 |
raw = {
|
|
|
|
| 3754 |
"state": "State",
|
| 3755 |
"country_region": "Country",
|
| 3756 |
"category": "Category",
|
| 3757 |
+
"type": "Type",
|
| 3758 |
"company_phone": "Phone",
|
| 3759 |
}
|
| 3760 |
|
|
|
|
| 3773 |
"State": _safe_str(rd.get("State")),
|
| 3774 |
"Country": _safe_str(rd.get("Country")),
|
| 3775 |
"Category": _safe_str(rd.get("Category")),
|
| 3776 |
+
"Type": _safe_str(rd.get("Type")),
|
| 3777 |
"Phone": _safe_str(rd.get("Phone")),
|
| 3778 |
}
|
| 3779 |
|
|
|
|
| 3801 |
"State": _safe_str(cd.get("State")),
|
| 3802 |
"Country": _safe_str(cd.get("Country")),
|
| 3803 |
"Category": _safe_str(cd.get("Category")),
|
| 3804 |
+
"Type": _safe_str(cd.get("Type")),
|
| 3805 |
"Phone": _safe_str(cd.get("Phone")),
|
| 3806 |
}
|
| 3807 |
|
|
|
|
| 3819 |
"State": "",
|
| 3820 |
"Country": _safe_str(d.country),
|
| 3821 |
"Category": "",
|
| 3822 |
+
"Type": "",
|
| 3823 |
"Phone": "",
|
| 3824 |
}
|
| 3825 |
|
|
|
|
| 4125 |
"id": c.id,
|
| 4126 |
"name": c.name or "",
|
| 4127 |
"category": c.category or "",
|
| 4128 |
+
"type": c.type or "",
|
| 4129 |
"company_name_for_emails": c.company_name_for_emails or "",
|
| 4130 |
"industry": c.industry or "",
|
| 4131 |
"employees": c.employees or "",
|
|
|
|
| 4201 |
tenant_id=tenant_id,
|
| 4202 |
name=name,
|
| 4203 |
category=details.get("Category", ""),
|
| 4204 |
+
type=details.get("Type", ""),
|
| 4205 |
company_name_for_emails=details.get("Company Name for Emails", ""),
|
| 4206 |
industry=details.get("Industry", ""),
|
| 4207 |
employees=details.get("# Employees", ""),
|
|
|
|
| 4324 |
async def list_companies(
|
| 4325 |
search: str = Query("", description="Search by name/industry/city/country"),
|
| 4326 |
category: str = Query("", description="Filter by category: A|B|C"),
|
| 4327 |
+
type: str = Query("", description="Filter by type: Existing|New"),
|
| 4328 |
sort_by: str = Query("name", description="Sort field: name|created_at|updated_at"),
|
| 4329 |
sort_dir: str = Query("asc", description="Sort direction: asc|desc"),
|
| 4330 |
limit: int = Query(200, ge=1, le=1000),
|
|
|
|
| 4345 |
)
|
| 4346 |
if category and category != "all":
|
| 4347 |
query = query.filter(Company.category == category)
|
| 4348 |
+
if type and type != "all":
|
| 4349 |
+
query = query.filter(Company.type == type)
|
| 4350 |
|
| 4351 |
sort_col = {
|
| 4352 |
"name": Company.name,
|
|
|
|
| 4392 |
tenant_id=t.tenant_id,
|
| 4393 |
name=name,
|
| 4394 |
category=_safe_str(body.category),
|
| 4395 |
+
type=_safe_str(body.type),
|
| 4396 |
company_name_for_emails=_safe_str(body.company_name_for_emails),
|
| 4397 |
industry=_safe_str(body.industry),
|
| 4398 |
employees=_safe_str(body.employees),
|
|
|
|
| 4494 |
company.name = name
|
| 4495 |
company_columns = (
|
| 4496 |
"category",
|
| 4497 |
+
"type",
|
| 4498 |
"company_name_for_emails",
|
| 4499 |
"industry",
|
| 4500 |
"employees",
|
backend/app/models.py
CHANGED
|
@@ -56,6 +56,7 @@ class CrmLeadPatchRequest(BaseModel):
|
|
| 56 |
state: Optional[str] = None
|
| 57 |
country_region: Optional[str] = None
|
| 58 |
category: Optional[str] = None
|
|
|
|
| 59 |
company_phone: Optional[str] = None # the company's main line β synced, distinct from `phone`
|
| 60 |
|
| 61 |
|
|
@@ -86,6 +87,7 @@ class ContactPatchRequest(BaseModel):
|
|
| 86 |
state: Optional[str] = None
|
| 87 |
country_region: Optional[str] = None # raw_data["Country"]
|
| 88 |
category: Optional[str] = None # raw_data["Category"] β "A" | "B" | "C" | ""
|
|
|
|
| 89 |
company_phone: Optional[str] = None # raw_data["Phone"] β company's main line, synced
|
| 90 |
|
| 91 |
|
|
@@ -100,6 +102,7 @@ class BulkContactIdsRequest(BaseModel):
|
|
| 100 |
class CompanyCreateRequest(BaseModel):
|
| 101 |
name: str
|
| 102 |
category: str = ""
|
|
|
|
| 103 |
company_name_for_emails: str = ""
|
| 104 |
industry: str = ""
|
| 105 |
employees: str = ""
|
|
@@ -115,6 +118,7 @@ class CompanyCreateRequest(BaseModel):
|
|
| 115 |
class CompanyPatchRequest(BaseModel):
|
| 116 |
name: Optional[str] = None
|
| 117 |
category: Optional[str] = None
|
|
|
|
| 118 |
company_name_for_emails: Optional[str] = None
|
| 119 |
industry: Optional[str] = None
|
| 120 |
employees: Optional[str] = None
|
|
@@ -265,6 +269,7 @@ class CrmDealPatchRequest(BaseModel):
|
|
| 265 |
state: Optional[str] = None
|
| 266 |
country_region: Optional[str] = None
|
| 267 |
category: Optional[str] = None
|
|
|
|
| 268 |
company_phone: Optional[str] = None
|
| 269 |
# Required (with conditionals) when setting stage to lost
|
| 270 |
lost_reason: Optional[str] = None # price|no_decision|chose_another|didnt_meet_expectation|unknown
|
|
|
|
| 56 |
state: Optional[str] = None
|
| 57 |
country_region: Optional[str] = None
|
| 58 |
category: Optional[str] = None
|
| 59 |
+
type: Optional[str] = None # raw_webhook.company_details["Type"] β "Existing" | "New" | ""
|
| 60 |
company_phone: Optional[str] = None # the company's main line β synced, distinct from `phone`
|
| 61 |
|
| 62 |
|
|
|
|
| 87 |
state: Optional[str] = None
|
| 88 |
country_region: Optional[str] = None # raw_data["Country"]
|
| 89 |
category: Optional[str] = None # raw_data["Category"] β "A" | "B" | "C" | ""
|
| 90 |
+
type: Optional[str] = None # raw_data["Type"] β "Existing" | "New" | ""
|
| 91 |
company_phone: Optional[str] = None # raw_data["Phone"] β company's main line, synced
|
| 92 |
|
| 93 |
|
|
|
|
| 102 |
class CompanyCreateRequest(BaseModel):
|
| 103 |
name: str
|
| 104 |
category: str = ""
|
| 105 |
+
type: str = ""
|
| 106 |
company_name_for_emails: str = ""
|
| 107 |
industry: str = ""
|
| 108 |
employees: str = ""
|
|
|
|
| 118 |
class CompanyPatchRequest(BaseModel):
|
| 119 |
name: Optional[str] = None
|
| 120 |
category: Optional[str] = None
|
| 121 |
+
type: Optional[str] = None
|
| 122 |
company_name_for_emails: Optional[str] = None
|
| 123 |
industry: Optional[str] = None
|
| 124 |
employees: Optional[str] = None
|
|
|
|
| 269 |
state: Optional[str] = None
|
| 270 |
country_region: Optional[str] = None
|
| 271 |
category: Optional[str] = None
|
| 272 |
+
type: Optional[str] = None
|
| 273 |
company_phone: Optional[str] = None
|
| 274 |
# Required (with conditionals) when setting stage to lost
|
| 275 |
lost_reason: Optional[str] = None # price|no_decision|chose_another|didnt_meet_expectation|unknown
|
frontend/src/components/workspace/CompanyDetailsEditor.jsx
CHANGED
|
@@ -6,6 +6,7 @@ import { Select, SelectTrigger, SelectContent, SelectItem } from '@/components/u
|
|
| 6 |
import { cn } from '@/lib/utils';
|
| 7 |
|
| 8 |
const CATEGORY_OPTIONS = ['A', 'B', 'C'];
|
|
|
|
| 9 |
|
| 10 |
function formFromDetails(cd, fallbackCompany = '') {
|
| 11 |
const d = cd || {};
|
|
@@ -22,6 +23,7 @@ function formFromDetails(cd, fallbackCompany = '') {
|
|
| 22 |
state: String(d['State'] || ''),
|
| 23 |
country: String(d['Country'] || ''),
|
| 24 |
category: String(d['Category'] || ''),
|
|
|
|
| 25 |
phone: String(d['Phone'] || ''),
|
| 26 |
};
|
| 27 |
}
|
|
@@ -44,6 +46,7 @@ function buildPatch(variant, form, dealLinkedContact) {
|
|
| 44 |
state: form.state,
|
| 45 |
country_region: form.country,
|
| 46 |
category: form.category,
|
|
|
|
| 47 |
company_phone: form.phone,
|
| 48 |
};
|
| 49 |
if (variant === 'contact') {
|
|
@@ -65,6 +68,7 @@ function buildPatch(variant, form, dealLinkedContact) {
|
|
| 65 |
state: form.state,
|
| 66 |
country: form.country,
|
| 67 |
category: form.category,
|
|
|
|
| 68 |
phone: form.phone,
|
| 69 |
};
|
| 70 |
}
|
|
@@ -173,6 +177,28 @@ export default function CompanyDetailsEditor({
|
|
| 173 |
</div>
|
| 174 |
);
|
| 175 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 176 |
return (
|
| 177 |
<div className={cn('mb-6 flex flex-col gap-4 rounded-xl border border-slate-200 bg-slate-50/50 p-4', className)}>
|
| 178 |
<div className="flex flex-wrap items-start justify-between gap-2">
|
|
@@ -230,6 +256,7 @@ export default function CompanyDetailsEditor({
|
|
| 230 |
{row('Country', 'country')}
|
| 231 |
{row('Phone', 'phone', { placeholder: 'Main company line' })}
|
| 232 |
{categoryRow}
|
|
|
|
| 233 |
</div>
|
| 234 |
|
| 235 |
{!autoSave ? (
|
|
|
|
| 6 |
import { cn } from '@/lib/utils';
|
| 7 |
|
| 8 |
const CATEGORY_OPTIONS = ['A', 'B', 'C'];
|
| 9 |
+
const TYPE_OPTIONS = ['Existing', 'New'];
|
| 10 |
|
| 11 |
function formFromDetails(cd, fallbackCompany = '') {
|
| 12 |
const d = cd || {};
|
|
|
|
| 23 |
state: String(d['State'] || ''),
|
| 24 |
country: String(d['Country'] || ''),
|
| 25 |
category: String(d['Category'] || ''),
|
| 26 |
+
type: String(d['Type'] || ''),
|
| 27 |
phone: String(d['Phone'] || ''),
|
| 28 |
};
|
| 29 |
}
|
|
|
|
| 46 |
state: form.state,
|
| 47 |
country_region: form.country,
|
| 48 |
category: form.category,
|
| 49 |
+
type: form.type,
|
| 50 |
company_phone: form.phone,
|
| 51 |
};
|
| 52 |
if (variant === 'contact') {
|
|
|
|
| 68 |
state: form.state,
|
| 69 |
country: form.country,
|
| 70 |
category: form.category,
|
| 71 |
+
type: form.type,
|
| 72 |
phone: form.phone,
|
| 73 |
};
|
| 74 |
}
|
|
|
|
| 177 |
</div>
|
| 178 |
);
|
| 179 |
|
| 180 |
+
const typeRow = (
|
| 181 |
+
<div>
|
| 182 |
+
<label className="mb-1 block text-xs font-medium text-slate-500">Type</label>
|
| 183 |
+
<Select value={form.type} onValueChange={(v) => setField('type', v)}>
|
| 184 |
+
<SelectTrigger
|
| 185 |
+
className="h-9 w-full border-slate-200 bg-white shadow-none"
|
| 186 |
+
disabled={isInputDisabled('type')}
|
| 187 |
+
>
|
| 188 |
+
<span className="text-sm text-slate-800">{form.type || 'β'}</span>
|
| 189 |
+
</SelectTrigger>
|
| 190 |
+
<SelectContent>
|
| 191 |
+
<SelectItem value="">β</SelectItem>
|
| 192 |
+
{TYPE_OPTIONS.map((opt) => (
|
| 193 |
+
<SelectItem key={opt} value={opt}>
|
| 194 |
+
{opt}
|
| 195 |
+
</SelectItem>
|
| 196 |
+
))}
|
| 197 |
+
</SelectContent>
|
| 198 |
+
</Select>
|
| 199 |
+
</div>
|
| 200 |
+
);
|
| 201 |
+
|
| 202 |
return (
|
| 203 |
<div className={cn('mb-6 flex flex-col gap-4 rounded-xl border border-slate-200 bg-slate-50/50 p-4', className)}>
|
| 204 |
<div className="flex flex-wrap items-start justify-between gap-2">
|
|
|
|
| 256 |
{row('Country', 'country')}
|
| 257 |
{row('Phone', 'phone', { placeholder: 'Main company line' })}
|
| 258 |
{categoryRow}
|
| 259 |
+
{typeRow}
|
| 260 |
</div>
|
| 261 |
|
| 262 |
{!autoSave ? (
|
frontend/src/pages/Companies.jsx
CHANGED
|
@@ -22,6 +22,7 @@ import { cn } from '@/lib/utils';
|
|
| 22 |
import { apiFetch } from '@/lib/api';
|
| 23 |
|
| 24 |
const CATEGORY_OPTIONS = ['A', 'B', 'C'];
|
|
|
|
| 25 |
|
| 26 |
function isRowUiTarget(e) {
|
| 27 |
return Boolean(
|
|
@@ -38,6 +39,7 @@ export default function Companies() {
|
|
| 38 |
const [loading, setLoading] = useState(true);
|
| 39 |
const [search, setSearch] = useState('');
|
| 40 |
const [categoryFilter, setCategoryFilter] = useState('all');
|
|
|
|
| 41 |
const [sectionOpen, setSectionOpen] = useState(true);
|
| 42 |
const [selected, setSelected] = useState(null);
|
| 43 |
const [rowSelection, setRowSelection] = useState({});
|
|
@@ -46,7 +48,7 @@ export default function Companies() {
|
|
| 46 |
const [convertBusy, setConvertBusy] = useState(false);
|
| 47 |
|
| 48 |
const [addingInline, setAddingInline] = useState(false);
|
| 49 |
-
const [inlineDraft, setInlineDraft] = useState({ name: '', category: '' });
|
| 50 |
const [inlineSaving, setInlineSaving] = useState(false);
|
| 51 |
const [inlineError, setInlineError] = useState('');
|
| 52 |
const inlineNameRef = useRef(null);
|
|
@@ -71,6 +73,7 @@ export default function Companies() {
|
|
| 71 |
params.set('sort_dir', 'asc');
|
| 72 |
if (search.trim()) params.set('search', search.trim());
|
| 73 |
if (categoryFilter && categoryFilter !== 'all') params.set('category', categoryFilter);
|
|
|
|
| 74 |
const res = await apiFetch(`/api/companies?${params.toString()}`);
|
| 75 |
if (res.ok) {
|
| 76 |
const data = await res.json();
|
|
@@ -82,7 +85,7 @@ export default function Companies() {
|
|
| 82 |
} finally {
|
| 83 |
setLoading(false);
|
| 84 |
}
|
| 85 |
-
}, [search, categoryFilter]);
|
| 86 |
|
| 87 |
useEffect(() => {
|
| 88 |
const t = setTimeout(() => fetchCompanies(), 250);
|
|
@@ -223,7 +226,7 @@ export default function Companies() {
|
|
| 223 |
|
| 224 |
const beginAddCompany = () => {
|
| 225 |
setAddingInline(true);
|
| 226 |
-
setInlineDraft({ name: '', category: '' });
|
| 227 |
setInlineError('');
|
| 228 |
};
|
| 229 |
|
|
@@ -244,7 +247,7 @@ export default function Companies() {
|
|
| 244 |
const res = await apiFetch('/api/companies', {
|
| 245 |
method: 'POST',
|
| 246 |
headers: { 'Content-Type': 'application/json' },
|
| 247 |
-
body: JSON.stringify({ name, category: inlineDraft.category }),
|
| 248 |
});
|
| 249 |
const data = await res.json().catch(() => ({}));
|
| 250 |
if (res.status === 409) {
|
|
@@ -330,6 +333,20 @@ export default function Companies() {
|
|
| 330 |
))}
|
| 331 |
</SelectContent>
|
| 332 |
</Select>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 333 |
</div>
|
| 334 |
);
|
| 335 |
|
|
@@ -411,6 +428,7 @@ export default function Companies() {
|
|
| 411 |
</th>
|
| 412 |
<th className="px-3 py-2 font-medium">Company</th>
|
| 413 |
<th className="px-3 py-2 font-medium">Category</th>
|
|
|
|
| 414 |
<th className="px-3 py-2 font-medium">Industry</th>
|
| 415 |
<th className="px-3 py-2 font-medium">Website</th>
|
| 416 |
<th className="px-3 py-2 font-medium">Contacts</th>
|
|
@@ -454,6 +472,24 @@ export default function Companies() {
|
|
| 454 |
</SelectContent>
|
| 455 |
</Select>
|
| 456 |
</td>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 457 |
<td className="px-3 py-2 align-top" colSpan={2} aria-hidden />
|
| 458 |
<td className="px-3 py-2 align-top">
|
| 459 |
<div className="flex items-center gap-1">
|
|
@@ -531,6 +567,15 @@ export default function Companies() {
|
|
| 531 |
<span className="text-sm text-slate-400">β</span>
|
| 532 |
)}
|
| 533 |
</td>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 534 |
<td className="px-3 py-2 align-top text-sm text-slate-700 max-w-[200px]">
|
| 535 |
{company.industry || 'β'}
|
| 536 |
</td>
|
|
@@ -587,6 +632,7 @@ export default function Companies() {
|
|
| 587 |
State: selected.state || '',
|
| 588 |
Country: selected.country || '',
|
| 589 |
Category: selected.category || '',
|
|
|
|
| 590 |
Phone: selected.phone || '',
|
| 591 |
}}
|
| 592 |
onSave={(patch) => patchCompany(selected.id, patch)}
|
|
|
|
| 22 |
import { apiFetch } from '@/lib/api';
|
| 23 |
|
| 24 |
const CATEGORY_OPTIONS = ['A', 'B', 'C'];
|
| 25 |
+
const TYPE_OPTIONS = ['Existing', 'New'];
|
| 26 |
|
| 27 |
function isRowUiTarget(e) {
|
| 28 |
return Boolean(
|
|
|
|
| 39 |
const [loading, setLoading] = useState(true);
|
| 40 |
const [search, setSearch] = useState('');
|
| 41 |
const [categoryFilter, setCategoryFilter] = useState('all');
|
| 42 |
+
const [typeFilter, setTypeFilter] = useState('all');
|
| 43 |
const [sectionOpen, setSectionOpen] = useState(true);
|
| 44 |
const [selected, setSelected] = useState(null);
|
| 45 |
const [rowSelection, setRowSelection] = useState({});
|
|
|
|
| 48 |
const [convertBusy, setConvertBusy] = useState(false);
|
| 49 |
|
| 50 |
const [addingInline, setAddingInline] = useState(false);
|
| 51 |
+
const [inlineDraft, setInlineDraft] = useState({ name: '', category: '', type: '' });
|
| 52 |
const [inlineSaving, setInlineSaving] = useState(false);
|
| 53 |
const [inlineError, setInlineError] = useState('');
|
| 54 |
const inlineNameRef = useRef(null);
|
|
|
|
| 73 |
params.set('sort_dir', 'asc');
|
| 74 |
if (search.trim()) params.set('search', search.trim());
|
| 75 |
if (categoryFilter && categoryFilter !== 'all') params.set('category', categoryFilter);
|
| 76 |
+
if (typeFilter && typeFilter !== 'all') params.set('type', typeFilter);
|
| 77 |
const res = await apiFetch(`/api/companies?${params.toString()}`);
|
| 78 |
if (res.ok) {
|
| 79 |
const data = await res.json();
|
|
|
|
| 85 |
} finally {
|
| 86 |
setLoading(false);
|
| 87 |
}
|
| 88 |
+
}, [search, categoryFilter, typeFilter]);
|
| 89 |
|
| 90 |
useEffect(() => {
|
| 91 |
const t = setTimeout(() => fetchCompanies(), 250);
|
|
|
|
| 226 |
|
| 227 |
const beginAddCompany = () => {
|
| 228 |
setAddingInline(true);
|
| 229 |
+
setInlineDraft({ name: '', category: '', type: '' });
|
| 230 |
setInlineError('');
|
| 231 |
};
|
| 232 |
|
|
|
|
| 247 |
const res = await apiFetch('/api/companies', {
|
| 248 |
method: 'POST',
|
| 249 |
headers: { 'Content-Type': 'application/json' },
|
| 250 |
+
body: JSON.stringify({ name, category: inlineDraft.category, type: inlineDraft.type }),
|
| 251 |
});
|
| 252 |
const data = await res.json().catch(() => ({}));
|
| 253 |
if (res.status === 409) {
|
|
|
|
| 333 |
))}
|
| 334 |
</SelectContent>
|
| 335 |
</Select>
|
| 336 |
+
<span className="text-xs font-medium text-slate-500 uppercase tracking-wide">Type</span>
|
| 337 |
+
<Select value={typeFilter} onValueChange={setTypeFilter}>
|
| 338 |
+
<SelectTrigger className="w-[160px] border-slate-200 bg-white h-9">
|
| 339 |
+
<span>{typeFilter === 'all' ? 'All types' : typeFilter}</span>
|
| 340 |
+
</SelectTrigger>
|
| 341 |
+
<SelectContent>
|
| 342 |
+
<SelectItem value="all">All types</SelectItem>
|
| 343 |
+
{TYPE_OPTIONS.map((tOpt) => (
|
| 344 |
+
<SelectItem key={tOpt} value={tOpt}>
|
| 345 |
+
{tOpt}
|
| 346 |
+
</SelectItem>
|
| 347 |
+
))}
|
| 348 |
+
</SelectContent>
|
| 349 |
+
</Select>
|
| 350 |
</div>
|
| 351 |
);
|
| 352 |
|
|
|
|
| 428 |
</th>
|
| 429 |
<th className="px-3 py-2 font-medium">Company</th>
|
| 430 |
<th className="px-3 py-2 font-medium">Category</th>
|
| 431 |
+
<th className="px-3 py-2 font-medium">Type</th>
|
| 432 |
<th className="px-3 py-2 font-medium">Industry</th>
|
| 433 |
<th className="px-3 py-2 font-medium">Website</th>
|
| 434 |
<th className="px-3 py-2 font-medium">Contacts</th>
|
|
|
|
| 472 |
</SelectContent>
|
| 473 |
</Select>
|
| 474 |
</td>
|
| 475 |
+
<td className="px-3 py-2 align-top">
|
| 476 |
+
<Select
|
| 477 |
+
value={inlineDraft.type}
|
| 478 |
+
onValueChange={(v) => setInlineDraft((d) => ({ ...d, type: v }))}
|
| 479 |
+
>
|
| 480 |
+
<SelectTrigger className="h-8 w-[110px] border-slate-200 bg-white shadow-none">
|
| 481 |
+
<span className="text-sm">{inlineDraft.type || 'β'}</span>
|
| 482 |
+
</SelectTrigger>
|
| 483 |
+
<SelectContent>
|
| 484 |
+
<SelectItem value="">β</SelectItem>
|
| 485 |
+
{TYPE_OPTIONS.map((tOpt) => (
|
| 486 |
+
<SelectItem key={tOpt} value={tOpt}>
|
| 487 |
+
{tOpt}
|
| 488 |
+
</SelectItem>
|
| 489 |
+
))}
|
| 490 |
+
</SelectContent>
|
| 491 |
+
</Select>
|
| 492 |
+
</td>
|
| 493 |
<td className="px-3 py-2 align-top" colSpan={2} aria-hidden />
|
| 494 |
<td className="px-3 py-2 align-top">
|
| 495 |
<div className="flex items-center gap-1">
|
|
|
|
| 567 |
<span className="text-sm text-slate-400">β</span>
|
| 568 |
)}
|
| 569 |
</td>
|
| 570 |
+
<td className="px-3 py-2 align-top">
|
| 571 |
+
{company.type ? (
|
| 572 |
+
<span className="rounded-full bg-sky-100 px-2.5 py-0.5 text-xs font-medium text-sky-800">
|
| 573 |
+
{company.type}
|
| 574 |
+
</span>
|
| 575 |
+
) : (
|
| 576 |
+
<span className="text-sm text-slate-400">β</span>
|
| 577 |
+
)}
|
| 578 |
+
</td>
|
| 579 |
<td className="px-3 py-2 align-top text-sm text-slate-700 max-w-[200px]">
|
| 580 |
{company.industry || 'β'}
|
| 581 |
</td>
|
|
|
|
| 632 |
State: selected.state || '',
|
| 633 |
Country: selected.country || '',
|
| 634 |
Category: selected.category || '',
|
| 635 |
+
Type: selected.type || '',
|
| 636 |
Phone: selected.phone || '',
|
| 637 |
}}
|
| 638 |
onSave={(patch) => patchCompany(selected.id, patch)}
|
frontend/src/pages/Contacts.jsx
CHANGED
|
@@ -95,6 +95,7 @@ export default function Contacts() {
|
|
| 95 |
State: rd['State'] ?? '',
|
| 96 |
Country: rd['Country'] ?? '',
|
| 97 |
Category: rd['Category'] ?? '',
|
|
|
|
| 98 |
Phone: rd['Phone'] ?? '',
|
| 99 |
};
|
| 100 |
}, [selectedContactDetails]);
|
|
|
|
| 95 |
State: rd['State'] ?? '',
|
| 96 |
Country: rd['Country'] ?? '',
|
| 97 |
Category: rd['Category'] ?? '',
|
| 98 |
+
Type: rd['Type'] ?? '',
|
| 99 |
Phone: rd['Phone'] ?? '',
|
| 100 |
};
|
| 101 |
}, [selectedContactDetails]);
|