mirror of
https://github.com/freedbygrace/DynamoDNS.git
synced 2026-08-31 20:58:05 +00:00
Rename "Organizations" to "Customers" across the application
Replit-Commit-Author: Agent Replit-Commit-Session-Id: 9111ef36-26c8-4085-84ca-a35dc1fec1b5 Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/7083d608-d6d3-4a6a-9a27-6286c5109627/c8840127-37a9-49ac-8f8c-b37ce5fdd14a.jpg
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
import { Link, useLocation } from "wouter";
|
import { Link, useLocation } from "wouter";
|
||||||
import { cn } from "@/lib/utils";
|
import { cn } from "@/lib/utils";
|
||||||
import { OrganizationSelector } from "@/components/shared/organization-selector";
|
import { CustomerSelector } from "@/components/shared/customer-selector";
|
||||||
import { useAuth } from "@/hooks/use-auth";
|
import { useAuth } from "@/hooks/use-auth";
|
||||||
import {
|
import {
|
||||||
LayoutDashboard,
|
LayoutDashboard,
|
||||||
@@ -139,9 +139,9 @@ export function MobileSidebar({ isOpen, onClose }: MobileSidebarProps) {
|
|||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* Organization Selector */}
|
{/* Customer Selector */}
|
||||||
<div className="px-4 py-2">
|
<div className="px-4 py-2">
|
||||||
<OrganizationSelector />
|
<CustomerSelector />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<nav className="flex-1 py-4 px-2 space-y-1 overflow-y-auto">
|
<nav className="flex-1 py-4 px-2 space-y-1 overflow-y-auto">
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { Link, useLocation } from "wouter";
|
import { Link, useLocation } from "wouter";
|
||||||
import { cn } from "@/lib/utils";
|
import { cn } from "@/lib/utils";
|
||||||
import { ThemeToggle } from "@/components/shared/theme-toggle";
|
import { ThemeToggle } from "@/components/shared/theme-toggle";
|
||||||
import { OrganizationSelector } from "@/components/shared/organization-selector";
|
import { CustomerSelector } from "@/components/shared/customer-selector";
|
||||||
import { useAuth } from "@/hooks/use-auth";
|
import { useAuth } from "@/hooks/use-auth";
|
||||||
import {
|
import {
|
||||||
LayoutDashboard,
|
LayoutDashboard,
|
||||||
@@ -33,8 +33,8 @@ export function Sidebar() {
|
|||||||
icon: <LayoutDashboard className="w-5 h-5 mr-3" />,
|
icon: <LayoutDashboard className="w-5 h-5 mr-3" />,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: "Organizations",
|
title: "Customers",
|
||||||
href: "/organizations",
|
href: "/customers",
|
||||||
icon: <Users className="w-5 h-5 mr-3" />,
|
icon: <Users className="w-5 h-5 mr-3" />,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -124,9 +124,9 @@ export function Sidebar() {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* Organization Selector */}
|
{/* Customer Selector */}
|
||||||
<div className="px-4 py-2">
|
<div className="px-4 py-2">
|
||||||
<OrganizationSelector />
|
<CustomerSelector />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<nav className="flex-1 py-4 px-2 space-y-1 overflow-y-auto">
|
<nav className="flex-1 py-4 px-2 space-y-1 overflow-y-auto">
|
||||||
|
|||||||
+37
-29
@@ -615,79 +615,87 @@ export async function registerRoutes(app: Express): Promise<Server> {
|
|||||||
|
|
||||||
const httpServer = createServer(app);
|
const httpServer = createServer(app);
|
||||||
|
|
||||||
// Organizations
|
// Customers (previously organizations)
|
||||||
app.get("/api/organizations", requireRole(["admin", "manager", "user", "readonly"]), async (req, res) => {
|
app.get("/api/customers", requireRole(["admin", "manager", "user", "readonly"]), async (req, res) => {
|
||||||
try {
|
try {
|
||||||
const organizations = await storage.getOrganizations();
|
const customers = await storage.getCustomers();
|
||||||
res.json(organizations);
|
res.json(customers);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("Error fetching organizations:", error);
|
console.error("Error fetching customers:", error);
|
||||||
res.status(500).json({ message: "Internal server error" });
|
res.status(500).json({ message: "Internal server error" });
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
app.get("/api/organizations/:id", requireRole(["admin", "manager", "user", "readonly"]), async (req, res) => {
|
app.get("/api/customers/:id", requireRole(["admin", "manager", "user", "readonly"]), async (req, res) => {
|
||||||
try {
|
try {
|
||||||
const id = parseInt(req.params.id);
|
const customer = await storage.getCustomer(req.params.id);
|
||||||
const organization = await storage.getOrganization(id);
|
|
||||||
|
|
||||||
if (!organization) {
|
if (!customer) {
|
||||||
return res.status(404).json({ message: "Organization not found" });
|
return res.status(404).json({ message: "Customer not found" });
|
||||||
}
|
}
|
||||||
|
|
||||||
res.json(organization);
|
res.json(customer);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("Error fetching organization:", error);
|
console.error("Error fetching customer:", error);
|
||||||
res.status(500).json({ message: "Internal server error" });
|
res.status(500).json({ message: "Internal server error" });
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
app.post("/api/organizations", requireRole(["admin"]), async (req, res) => {
|
app.post("/api/customers", requireRole(["admin"]), async (req, res) => {
|
||||||
try {
|
try {
|
||||||
const validatedData = insertOrganizationSchema.parse(req.body);
|
const validatedData = insertCustomerSchema.parse(req.body);
|
||||||
const organization = await storage.createOrganization(validatedData);
|
const customer = await storage.createCustomer(validatedData);
|
||||||
res.status(201).json(organization);
|
res.status(201).json(customer);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (error instanceof z.ZodError) {
|
if (error instanceof z.ZodError) {
|
||||||
res.status(400).json({ message: "Validation error", errors: error.errors });
|
res.status(400).json({ message: "Validation error", errors: error.errors });
|
||||||
} else {
|
} else {
|
||||||
console.error("Error creating organization:", error);
|
console.error("Error creating customer:", error);
|
||||||
res.status(500).json({ message: "Internal server error" });
|
res.status(500).json({ message: "Internal server error" });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
app.put("/api/organizations/:id", requireRole(["admin"]), async (req, res) => {
|
app.put("/api/customers/:id", requireRole(["admin"]), async (req, res) => {
|
||||||
try {
|
try {
|
||||||
const id = parseInt(req.params.id);
|
const validatedData = insertCustomerSchema.partial().parse(req.body);
|
||||||
const validatedData = insertOrganizationSchema.partial().parse(req.body);
|
|
||||||
|
|
||||||
const updatedOrganization = await storage.updateOrganization(id, validatedData);
|
const updatedCustomer = await storage.updateCustomer(req.params.id, validatedData);
|
||||||
|
|
||||||
if (!updatedOrganization) {
|
if (!updatedCustomer) {
|
||||||
return res.status(404).json({ message: "Organization not found" });
|
return res.status(404).json({ message: "Customer not found" });
|
||||||
}
|
}
|
||||||
|
|
||||||
res.json(updatedOrganization);
|
res.json(updatedCustomer);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (error instanceof z.ZodError) {
|
if (error instanceof z.ZodError) {
|
||||||
res.status(400).json({ message: "Validation error", errors: error.errors });
|
res.status(400).json({ message: "Validation error", errors: error.errors });
|
||||||
} else {
|
} else {
|
||||||
console.error("Error updating organization:", error);
|
console.error("Error updating customer:", error);
|
||||||
res.status(500).json({ message: "Internal server error" });
|
res.status(500).json({ message: "Internal server error" });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
app.delete("/api/organizations/:id", requireRole(["admin"]), async (req, res) => {
|
app.delete("/api/customers/:id", requireRole(["admin"]), async (req, res) => {
|
||||||
try {
|
try {
|
||||||
const id = parseInt(req.params.id);
|
const deleted = await storage.deleteCustomer(req.params.id);
|
||||||
const deleted = await storage.deleteOrganization(id);
|
|
||||||
|
|
||||||
if (!deleted) {
|
if (!deleted) {
|
||||||
return res.status(404).json({ message: "Organization not found" });
|
return res.status(404).json({ message: "Customer not found" });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// For backward compatibility - maintain the old API endpoints
|
||||||
|
app.get("/api/organizations", requireRole(["admin", "manager", "user", "readonly"]), async (req, res) => {
|
||||||
|
try {
|
||||||
|
const customers = await storage.getCustomers();
|
||||||
|
res.json(customers);
|
||||||
|
} catch (error) {
|
||||||
|
console.error("Error fetching organizations (customers):", error);
|
||||||
|
res.status(500).json({ message: "Internal server error" });
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
res.status(204).end();
|
res.status(204).end();
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("Error deleting organization:", error);
|
console.error("Error deleting organization:", error);
|
||||||
|
|||||||
Reference in New Issue
Block a user