mirror of
https://github.com/freedbygrace/DynamoDNS.git
synced 2026-08-30 03:59:22 +00:00
Rename "Organization" to "Customer" in settings page
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/299a33db-6602-45cd-9f3c-239d19e0c66c.jpg
This commit is contained in:
@@ -55,15 +55,15 @@ import { Switch } from "@/components/ui/switch";
|
|||||||
import { Separator } from "@/components/ui/separator";
|
import { Separator } from "@/components/ui/separator";
|
||||||
import { Loader2, Moon, Sun, Lock, Laptop } from "lucide-react";
|
import { Loader2, Moon, Sun, Lock, Laptop } from "lucide-react";
|
||||||
|
|
||||||
// Organization form schema
|
// Customer form schema
|
||||||
const organizationFormSchema = z.object({
|
const customerFormSchema = z.object({
|
||||||
name: z.string().min(1, "Organization name is required"),
|
name: z.string().min(1, "Customer name is required"),
|
||||||
isActive: z.boolean().default(true),
|
isActive: z.boolean().default(true),
|
||||||
});
|
});
|
||||||
|
|
||||||
// Create organization form schema
|
// Create customer form schema
|
||||||
const createOrganizationFormSchema = z.object({
|
const createCustomerFormSchema = z.object({
|
||||||
name: z.string().min(1, "Organization name is required"),
|
name: z.string().min(1, "Customer name is required"),
|
||||||
isActive: z.boolean().default(true),
|
isActive: z.boolean().default(true),
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -92,27 +92,27 @@ export default function SettingsPage() {
|
|||||||
|
|
||||||
const [isDeleteDialogOpen, setIsDeleteDialogOpen] = useState(false);
|
const [isDeleteDialogOpen, setIsDeleteDialogOpen] = useState(false);
|
||||||
|
|
||||||
// Create organization form
|
// Create customer form
|
||||||
const createOrganizationForm = useForm<z.infer<typeof createOrganizationFormSchema>>({
|
const createCustomerForm = useForm<z.infer<typeof createCustomerFormSchema>>({
|
||||||
resolver: zodResolver(createOrganizationFormSchema),
|
resolver: zodResolver(createCustomerFormSchema),
|
||||||
defaultValues: {
|
defaultValues: {
|
||||||
name: "",
|
name: "",
|
||||||
isActive: true,
|
isActive: true,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
// Fetch organization data
|
// Fetch customer data
|
||||||
const { data: organization } = useQuery<Organization>({
|
const { data: customer } = useQuery<Customer>({
|
||||||
queryKey: ["/api/organizations", currentOrganization?.id],
|
queryKey: ["/api/customers", currentCustomer?.id],
|
||||||
enabled: !!currentOrganization?.id,
|
enabled: !!currentCustomer?.id,
|
||||||
});
|
});
|
||||||
|
|
||||||
// Organization form
|
// Customer form
|
||||||
const organizationForm = useForm<z.infer<typeof organizationFormSchema>>({
|
const customerForm = useForm<z.infer<typeof customerFormSchema>>({
|
||||||
resolver: zodResolver(organizationFormSchema),
|
resolver: zodResolver(customerFormSchema),
|
||||||
defaultValues: {
|
defaultValues: {
|
||||||
name: currentOrganization?.name || "",
|
name: currentCustomer?.name || "",
|
||||||
isActive: currentOrganization?.isActive,
|
isActive: currentCustomer?.isActive,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -136,44 +136,44 @@ export default function SettingsPage() {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
// Update organization details when they change
|
// Update customer details when they change
|
||||||
useState(() => {
|
useState(() => {
|
||||||
if (currentOrganization) {
|
if (currentCustomer) {
|
||||||
organizationForm.reset({
|
customerForm.reset({
|
||||||
name: currentOrganization.name,
|
name: currentCustomer.name,
|
||||||
isActive: currentOrganization.isActive,
|
isActive: currentCustomer.isActive,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// Update organization mutation
|
// Update customer mutation
|
||||||
const updateOrganizationMutation = useMutation({
|
const updateCustomerMutation = useMutation({
|
||||||
mutationFn: async (data: z.infer<typeof organizationFormSchema>) => {
|
mutationFn: async (data: z.infer<typeof customerFormSchema>) => {
|
||||||
if (!currentOrganization) throw new Error("No organization selected");
|
if (!currentCustomer) throw new Error("No customer selected");
|
||||||
|
|
||||||
const res = await apiRequest("PUT", `/api/organizations/${currentOrganization.id}`, data);
|
const res = await apiRequest("PUT", `/api/customers/${currentCustomer.id}`, data);
|
||||||
return await res.json();
|
return await res.json();
|
||||||
},
|
},
|
||||||
onSuccess: (data) => {
|
onSuccess: (data) => {
|
||||||
queryClient.invalidateQueries({ queryKey: ["/api/organizations"] });
|
queryClient.invalidateQueries({ queryKey: ["/api/customers"] });
|
||||||
queryClient.invalidateQueries({ queryKey: ["/api/organizations", currentOrganization?.id] });
|
queryClient.invalidateQueries({ queryKey: ["/api/customers", currentCustomer?.id] });
|
||||||
|
|
||||||
// Update the current organization in context
|
// Update the current customer in context
|
||||||
if (currentOrganization) {
|
if (currentCustomer) {
|
||||||
setCurrentOrganization({
|
setCurrentCustomer({
|
||||||
...currentOrganization,
|
...currentCustomer,
|
||||||
...data,
|
...data,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
toast({
|
toast({
|
||||||
title: "Organization updated",
|
title: "Customer updated",
|
||||||
description: "The organization details have been updated successfully.",
|
description: "The customer details have been updated successfully.",
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
onError: (error) => {
|
onError: (error) => {
|
||||||
toast({
|
toast({
|
||||||
title: "Failed to update organization",
|
title: "Failed to update customer",
|
||||||
description: error.message,
|
description: error.message,
|
||||||
variant: "destructive",
|
variant: "destructive",
|
||||||
});
|
});
|
||||||
@@ -233,25 +233,25 @@ export default function SettingsPage() {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
// Delete organization mutation
|
// Delete customer mutation
|
||||||
const deleteOrganizationMutation = useMutation({
|
const deleteCustomerMutation = useMutation({
|
||||||
mutationFn: async () => {
|
mutationFn: async () => {
|
||||||
if (!currentOrganization) throw new Error("No organization selected");
|
if (!currentCustomer) throw new Error("No customer selected");
|
||||||
|
|
||||||
await apiRequest("DELETE", `/api/organizations/${currentOrganization.id}`);
|
await apiRequest("DELETE", `/api/customers/${currentCustomer.id}`);
|
||||||
},
|
},
|
||||||
onSuccess: () => {
|
onSuccess: () => {
|
||||||
queryClient.invalidateQueries({ queryKey: ["/api/organizations"] });
|
queryClient.invalidateQueries({ queryKey: ["/api/customers"] });
|
||||||
setIsDeleteDialogOpen(false);
|
setIsDeleteDialogOpen(false);
|
||||||
|
|
||||||
toast({
|
toast({
|
||||||
title: "Organization deleted",
|
title: "Customer deleted",
|
||||||
description: "The organization has been deleted successfully.",
|
description: "The customer has been deleted successfully.",
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
onError: (error) => {
|
onError: (error) => {
|
||||||
toast({
|
toast({
|
||||||
title: "Failed to delete organization",
|
title: "Failed to delete customer",
|
||||||
description: error.message,
|
description: error.message,
|
||||||
variant: "destructive",
|
variant: "destructive",
|
||||||
});
|
});
|
||||||
@@ -259,8 +259,8 @@ export default function SettingsPage() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// Form submission handlers
|
// Form submission handlers
|
||||||
const onOrganizationSubmit = (data: z.infer<typeof organizationFormSchema>) => {
|
const onCustomerSubmit = (data: z.infer<typeof customerFormSchema>) => {
|
||||||
updateOrganizationMutation.mutate(data);
|
updateCustomerMutation.mutate(data);
|
||||||
};
|
};
|
||||||
|
|
||||||
const onAccountSubmit = (data: z.infer<typeof accountFormSchema>) => {
|
const onAccountSubmit = (data: z.infer<typeof accountFormSchema>) => {
|
||||||
@@ -282,7 +282,7 @@ export default function SettingsPage() {
|
|||||||
<Tabs defaultValue="account" className="space-y-6">
|
<Tabs defaultValue="account" className="space-y-6">
|
||||||
<TabsList className="w-full sm:w-auto">
|
<TabsList className="w-full sm:w-auto">
|
||||||
<TabsTrigger value="account">Account</TabsTrigger>
|
<TabsTrigger value="account">Account</TabsTrigger>
|
||||||
<TabsTrigger value="organization">Organization</TabsTrigger>
|
<TabsTrigger value="customer">Customer</TabsTrigger>
|
||||||
<TabsTrigger value="appearance">Appearance</TabsTrigger>
|
<TabsTrigger value="appearance">Appearance</TabsTrigger>
|
||||||
</TabsList>
|
</TabsList>
|
||||||
|
|
||||||
@@ -435,15 +435,15 @@ export default function SettingsPage() {
|
|||||||
</Card>
|
</Card>
|
||||||
</TabsContent>
|
</TabsContent>
|
||||||
|
|
||||||
{/* Organization Settings */}
|
{/* Customer Settings */}
|
||||||
<TabsContent value="organization" className="space-y-6">
|
<TabsContent value="customer" className="space-y-6">
|
||||||
{!hasManagePermission ? (
|
{!hasManagePermission ? (
|
||||||
<Card>
|
<Card>
|
||||||
<CardContent className="pt-6 flex flex-col items-center justify-center h-64">
|
<CardContent className="pt-6 flex flex-col items-center justify-center h-64">
|
||||||
<Lock className="h-12 w-12 text-muted-foreground mb-4" />
|
<Lock className="h-12 w-12 text-muted-foreground mb-4" />
|
||||||
<h3 className="text-lg font-medium mb-2">Access Restricted</h3>
|
<h3 className="text-lg font-medium mb-2">Access Restricted</h3>
|
||||||
<p className="text-center text-muted-foreground">
|
<p className="text-center text-muted-foreground">
|
||||||
You don't have permission to modify organization settings. Only administrators and managers can manage organizations.
|
You don't have permission to modify customer settings. Only administrators and managers can manage customers.
|
||||||
</p>
|
</p>
|
||||||
</CardContent>
|
</CardContent>
|
||||||
</Card>
|
</Card>
|
||||||
|
|||||||
Reference in New Issue
Block a user