import React from 'react'; import superagent from 'superagent'; import BigOrdersWrapper from './BigOrdersWrapper.jsx'; import { Segment, Table, Header, Label } from 'semantic-ui-react' export default class ShopifyWebhooks extends React.Component { constructor(props) { super(props); this.state = { loading: false, webhooks: [] }; } async componentDidMount() { this.setState({ loading: true }); try { const res = await superagent.get('/api/admin/shop/webhooks').accept('json'); this.setState({ webhooks: res.body, loading: false }); console.log(res.text); } catch (error) { console.error('Failed to fetch webhooks:', error); this.setState({ webhooks: [], loading: false }); } } formatDate(dateString) { const date = new Date(dateString); return date.toLocaleString(); } render() { const { webhooks, loading } = this.state; const webhookList = webhooks || []; return ( {webhookList.length === 0 && !loading ? (

No webhooks found.

) : ( <>
Shopify Webhooks ({webhookList.length})
Topic Shopify ID Received At GraphQL ID {webhookList.map((webhook, index) => ( {webhook.shopifyId} {this.formatDate(webhook.receivedAt)} {webhook.graphQLId} ))}
)}
); } }