2019-09-25 14:11:45 +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 {
|
|
|
|
serviceListPath,
|
2019-09-27 10:17:23 +00:00
|
|
|
ServiceListUrlQueryParams,
|
|
|
|
servicePath,
|
|
|
|
ServiceUrlQueryParams
|
2019-09-25 14:11:45 +00:00
|
|
|
} from "./urls";
|
2019-09-27 10:17:23 +00:00
|
|
|
import ServiceDetailsComponent from "./views/ServiceDetails";
|
2019-09-25 14:11:45 +00:00
|
|
|
import ServiceListComponent from "./views/ServiceList";
|
|
|
|
|
2019-09-27 10:17:23 +00:00
|
|
|
const ServiceList: React.FC<RouteComponentProps> = ({ location }) => {
|
2019-09-25 14:11:45 +00:00
|
|
|
const qs = parseQs(location.search.substr(1));
|
|
|
|
const params: ServiceListUrlQueryParams = qs;
|
2019-09-27 10:17:23 +00:00
|
|
|
|
2019-09-25 14:11:45 +00:00
|
|
|
return <ServiceListComponent params={params} />;
|
|
|
|
};
|
|
|
|
|
2019-09-27 10:17:23 +00:00
|
|
|
const ServiceDetails: React.FC<RouteComponentProps<{ id: string }>> = ({
|
|
|
|
match
|
|
|
|
}) => {
|
|
|
|
const qs = parseQs(location.search.substr(1));
|
|
|
|
const params: ServiceUrlQueryParams = qs;
|
|
|
|
|
|
|
|
return (
|
|
|
|
<ServiceDetailsComponent
|
|
|
|
id={decodeURIComponent(match.params.id)}
|
|
|
|
params={params}
|
|
|
|
/>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
const ServiceSection = () => {
|
2019-09-25 14:11:45 +00:00
|
|
|
const intl = useIntl();
|
2019-09-27 10:17:23 +00:00
|
|
|
|
2019-09-25 14:11:45 +00:00
|
|
|
return (
|
|
|
|
<>
|
|
|
|
<WindowTitle title={intl.formatMessage(sectionNames.serviceAccounts)} />
|
|
|
|
<Switch>
|
2019-09-27 10:17:23 +00:00
|
|
|
<Route exact path={serviceListPath} component={ServiceList} />
|
|
|
|
<Route path={servicePath(":id")} component={ServiceDetails} />
|
2019-09-25 14:11:45 +00:00
|
|
|
</Switch>
|
|
|
|
</>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
2019-09-27 10:17:23 +00:00
|
|
|
export default ServiceSection;
|