2026-02-17 10:53:20 -06:00
|
|
|
import { useState, useEffect } from "react";
|
2026-02-17 12:24:48 -06:00
|
|
|
import { useMutation, useQueryClient } from "@tanstack/react-query";
|
Overhaul UI with shadcn components and new pages
Add shadcn/ui components (badge, button, card, input, select,
separator). Add company context provider. New pages: Activity,
Approvals, Companies, Costs, Org chart. Restyle existing pages
(Dashboard, Agents, Issues, Goals, Projects) with shadcn components
and dark theme. Update layout, sidebar navigation, and routing.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-17 09:07:32 -06:00
|
|
|
import { useCompany } from "../context/CompanyContext";
|
2026-02-17 20:07:49 -06:00
|
|
|
import { useDialog } from "../context/DialogContext";
|
2026-02-17 10:53:20 -06:00
|
|
|
import { useBreadcrumbs } from "../context/BreadcrumbContext";
|
|
|
|
|
import { companiesApi } from "../api/companies";
|
2026-02-17 12:24:48 -06:00
|
|
|
import { queryKeys } from "../lib/queryKeys";
|
Overhaul UI with shadcn components and new pages
Add shadcn/ui components (badge, button, card, input, select,
separator). Add company context provider. New pages: Activity,
Approvals, Companies, Costs, Org chart. Restyle existing pages
(Dashboard, Agents, Issues, Goals, Projects) with shadcn components
and dark theme. Update layout, sidebar navigation, and routing.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-17 09:07:32 -06:00
|
|
|
import { formatCents } from "../lib/utils";
|
|
|
|
|
import { Input } from "@/components/ui/input";
|
|
|
|
|
import { Button } from "@/components/ui/button";
|
2026-02-17 20:07:49 -06:00
|
|
|
import { Pencil, Check, X, Plus } from "lucide-react";
|
Overhaul UI with shadcn components and new pages
Add shadcn/ui components (badge, button, card, input, select,
separator). Add company context provider. New pages: Activity,
Approvals, Companies, Costs, Org chart. Restyle existing pages
(Dashboard, Agents, Issues, Goals, Projects) with shadcn components
and dark theme. Update layout, sidebar navigation, and routing.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-17 09:07:32 -06:00
|
|
|
|
|
|
|
|
export function Companies() {
|
|
|
|
|
const {
|
|
|
|
|
companies,
|
|
|
|
|
selectedCompanyId,
|
|
|
|
|
setSelectedCompanyId,
|
|
|
|
|
loading,
|
|
|
|
|
error,
|
|
|
|
|
} = useCompany();
|
2026-02-17 20:07:49 -06:00
|
|
|
const { openOnboarding } = useDialog();
|
2026-02-17 10:53:20 -06:00
|
|
|
const { setBreadcrumbs } = useBreadcrumbs();
|
2026-02-17 12:24:48 -06:00
|
|
|
const queryClient = useQueryClient();
|
Overhaul UI with shadcn components and new pages
Add shadcn/ui components (badge, button, card, input, select,
separator). Add company context provider. New pages: Activity,
Approvals, Companies, Costs, Org chart. Restyle existing pages
(Dashboard, Agents, Issues, Goals, Projects) with shadcn components
and dark theme. Update layout, sidebar navigation, and routing.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-17 09:07:32 -06:00
|
|
|
|
2026-02-17 10:53:20 -06:00
|
|
|
// Inline edit state
|
|
|
|
|
const [editingId, setEditingId] = useState<string | null>(null);
|
|
|
|
|
const [editName, setEditName] = useState("");
|
2026-02-17 12:24:48 -06:00
|
|
|
|
|
|
|
|
const editMutation = useMutation({
|
|
|
|
|
mutationFn: ({ id, newName }: { id: string; newName: string }) =>
|
|
|
|
|
companiesApi.update(id, { name: newName }),
|
|
|
|
|
onSuccess: () => {
|
|
|
|
|
queryClient.invalidateQueries({ queryKey: queryKeys.companies.all });
|
|
|
|
|
setEditingId(null);
|
|
|
|
|
},
|
|
|
|
|
});
|
2026-02-17 10:53:20 -06:00
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
setBreadcrumbs([{ label: "Companies" }]);
|
|
|
|
|
}, [setBreadcrumbs]);
|
|
|
|
|
|
|
|
|
|
function startEdit(companyId: string, currentName: string) {
|
|
|
|
|
setEditingId(companyId);
|
|
|
|
|
setEditName(currentName);
|
|
|
|
|
}
|
|
|
|
|
|
2026-02-17 12:24:48 -06:00
|
|
|
function saveEdit() {
|
2026-02-17 10:53:20 -06:00
|
|
|
if (!editingId || !editName.trim()) return;
|
2026-02-17 12:24:48 -06:00
|
|
|
editMutation.mutate({ id: editingId, newName: editName.trim() });
|
2026-02-17 10:53:20 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function cancelEdit() {
|
|
|
|
|
setEditingId(null);
|
|
|
|
|
setEditName("");
|
|
|
|
|
}
|
|
|
|
|
|
Overhaul UI with shadcn components and new pages
Add shadcn/ui components (badge, button, card, input, select,
separator). Add company context provider. New pages: Activity,
Approvals, Companies, Costs, Org chart. Restyle existing pages
(Dashboard, Agents, Issues, Goals, Projects) with shadcn components
and dark theme. Update layout, sidebar navigation, and routing.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-17 09:07:32 -06:00
|
|
|
return (
|
|
|
|
|
<div className="space-y-6">
|
2026-02-17 20:07:49 -06:00
|
|
|
<div className="flex items-center justify-between">
|
|
|
|
|
<div>
|
|
|
|
|
<h2 className="text-lg font-semibold">Companies</h2>
|
|
|
|
|
<p className="text-sm text-muted-foreground">Manage your companies.</p>
|
|
|
|
|
</div>
|
|
|
|
|
<Button size="sm" onClick={openOnboarding}>
|
|
|
|
|
<Plus className="h-3.5 w-3.5 mr-1.5" />
|
|
|
|
|
New Company
|
|
|
|
|
</Button>
|
Overhaul UI with shadcn components and new pages
Add shadcn/ui components (badge, button, card, input, select,
separator). Add company context provider. New pages: Activity,
Approvals, Companies, Costs, Org chart. Restyle existing pages
(Dashboard, Agents, Issues, Goals, Projects) with shadcn components
and dark theme. Update layout, sidebar navigation, and routing.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-17 09:07:32 -06:00
|
|
|
</div>
|
|
|
|
|
|
2026-02-17 11:14:06 -06:00
|
|
|
<div className="h-6">
|
|
|
|
|
{loading && <p className="text-sm text-muted-foreground">Loading companies...</p>}
|
|
|
|
|
{error && <p className="text-sm text-destructive">{error.message}</p>}
|
|
|
|
|
</div>
|
Overhaul UI with shadcn components and new pages
Add shadcn/ui components (badge, button, card, input, select,
separator). Add company context provider. New pages: Activity,
Approvals, Companies, Costs, Org chart. Restyle existing pages
(Dashboard, Agents, Issues, Goals, Projects) with shadcn components
and dark theme. Update layout, sidebar navigation, and routing.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-17 09:07:32 -06:00
|
|
|
|
|
|
|
|
<div className="grid gap-3">
|
|
|
|
|
{companies.map((company) => {
|
|
|
|
|
const selected = company.id === selectedCompanyId;
|
2026-02-17 10:53:20 -06:00
|
|
|
const isEditing = editingId === company.id;
|
|
|
|
|
|
Overhaul UI with shadcn components and new pages
Add shadcn/ui components (badge, button, card, input, select,
separator). Add company context provider. New pages: Activity,
Approvals, Companies, Costs, Org chart. Restyle existing pages
(Dashboard, Agents, Issues, Goals, Projects) with shadcn components
and dark theme. Update layout, sidebar navigation, and routing.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-17 09:07:32 -06:00
|
|
|
return (
|
2026-02-17 13:39:47 -06:00
|
|
|
<div
|
Overhaul UI with shadcn components and new pages
Add shadcn/ui components (badge, button, card, input, select,
separator). Add company context provider. New pages: Activity,
Approvals, Companies, Costs, Org chart. Restyle existing pages
(Dashboard, Agents, Issues, Goals, Projects) with shadcn components
and dark theme. Update layout, sidebar navigation, and routing.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-17 09:07:32 -06:00
|
|
|
key={company.id}
|
2026-02-17 13:39:47 -06:00
|
|
|
role="button"
|
|
|
|
|
tabIndex={0}
|
Overhaul UI with shadcn components and new pages
Add shadcn/ui components (badge, button, card, input, select,
separator). Add company context provider. New pages: Activity,
Approvals, Companies, Costs, Org chart. Restyle existing pages
(Dashboard, Agents, Issues, Goals, Projects) with shadcn components
and dark theme. Update layout, sidebar navigation, and routing.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-17 09:07:32 -06:00
|
|
|
onClick={() => setSelectedCompanyId(company.id)}
|
2026-02-17 13:39:47 -06:00
|
|
|
onKeyDown={(e) => {
|
|
|
|
|
if (e.key === "Enter" || e.key === " ") {
|
|
|
|
|
e.preventDefault();
|
|
|
|
|
setSelectedCompanyId(company.id);
|
|
|
|
|
}
|
|
|
|
|
}}
|
|
|
|
|
className={`group text-left bg-card border rounded-lg p-4 transition-colors cursor-pointer ${
|
2026-02-17 10:53:20 -06:00
|
|
|
selected ? "border-primary ring-1 ring-primary" : "border-border hover:border-muted-foreground/30"
|
Overhaul UI with shadcn components and new pages
Add shadcn/ui components (badge, button, card, input, select,
separator). Add company context provider. New pages: Activity,
Approvals, Companies, Costs, Org chart. Restyle existing pages
(Dashboard, Agents, Issues, Goals, Projects) with shadcn components
and dark theme. Update layout, sidebar navigation, and routing.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-17 09:07:32 -06:00
|
|
|
}`}
|
|
|
|
|
>
|
|
|
|
|
<div className="flex items-center justify-between">
|
2026-02-17 10:53:20 -06:00
|
|
|
<div className="flex-1 min-w-0">
|
|
|
|
|
{isEditing ? (
|
|
|
|
|
<div className="flex items-center gap-2" onClick={(e) => e.stopPropagation()}>
|
|
|
|
|
<Input
|
|
|
|
|
value={editName}
|
|
|
|
|
onChange={(e) => setEditName(e.target.value)}
|
|
|
|
|
className="h-7 text-sm"
|
|
|
|
|
autoFocus
|
|
|
|
|
onKeyDown={(e) => {
|
|
|
|
|
if (e.key === "Enter") saveEdit();
|
|
|
|
|
if (e.key === "Escape") cancelEdit();
|
|
|
|
|
}}
|
|
|
|
|
/>
|
|
|
|
|
<Button
|
|
|
|
|
variant="ghost"
|
|
|
|
|
size="icon-xs"
|
|
|
|
|
onClick={saveEdit}
|
2026-02-17 12:24:48 -06:00
|
|
|
disabled={editMutation.isPending}
|
2026-02-17 10:53:20 -06:00
|
|
|
>
|
|
|
|
|
<Check className="h-3.5 w-3.5 text-green-500" />
|
|
|
|
|
</Button>
|
|
|
|
|
<Button variant="ghost" size="icon-xs" onClick={cancelEdit}>
|
|
|
|
|
<X className="h-3.5 w-3.5 text-muted-foreground" />
|
|
|
|
|
</Button>
|
|
|
|
|
</div>
|
|
|
|
|
) : (
|
|
|
|
|
<div className="flex items-center gap-2">
|
|
|
|
|
<h3 className="font-semibold">{company.name}</h3>
|
|
|
|
|
<Button
|
|
|
|
|
variant="ghost"
|
|
|
|
|
size="icon-xs"
|
|
|
|
|
className="text-muted-foreground opacity-0 group-hover:opacity-100"
|
|
|
|
|
onClick={(e) => {
|
|
|
|
|
e.stopPropagation();
|
|
|
|
|
startEdit(company.id, company.name);
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
<Pencil className="h-3 w-3" />
|
|
|
|
|
</Button>
|
|
|
|
|
</div>
|
|
|
|
|
)}
|
|
|
|
|
{company.description && !isEditing && (
|
Overhaul UI with shadcn components and new pages
Add shadcn/ui components (badge, button, card, input, select,
separator). Add company context provider. New pages: Activity,
Approvals, Companies, Costs, Org chart. Restyle existing pages
(Dashboard, Agents, Issues, Goals, Projects) with shadcn components
and dark theme. Update layout, sidebar navigation, and routing.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-17 09:07:32 -06:00
|
|
|
<p className="text-sm text-muted-foreground mt-1">{company.description}</p>
|
|
|
|
|
)}
|
|
|
|
|
</div>
|
|
|
|
|
<div className="text-sm text-muted-foreground">
|
|
|
|
|
{formatCents(company.spentMonthlyCents)} / {formatCents(company.budgetMonthlyCents)}
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
2026-02-17 13:39:47 -06:00
|
|
|
</div>
|
Overhaul UI with shadcn components and new pages
Add shadcn/ui components (badge, button, card, input, select,
separator). Add company context provider. New pages: Activity,
Approvals, Companies, Costs, Org chart. Restyle existing pages
(Dashboard, Agents, Issues, Goals, Projects) with shadcn components
and dark theme. Update layout, sidebar navigation, and routing.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-17 09:07:32 -06:00
|
|
|
);
|
|
|
|
|
})}
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
}
|