()
| 66 | const WEBHOOK_BASE_URL = env.VITE_API_URL || 'https://api.shipsec.ai'; |
| 67 | |
| 68 | export function WebhooksPage() { |
| 69 | const { toast } = useToast(); |
| 70 | const navigate = useNavigate(); |
| 71 | const [searchParams, setSearchParams] = useSearchParams(); |
| 72 | const [workflowOptions, setWorkflowOptions] = useState<WorkflowOption[]>([]); |
| 73 | const [workflowsLoading, setWorkflowsLoading] = useState(true); |
| 74 | const [actionState, setActionState] = useState<Record<string, 'delete' | 'regenerate' | 'test'>>( |
| 75 | {}, |
| 76 | ); |
| 77 | |
| 78 | const webhooks = useWebhookStore((state) => state.webhooks); |
| 79 | const isLoading = useWebhookStore((state) => state.isLoading); |
| 80 | const error = useWebhookStore((state) => state.error); |
| 81 | const filters = useWebhookStore((state) => state.filters); |
| 82 | const fetchWebhooks = useWebhookStore((state) => state.fetchWebhooks); |
| 83 | const refreshWebhooks = useWebhookStore((state) => state.refreshWebhooks); |
| 84 | const setFilters = useWebhookStore((state) => state.setFilters); |
| 85 | const deleteWebhook = useWebhookStore((state) => state.deleteWebhook); |
| 86 | const regeneratePath = useWebhookStore((state) => state.regeneratePath); |
| 87 | |
| 88 | useEffect(() => { |
| 89 | const initialWorkflowId = searchParams.get('workflowId'); |
| 90 | if (initialWorkflowId) { |
| 91 | setFilters({ workflowId: initialWorkflowId }); |
| 92 | } |
| 93 | }, []); |
| 94 | |
| 95 | useEffect(() => { |
| 96 | fetchWebhooks({ force: true }).catch(() => {}); |
| 97 | }, [fetchWebhooks]); |
| 98 | |
| 99 | useEffect(() => { |
| 100 | let cancelled = false; |
| 101 | (async () => { |
| 102 | try { |
| 103 | const workflowList = await api.workflows.list(); |
| 104 | if (cancelled) return; |
| 105 | const normalized = workflowList.map((workflow) => ({ |
| 106 | id: workflow.id, |
| 107 | name: workflow.name ?? 'Untitled workflow', |
| 108 | })); |
| 109 | setWorkflowOptions(normalized); |
| 110 | } catch (_err) { |
| 111 | console.error('Failed to load workflows', _err); |
| 112 | toast({ |
| 113 | title: 'Unable to load workflows', |
| 114 | description: _err instanceof Error ? _err.message : 'Please try refreshing the page.', |
| 115 | variant: 'destructive', |
| 116 | }); |
| 117 | } finally { |
| 118 | if (!cancelled) { |
| 119 | setWorkflowsLoading(false); |
| 120 | } |
| 121 | } |
| 122 | })(); |
| 123 | return () => { |
| 124 | cancelled = true; |
| 125 | }; |
nothing calls this directly
no test coverage detected