fixed cache Refactoring from app router to page router Refactoring from app router to page router Add authentication with JWT base ui done protect the dashboard added transitions styling type trick added cleanup Add enable-disable logic add transactional emails Improvements on delay and frontend added description on select implement auth with magic link migrate to mariadb webhook signature working Adding async processing with queues Implemented webhook reply functionality Add son execution logs update status logic Add recent activity monitoring to sons show son performance in dashboard add readme implement listmonk connector listmonk-connector-v1 Create CODE_OF_CONDUCT.md Create LICENSE
29 lines
No EOL
909 B
TypeScript
29 lines
No EOL
909 B
TypeScript
import { useState, useEffect, useCallback } from 'react';
|
|
import { apiClient } from '@/lib/api-client';
|
|
import { Webhook } from '@/lib/types';
|
|
|
|
|
|
export function useWebhook() {
|
|
const [webhook, setWebhook] = useState<Webhook | null>(null);
|
|
const [loading, setLoading] = useState(true);
|
|
const [error, setError] = useState<Error | null>(null);
|
|
|
|
const fetchWebhook = useCallback(async () => {
|
|
setLoading(true);
|
|
try {
|
|
const response = await apiClient.get<{ data: Webhook }>('/webhook-info');
|
|
setWebhook(response.data.data);
|
|
setError(null);
|
|
} catch (err) {
|
|
setError(err instanceof Error ? err : new Error('An error occurred'));
|
|
} finally {
|
|
setLoading(false);
|
|
}
|
|
}, []);
|
|
|
|
useEffect(() => {
|
|
fetchWebhook();
|
|
}, [fetchWebhook]);
|
|
|
|
return { webhook, loading, error, fetchWebhook };
|
|
} |