diff --git a/client/src/App.tsx b/client/src/App.tsx index 510de8f..3d6ecfd 100644 --- a/client/src/App.tsx +++ b/client/src/App.tsx @@ -14,7 +14,7 @@ import RolesPage from "@/pages/roles"; import GroupsPage from "@/pages/groups"; import ProvidersPage from "@/pages/providers"; import SettingsPage from "@/pages/settings"; -import OrganizationsPage from "@/pages/organizations"; +import CustomersPage from "@/pages/organizations"; import WebhooksPage from "@/pages/webhooks"; import WebhookLogsPage from "@/pages/webhook-logs"; import { AuthProvider } from "@/hooks/use-auth"; @@ -27,7 +27,7 @@ function Router() { - + diff --git a/client/src/pages/organizations.tsx b/client/src/pages/organizations.tsx index fae0a7d..105ee7b 100644 --- a/client/src/pages/organizations.tsx +++ b/client/src/pages/organizations.tsx @@ -7,8 +7,8 @@ import { Label } from '@/components/ui/label'; import { Input } from '@/components/ui/input'; import { Checkbox } from '@/components/ui/checkbox'; import { Dialog, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle, DialogTrigger } from '@/components/ui/dialog'; -import { Organization } from '@shared/schema'; -import { useOrganization } from '@/context/organization-context'; +import { Customer } from '@shared/schema'; +import { useCustomer } from '@/context/customer-context'; import { useToast } from '@/hooks/use-toast'; import { useAuth } from '@/hooks/use-auth'; import { Users, Plus, Edit, Trash2, Building, Calendar, Clock, Info, AlertCircle } from 'lucide-react'; @@ -26,60 +26,60 @@ import { AlertDialogTitle } from '@/components/ui/alert-dialog'; -export default function OrganizationsPage() { +export default function CustomersPage() { const { user } = useAuth(); const { - organizations, - currentOrganization, - setCurrentOrganization, - createOrganizationMutation, - updateOrganizationMutation, - deleteOrganizationMutation, - domainsByOrganization - } = useOrganization(); + customers, + currentCustomer, + setCurrentCustomer, + createCustomerMutation, + updateCustomerMutation, + deleteCustomerMutation, + domainsByCustomer + } = useCustomer(); const { toast } = useToast(); - const [newOrgName, setNewOrgName] = useState(''); - const [newOrgActive, setNewOrgActive] = useState(true); + const [newCustomerName, setNewCustomerName] = useState(''); + const [newCustomerActive, setNewCustomerActive] = useState(true); const [isDialogOpen, setIsDialogOpen] = useState(false); const [isEditDialogOpen, setIsEditDialogOpen] = useState(false); const [isViewDialogOpen, setIsViewDialogOpen] = useState(false); const [isDeleteDialogOpen, setIsDeleteDialogOpen] = useState(false); - const [selectedOrg, setSelectedOrg] = useState(null); - const [editOrgName, setEditOrgName] = useState(''); - const [editOrgActive, setEditOrgActive] = useState(true); + const [selectedCustomer, setSelectedCustomer] = useState(null); + const [editCustomerName, setEditCustomerName] = useState(''); + const [editCustomerActive, setEditCustomerActive] = useState(true); const isAdmin = user?.role === 'admin'; - const handleCreateOrganization = async (e: React.FormEvent) => { + const handleCreateCustomer = async (e: React.FormEvent) => { e.preventDefault(); - if (!newOrgName.trim()) { + if (!newCustomerName.trim()) { toast({ title: 'Error', - description: 'Organization name cannot be empty', + description: 'Customer name cannot be empty', variant: 'destructive', }); return; } try { - await createOrganizationMutation.mutateAsync({ - name: newOrgName, - isActive: newOrgActive, + await createCustomerMutation.mutateAsync({ + name: newCustomerName, + isActive: newCustomerActive, }); - setNewOrgName(''); - setNewOrgActive(true); + setNewCustomerName(''); + setNewCustomerActive(true); setIsDialogOpen(false); toast({ title: 'Success', - description: 'Organization created successfully', + description: 'Customer created successfully', }); } catch (error) { - console.error('Error creating organization:', error); + console.error('Error creating customer:', error); toast({ title: 'Error', - description: 'Failed to create organization', + description: 'Failed to create customer', variant: 'destructive', }); } @@ -87,43 +87,43 @@ export default function OrganizationsPage() { return (
-

Organizations

+

Customers

{isAdmin && ( - Create New Organization + Create New Customer - Add a new organization to your account. + Add a new customer to your account. -
+
- + setNewOrgName(e.target.value)} - placeholder="Enter organization name" + id="customerName" + value={newCustomerName} + onChange={(e) => setNewCustomerName(e.target.value)} + placeholder="Enter customer name" required />
setNewOrgActive(checked as boolean)} + checked={newCustomerActive} + onCheckedChange={(checked) => setNewCustomerActive(checked as boolean)} />
@@ -131,9 +131,9 @@ export default function OrganizationsPage() { @@ -143,14 +143,14 @@ export default function OrganizationsPage() {
- {organizations.map((org) => ( + {customers.map((customer) => ( setCurrentOrganization(org)} + onClick={() => setCurrentCustomer(customer)} >
@@ -159,13 +159,13 @@ export default function OrganizationsPage() {
- {org.name} + {customer.name} - {org.isActive ? 'Active' : 'Inactive'} + {customer.isActive ? 'Active' : 'Inactive'}
- {currentOrganization?.id === org.id && ( + {currentCustomer?.id === customer.id && (
@@ -174,7 +174,7 @@ export default function OrganizationsPage() {

- Created on {new Date(org.createdAt).toLocaleDateString()} + Created on {new Date(customer.createdAt).toLocaleDateString()}

@@ -184,7 +184,7 @@ export default function OrganizationsPage() { className="text-muted-foreground" onClick={(e) => { e.stopPropagation(); - setSelectedOrg(org); + setSelectedCustomer(customer); setIsViewDialogOpen(true); }} > @@ -199,9 +199,9 @@ export default function OrganizationsPage() { className="h-8 w-8 text-muted-foreground hover:text-foreground" onClick={(e) => { e.stopPropagation(); - setSelectedOrg(org); - setEditOrgName(org.name); - setEditOrgActive(org.isActive); + setSelectedCustomer(customer); + setEditCustomerName(customer.name); + setEditCustomerActive(customer.isActive); setIsEditDialogOpen(true); }} > @@ -213,7 +213,7 @@ export default function OrganizationsPage() { className="h-8 w-8 text-muted-foreground hover:text-destructive" onClick={(e) => { e.stopPropagation(); - setSelectedOrg(org); + setSelectedCustomer(customer); setIsDeleteDialogOpen(true); }} > @@ -226,47 +226,47 @@ export default function OrganizationsPage() { ))}
- {organizations.length === 0 && ( + {customers.length === 0 && (
-

No Organizations

+

No Customers

- You don't have any organizations yet. Create one to get started. + You don't have any customers yet. Create one to get started.

{isAdmin && ( )}
)} - {/* View Organization Dialog */} + {/* View Customer Dialog */} - Organization Details + Customer Details - View details for this organization. + View details for this customer.
- {selectedOrg && ( + {selectedCustomer && ( <>

Name

-

{selectedOrg.name}

+

{selectedCustomer.name}

Status

- {selectedOrg.isActive ? ( + {selectedCustomer.isActive ? ( Active @@ -281,20 +281,20 @@ export default function OrganizationsPage() {

Created

-

{new Date(selectedOrg.createdAt).toLocaleDateString()}

+

{new Date(selectedCustomer.createdAt).toLocaleDateString()}

Domains

- {/* Check if domain data is available for this org */} - {selectedOrg.id in (domainsByOrganization || {}) && domainsByOrganization[selectedOrg.id]?.length > 0 ? ( + {/* Check if domain data is available for this customer */} + {selectedCustomer.id in (domainsByCustomer || {}) && domainsByCustomer[selectedCustomer.id]?.length > 0 ? (
    - {domainsByOrganization[selectedOrg.id]?.map(domain => ( + {domainsByCustomer[selectedCustomer.id]?.map(domain => (
  • {domain.name}
  • ))}
) : ( -

No domains associated with this organization.

+

No domains associated with this customer.

)}
@@ -306,33 +306,33 @@ export default function OrganizationsPage() { - {/* Edit Organization Dialog */} + {/* Edit Customer Dialog */} - Edit Organization + Edit Customer - Make changes to the organization details. + Make changes to the customer details.
{ e.preventDefault(); - if (!editOrgName.trim()) { + if (!editCustomerName.trim()) { toast({ title: 'Error', - description: 'Organization name cannot be empty', + description: 'Customer name cannot be empty', variant: 'destructive', }); return; } - if (selectedOrg) { - // Use the updateOrganizationMutation from context - updateOrganizationMutation.mutate({ - id: selectedOrg.id, + if (selectedCustomer) { + // Use the updateCustomerMutation from context + updateCustomerMutation.mutate({ + id: selectedCustomer.id, data: { - name: editOrgName, - isActive: editOrgActive, + name: editCustomerName, + isActive: editCustomerActive, } }); @@ -341,20 +341,20 @@ export default function OrganizationsPage() { }}>
- + setEditOrgName(e.target.value)} - placeholder="Enter organization name" + id="editCustomerName" + value={editCustomerName} + onChange={(e) => setEditCustomerName(e.target.value)} + placeholder="Enter customer name" required />
setEditOrgActive(checked as boolean)} + checked={editCustomerActive} + onCheckedChange={(checked) => setEditCustomerActive(checked as boolean)} />
@@ -362,38 +362,38 @@ export default function OrganizationsPage() {
- {/* Delete Organization Dialog */} + {/* Delete Customer Dialog */} Are you sure? - This action cannot be undone. This will permanently delete the organization - {selectedOrg && "{selectedOrg.name}"} and all associated data. + This action cannot be undone. This will permanently delete the customer + {selectedCustomer && "{selectedCustomer.name}"} and all associated data. Cancel { - if (selectedOrg) { - deleteOrganizationMutation.mutate(selectedOrg.id); + if (selectedCustomer) { + deleteCustomerMutation.mutate(selectedCustomer.id); setIsDeleteDialogOpen(false); } }} > - {deleteOrganizationMutation.isPending ? 'Deleting...' : 'Delete'} + {deleteCustomerMutation.isPending ? 'Deleting...' : 'Delete'}