useSubscriptions

Fetch and manage subscriptions for a vendor

useSubscriptions

Fetch and manage subscriptions

Returns

subscriptionsSubscription[]

Array of subscriptions

loadingboolean

Loading state

errorstring | null

Error message if any

refetch() => void

Refetch subscriptions

Example

1import { useSubscriptions } from 'pyhard-vendor-sdk';
2
3function SubscriptionsList({ vendorAddress }: { vendorAddress: string }) {
4  const { subscriptions, loading, error, refetch } = useSubscriptions(vendorAddress);
5  
6  if (loading) return <div>Loading...</div>;
7  if (error) return <div>Error: {error}</div>;
8  
9  return (
10    <div>
11      <button onClick={refetch}>Refresh</button>
12      {subscriptions.map(sub => (
13        <div key={sub.id}>
14          <p>Amount: {sub.amountPerInterval} PYUSD</p>
15          <p>Interval: {sub.interval}</p>
16          <p>Active: {sub.active ? 'Yes' : 'No'}</p>
17        </div>
18      ))}
19    </div>
20  );
21}