2019-10-09 06:01:52 +00:00
|
|
|
import { parse as parseQs } from "qs";
|
|
|
|
import React from "react";
|
|
|
|
import { useIntl } from "react-intl";
|
|
|
|
import { Route, RouteComponentProps, Switch } from "react-router-dom";
|
|
|
|
|
|
|
|
import { sectionNames } from "@saleor/intl";
|
|
|
|
import { WindowTitle } from "../components/WindowTitle";
|
|
|
|
import {
|
2019-10-09 20:50:03 +00:00
|
|
|
webhooksAddUrl,
|
2019-10-09 06:01:52 +00:00
|
|
|
webhooksListPath,
|
|
|
|
WebhooksListUrlQueryParams,
|
|
|
|
webhooksPath
|
|
|
|
} from "./urls";
|
2019-10-09 20:50:03 +00:00
|
|
|
import WebhookCreate from "./views/WebhooksCreate";
|
2019-10-09 07:31:00 +00:00
|
|
|
import WebhooksDetails from "./views/WebhooksDetails";
|
|
|
|
import WebhooksList from "./views/WebhooksList";
|
2019-10-09 06:01:52 +00:00
|
|
|
|
2019-10-09 07:31:00 +00:00
|
|
|
const WebhookList: React.StatelessComponent<RouteComponentProps<any>> = ({
|
2019-10-09 06:01:52 +00:00
|
|
|
location
|
|
|
|
}) => {
|
|
|
|
const qs = parseQs(location.search.substr(1));
|
|
|
|
const params: WebhooksListUrlQueryParams = qs;
|
2019-10-09 07:31:00 +00:00
|
|
|
return <WebhooksList params={params} />;
|
2019-10-09 06:01:52 +00:00
|
|
|
};
|
|
|
|
|
2019-10-09 20:50:03 +00:00
|
|
|
const WebhookDetails: React.StatelessComponent<RouteComponentProps<any>> = ({
|
2019-10-09 06:01:52 +00:00
|
|
|
match
|
|
|
|
}) => {
|
|
|
|
const qs = parseQs(location.search.substr(1));
|
|
|
|
const params: WebhooksListUrlQueryParams = qs;
|
|
|
|
|
|
|
|
return (
|
2019-10-09 20:50:03 +00:00
|
|
|
<WebhooksDetails id={decodeURIComponent(match.params.id)} params={params} />
|
2019-10-09 06:01:52 +00:00
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
const Component = () => {
|
|
|
|
const intl = useIntl();
|
|
|
|
return (
|
|
|
|
<>
|
2019-10-15 10:06:19 +00:00
|
|
|
<WindowTitle title={intl.formatMessage(sectionNames.webhooks)} />
|
2019-10-09 06:01:52 +00:00
|
|
|
<Switch>
|
2019-10-09 07:31:00 +00:00
|
|
|
<Route exact path={webhooksListPath} component={WebhookList} />
|
2019-10-09 20:50:03 +00:00
|
|
|
<Route exact path={webhooksAddUrl} component={WebhookCreate} />
|
|
|
|
<Route path={webhooksPath(":id")} component={WebhookDetails} />
|
2019-10-09 06:01:52 +00:00
|
|
|
</Switch>
|
|
|
|
</>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
export default Component;
|