{editingName ? (
) : (
{company.name}
)}
{company.phone && <>{company.phone}>}
{company.phone && company.address && ' ยท '}
{company.address && <>{company.address}>}
{!company.phone && !company.address && 'No contact info'}
๐
{projects.length}
Projects
โก
{activeTasks.length}
Active Jobs
โ
{completedTasks.length}
Completed
๐
{new Date(company.created_at).toLocaleDateString()}
Since
{/* Tabs */}
{['users', 'projects', 'pricing'].map(t => (
))}
{/* Users Tab */}
{tab === 'users' && (
Assigned Users
{users.length === 0 ? (
No users assigned to this company yet.
) : (
{users.map((user, i) => (
{user.name?.split(' ').map(n => n[0]).join('').toUpperCase().slice(0, 2)}
{editingUserId === user.id ? (
setEditUserVal(e.target.value)}
autoFocus
style={{ margin: 0, fontSize: 13, padding: '3px 8px', width: 180 }}
onKeyDown={e => { if (e.key === 'Enter') handleEditUserSave(user.id); if (e.key === 'Escape') setEditingUserId(null); }}
/>
) : (
<>
{user.name}
{user.email || 'โ'}
{user.role || 'โ'}
>
)}
{editingUserId !== user.id && (
)}
))}
)}
{availableUsers.length > 0 && (
Available Users
Add an existing client user to this company. External subcontractors are assigned to projects instead.
{availableUsers.map(user => (
{editingUserId === user.id ? (
setEditUserVal(e.target.value)}
autoFocus
style={{ margin: 0, fontSize: 13, padding: '3px 8px', width: 180 }}
onKeyDown={e => { if (e.key === 'Enter') handleEditUserSave(user.id); if (e.key === 'Escape') setEditingUserId(null); }}
/>
) : (
<>
{user.name}
{user.email}
{user.role || 'โ'}
>
)}
{editingUserId !== user.id && (
)}
))}
)}
)}
{/* Projects Tab */}
{tab === 'projects' && (
{showNewProject && (
)}
{projects.length === 0 ? (
No projects yet
Create a project to start adding jobs.
) : (
{projects.map(project => {
const projectTasks = tasks.filter(t => t.project_id === project.id);
const active = projectTasks.filter(t => t.status !== 'client_approved').length;
const done = projectTasks.filter(t => t.status === 'client_approved').length;
return (
{project.name}
{projectTasks.length} job{projectTasks.length !== 1 ? 's' : ''}
{active > 0 && <> ยท {active} active>}
{done > 0 && <> ยท {done} done>}
{' ยท '}Started {new Date(project.created_at).toLocaleDateString()}
โบ
);
})}
)}
)}
{/* Pricing Tab */}
{tab === 'pricing' && (
Price List โ {company.name}
Set prices per service type for this company. These auto-fill when creating an invoice.
{['New', 'Revision'].map(label => (
{label}
))}
{serviceTypes.map(serviceType => (
{serviceType}
{['new', 'revision'].map(priceType => (
$
handlePriceChange(serviceType, priceType, e.target.value)}
style={{ margin: 0, width: '100%', textAlign: 'right' }}
/>
))}
))}
)}
);
}