mirror of
https://github.com/freedbygrace/DynamoDNS.git
synced 2026-07-26 11:38:13 +00:00
Fix: Address error in other pages after customer creation. Updated customer data handling and webhook association.
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/cd2abb23-ad61-4639-982a-580ae4b4c15f.jpg
This commit is contained in:
@@ -3,7 +3,7 @@ import { useQuery, useMutation } from "@tanstack/react-query";
|
||||
import { useToast } from "@/hooks/use-toast";
|
||||
import { queryClient, apiRequest } from "@/lib/queryClient";
|
||||
import { useAuth } from "@/hooks/use-auth";
|
||||
import { useOrganization } from "@/context/organization-context";
|
||||
import { useCustomer } from "@/context/customer-context";
|
||||
import { Webhook, WebhookDeliveryLog } from "@shared/schema";
|
||||
|
||||
import {
|
||||
@@ -84,7 +84,7 @@ import {
|
||||
export default function WebhooksPage() {
|
||||
const { toast } = useToast();
|
||||
const { user } = useAuth();
|
||||
const { currentOrganization } = useOrganization();
|
||||
const { currentCustomer } = useCustomer();
|
||||
const [isCreateOpen, setIsCreateOpen] = useState(false);
|
||||
const [isEditOpen, setIsEditOpen] = useState(false);
|
||||
const [isDeleteOpen, setIsDeleteOpen] = useState(false);
|
||||
@@ -116,22 +116,22 @@ export default function WebhooksPage() {
|
||||
});
|
||||
};
|
||||
|
||||
// Fetch webhooks for the selected organization
|
||||
// Fetch webhooks for the selected customer
|
||||
const {
|
||||
data: webhooks = [],
|
||||
isLoading,
|
||||
error,
|
||||
} = useQuery({
|
||||
queryKey: ["/api/webhooks", currentOrganization?.id],
|
||||
queryKey: ["/api/webhooks", currentCustomer?.id],
|
||||
queryFn: async () => {
|
||||
if (!currentOrganization) return [];
|
||||
if (!currentCustomer) return [];
|
||||
const res = await apiRequest(
|
||||
"GET",
|
||||
`/api/webhooks?organizationId=${currentOrganization.id}`
|
||||
`/api/webhooks?customerId=${currentCustomer.id}`
|
||||
);
|
||||
return await res.json();
|
||||
},
|
||||
enabled: !!currentOrganization,
|
||||
enabled: !!currentCustomer,
|
||||
});
|
||||
|
||||
// Create webhook mutation
|
||||
@@ -139,7 +139,7 @@ export default function WebhooksPage() {
|
||||
mutationFn: async (data: any) => {
|
||||
const res = await apiRequest("POST", "/api/webhooks", {
|
||||
...data,
|
||||
organizationId: currentOrganization?.id,
|
||||
customerId: currentCustomer?.id,
|
||||
});
|
||||
return await res.json();
|
||||
},
|
||||
@@ -149,7 +149,7 @@ export default function WebhooksPage() {
|
||||
description: "The webhook has been created successfully.",
|
||||
});
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: ["/api/webhooks", currentOrganization?.id],
|
||||
queryKey: ["/api/webhooks", currentCustomer?.id],
|
||||
});
|
||||
setIsCreateOpen(false);
|
||||
resetForm();
|
||||
|
||||
Reference in New Issue
Block a user