mirror of
https://github.com/freedbygrace/DynamoDNS.git
synced 2026-08-05 15:57:43 +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 { 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 {
|
||||
LayoutDashboard,
|
||||
@@ -139,9 +139,9 @@ export function MobileSidebar({ isOpen, onClose }: MobileSidebarProps) {
|
||||
</button>
|
||||
</div>
|
||||
|
||||
{/* Organization Selector */}
|
||||
{/* Customer Selector */}
|
||||
<div className="px-4 py-2">
|
||||
<OrganizationSelector />
|
||||
<CustomerSelector />
|
||||
</div>
|
||||
|
||||
<nav className="flex-1 py-4 px-2 space-y-1 overflow-y-auto">
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { Link, useLocation } from "wouter";
|
||||
import { cn } from "@/lib/utils";
|
||||
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 {
|
||||
LayoutDashboard,
|
||||
@@ -33,8 +33,8 @@ export function Sidebar() {
|
||||
icon: <LayoutDashboard className="w-5 h-5 mr-3" />,
|
||||
},
|
||||
{
|
||||
title: "Organizations",
|
||||
href: "/organizations",
|
||||
title: "Customers",
|
||||
href: "/customers",
|
||||
icon: <Users className="w-5 h-5 mr-3" />,
|
||||
},
|
||||
{
|
||||
@@ -124,9 +124,9 @@ export function Sidebar() {
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Organization Selector */}
|
||||
{/* Customer Selector */}
|
||||
<div className="px-4 py-2">
|
||||
<OrganizationSelector />
|
||||
<CustomerSelector />
|
||||
</div>
|
||||
|
||||
<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);
|
||||
|
||||
// Organizations
|
||||
app.get("/api/organizations", requireRole(["admin", "manager", "user", "readonly"]), async (req, res) => {
|
||||
// Customers (previously organizations)
|
||||
app.get("/api/customers", requireRole(["admin", "manager", "user", "readonly"]), async (req, res) => {
|
||||
try {
|
||||
const organizations = await storage.getOrganizations();
|
||||
res.json(organizations);
|
||||
const customers = await storage.getCustomers();
|
||||
res.json(customers);
|
||||
} catch (error) {
|
||||
console.error("Error fetching organizations:", error);
|
||||
console.error("Error fetching customers:", 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 {
|
||||
const id = parseInt(req.params.id);
|
||||
const organization = await storage.getOrganization(id);
|
||||
const customer = await storage.getCustomer(req.params.id);
|
||||
|
||||
if (!organization) {
|
||||
return res.status(404).json({ message: "Organization not found" });
|
||||
if (!customer) {
|
||||
return res.status(404).json({ message: "Customer not found" });
|
||||
}
|
||||
|
||||
res.json(organization);
|
||||
res.json(customer);
|
||||
} catch (error) {
|
||||
console.error("Error fetching organization:", error);
|
||||
console.error("Error fetching customer:", 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 {
|
||||
const validatedData = insertOrganizationSchema.parse(req.body);
|
||||
const organization = await storage.createOrganization(validatedData);
|
||||
res.status(201).json(organization);
|
||||
const validatedData = insertCustomerSchema.parse(req.body);
|
||||
const customer = await storage.createCustomer(validatedData);
|
||||
res.status(201).json(customer);
|
||||
} catch (error) {
|
||||
if (error instanceof z.ZodError) {
|
||||
res.status(400).json({ message: "Validation error", errors: error.errors });
|
||||
} else {
|
||||
console.error("Error creating organization:", error);
|
||||
console.error("Error creating customer:", 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 {
|
||||
const id = parseInt(req.params.id);
|
||||
const validatedData = insertOrganizationSchema.partial().parse(req.body);
|
||||
const validatedData = insertCustomerSchema.partial().parse(req.body);
|
||||
|
||||
const updatedOrganization = await storage.updateOrganization(id, validatedData);
|
||||
const updatedCustomer = await storage.updateCustomer(req.params.id, validatedData);
|
||||
|
||||
if (!updatedOrganization) {
|
||||
return res.status(404).json({ message: "Organization not found" });
|
||||
if (!updatedCustomer) {
|
||||
return res.status(404).json({ message: "Customer not found" });
|
||||
}
|
||||
|
||||
res.json(updatedOrganization);
|
||||
res.json(updatedCustomer);
|
||||
} catch (error) {
|
||||
if (error instanceof z.ZodError) {
|
||||
res.status(400).json({ message: "Validation error", errors: error.errors });
|
||||
} else {
|
||||
console.error("Error updating organization:", error);
|
||||
console.error("Error updating customer:", 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 {
|
||||
const id = parseInt(req.params.id);
|
||||
const deleted = await storage.deleteOrganization(id);
|
||||
const deleted = await storage.deleteCustomer(req.params.id);
|
||||
|
||||
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();
|
||||
} catch (error) {
|
||||
console.error("Error deleting organization:", error);
|
||||
|
||||
Reference in New Issue
Block a user