/** * WordPress dependencies */ import { select } from '@safe-wordpress/data'; /** * External dependencies */ import { store as NC_DATA } from '@nelio-content/data'; import type { Maybe, Uuid, WebhookSettings } from '@nelio-content/types'; export type WebhookSettingsAction = SetWebhookSettingsInProfileAction; export function setWebhookSettingsInProfile( profileId: Maybe< Uuid >, webhookSettings: WebhookSettings ): Maybe< SetWebhookSettingsInProfileAction > { if ( ! profileId ) { return; } const profile = select( NC_DATA ).getSocialProfile( profileId ); if ( ! profile ) { return; } return { type: 'SET_WEBHOOK_SETTINGS_IN_PROFILE', profileId, webhookSettings, }; } // ============ // HELPER TYPES // ============ export type SetWebhookSettingsInProfileAction = { readonly type: 'SET_WEBHOOK_SETTINGS_IN_PROFILE'; readonly profileId: Uuid; readonly webhookSettings: WebhookSettings; };