saleor-dashboard/src/webhooks/index.tsx

52 lines
1.3 KiB
TypeScript
Raw Normal View History

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 {
webhooksListPath,
WebhooksListUrlQueryParams,
webhooksPath
} from "./urls";
import WebhooksDetails from "./views/WebhooksDetails";
import WebhooksList from "./views/WebhooksList";
2019-10-09 06:01:52 +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;
return <WebhooksList params={params} />;
2019-10-09 06:01:52 +00:00
};
const PageDetails: React.StatelessComponent<RouteComponentProps<any>> = ({
match
}) => {
const qs = parseQs(location.search.substr(1));
const params: WebhooksListUrlQueryParams = qs;
return (
<WebhooksDetails
2019-10-09 06:01:52 +00:00
id={decodeURIComponent(match.params.id)}
params={params}
/>
);
};
const Component = () => {
const intl = useIntl();
return (
<>
<WindowTitle title={intl.formatMessage(sectionNames.plugins)} />
<Switch>
<Route exact path={webhooksListPath} component={WebhookList} />
<Route path={webhooksPath(":id")} component={WebhooksDetails} />
2019-10-09 06:01:52 +00:00
</Switch>
</>
);
};
export default Component;