import AppHeader from "@saleor/components/AppHeader"; import { ConfirmButtonTransitionState } from "@saleor/components/ConfirmButton"; import Container from "@saleor/components/Container"; import Form from "@saleor/components/Form"; import FormSpacer from "@saleor/components/FormSpacer"; import Grid from "@saleor/components/Grid"; import PageHeader from "@saleor/components/PageHeader"; import SaveButtonBar from "@saleor/components/SaveButtonBar"; import { sectionNames } from "@saleor/intl"; import { maybe } from "@saleor/misc"; import { UserError } from "@saleor/types"; import { WebhookEventTypeEnum } from "@saleor/types/globalTypes"; import React from "react"; import { useIntl } from "react-intl"; import { ServiceList_serviceAccounts_edges_node } from "../../types/ServiceList"; import { Webhook_webhook } from "../../types/Webhook"; import WebhookEvents from "../WebhookEvents"; import WebhookInfo from "../WebhookInfo"; import WebhookStatus from "../WebhookStatus"; export interface FormData { id: string; events: string[]; isActive: boolean; name: string; secretKey: string | null; targetUrl: string; serviceAccount: string; } export interface WebhooksDetailsPageProps { disabled: boolean; errors: UserError[]; webhook: Webhook_webhook; services: ServiceList_serviceAccounts_edges_node[]; saveButtonBarState: ConfirmButtonTransitionState; onBack: () => void; onDelete: () => void; onSubmit: (data: FormData) => void; } const WebhooksDetailsPage: React.StatelessComponent< WebhooksDetailsPageProps > = ({ disabled, errors, webhook, saveButtonBarState, services, onBack, onDelete, onSubmit }) => { const intl = useIntl(); const initialForm: FormData = { events: maybe(() => webhook.events, []).map(event => event.eventType), id: maybe(() => webhook.id, null), isActive: maybe(() => webhook.isActive, false), name: maybe(() => webhook.name, ""), secretKey: maybe(() => webhook.secretKey, ""), serviceAccount: maybe(() => webhook.serviceAccount.id, ""), targetUrl: maybe(() => webhook.targetUrl, "") }; return (
{({ data, errors, hasChanged, submit, change }) => { return ( {intl.formatMessage(sectionNames.plugins)} webhook.name, "...") } )} />
services, [])} errors={errors} onChange={change} />
); }}
); }; WebhooksDetailsPage.displayName = "WebhooksDetailsPage"; export default WebhooksDetailsPage;