Replace company email with address field
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -11,7 +11,7 @@ export default function Companies() {
|
|||||||
const [tasks, setTasks] = useState([]);
|
const [tasks, setTasks] = useState([]);
|
||||||
const [loading, setLoading] = useState(true);
|
const [loading, setLoading] = useState(true);
|
||||||
const [showNew, setShowNew] = useState(false);
|
const [showNew, setShowNew] = useState(false);
|
||||||
const [newForm, setNewForm] = useState({ name: '', email: '', phone: '' });
|
const [newForm, setNewForm] = useState({ name: '', phone: '', address: '' });
|
||||||
const [saving, setSaving] = useState(false);
|
const [saving, setSaving] = useState(false);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@@ -38,8 +38,8 @@ export default function Companies() {
|
|||||||
setSaving(true);
|
setSaving(true);
|
||||||
const { data } = await supabase.from('companies').insert({
|
const { data } = await supabase.from('companies').insert({
|
||||||
name: newForm.name.trim(),
|
name: newForm.name.trim(),
|
||||||
email: newForm.email.trim(),
|
|
||||||
phone: newForm.phone.trim(),
|
phone: newForm.phone.trim(),
|
||||||
|
address: newForm.address.trim(),
|
||||||
}).select().single();
|
}).select().single();
|
||||||
setSaving(false);
|
setSaving(false);
|
||||||
if (data) {
|
if (data) {
|
||||||
@@ -88,15 +88,6 @@ export default function Companies() {
|
|||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div className="grid-2">
|
<div className="grid-2">
|
||||||
<div className="form-group">
|
|
||||||
<label>Email</label>
|
|
||||||
<input
|
|
||||||
type="email"
|
|
||||||
placeholder="contact@acme.com"
|
|
||||||
value={newForm.email}
|
|
||||||
onChange={e => setNewForm(f => ({ ...f, email: e.target.value }))}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
<div className="form-group">
|
<div className="form-group">
|
||||||
<label>Phone</label>
|
<label>Phone</label>
|
||||||
<input
|
<input
|
||||||
@@ -106,6 +97,15 @@ export default function Companies() {
|
|||||||
onChange={e => setNewForm(f => ({ ...f, phone: e.target.value }))}
|
onChange={e => setNewForm(f => ({ ...f, phone: e.target.value }))}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
<div className="form-group">
|
||||||
|
<label>Address</label>
|
||||||
|
<input
|
||||||
|
type="text"
|
||||||
|
placeholder="123 Main St, City, State"
|
||||||
|
value={newForm.address}
|
||||||
|
onChange={e => setNewForm(f => ({ ...f, address: e.target.value }))}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div className="action-buttons">
|
<div className="action-buttons">
|
||||||
<button type="submit" className="btn btn-primary" disabled={saving || !newForm.name.trim()}>
|
<button type="submit" className="btn btn-primary" disabled={saving || !newForm.name.trim()}>
|
||||||
@@ -164,7 +164,7 @@ export default function Companies() {
|
|||||||
{' · '}
|
{' · '}
|
||||||
{companyProjects.length} project{companyProjects.length !== 1 ? 's' : ''}
|
{companyProjects.length} project{companyProjects.length !== 1 ? 's' : ''}
|
||||||
{activeTasks.length > 0 && <> · <span style={{ color: 'var(--accent)', fontWeight: 600 }}>{activeTasks.length} active</span></>}
|
{activeTasks.length > 0 && <> · <span style={{ color: 'var(--accent)', fontWeight: 600 }}>{activeTasks.length} active</span></>}
|
||||||
{company.email && <> · {company.email}</>}
|
{company.phone && <> · {company.phone}</>}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<Link to={`/companies/${company.id}`} className="btn btn-outline btn-sm">View</Link>
|
<Link to={`/companies/${company.id}`} className="btn btn-outline btn-sm">View</Link>
|
||||||
|
|||||||
@@ -110,10 +110,10 @@ export default function CompanyDetail() {
|
|||||||
<div>
|
<div>
|
||||||
<div className="page-title">{company.name}</div>
|
<div className="page-title">{company.name}</div>
|
||||||
<div className="page-subtitle">
|
<div className="page-subtitle">
|
||||||
{company.email && <>{company.email}</>}
|
|
||||||
{company.email && company.phone && ' · '}
|
|
||||||
{company.phone && <>{company.phone}</>}
|
{company.phone && <>{company.phone}</>}
|
||||||
{!company.email && !company.phone && 'No contact info'}
|
{company.phone && company.address && ' · '}
|
||||||
|
{company.address && <>{company.address}</>}
|
||||||
|
{!company.phone && !company.address && 'No contact info'}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<span className="badge badge-client" style={{ fontSize: 13, padding: '6px 14px' }}>Company</span>
|
<span className="badge badge-client" style={{ fontSize: 13, padding: '6px 14px' }}>Company</span>
|
||||||
|
|||||||
+1
-1
@@ -7,8 +7,8 @@
|
|||||||
create table public.companies (
|
create table public.companies (
|
||||||
id uuid default gen_random_uuid() primary key,
|
id uuid default gen_random_uuid() primary key,
|
||||||
name text not null,
|
name text not null,
|
||||||
email text default '',
|
|
||||||
phone text default '',
|
phone text default '',
|
||||||
|
address text default '',
|
||||||
created_at timestamptz default now() not null
|
created_at timestamptz default now() not null
|
||||||
);
|
);
|
||||||
alter table public.companies enable row level security;
|
alter table public.companies enable row level security;
|
||||||
|
|||||||
Reference in New Issue
Block a user