2022-12-15 13:51:05 +00:00
|
|
|
import WebhooksRoutes from "@saleor/custom-apps";
|
2020-07-22 10:54:15 +00:00
|
|
|
import { sectionNames } from "@saleor/intl";
|
|
|
|
import { parse as parseQs } from "qs";
|
|
|
|
import React from "react";
|
|
|
|
import { useIntl } from "react-intl";
|
|
|
|
import { Route, RouteComponentProps, Switch } from "react-router-dom";
|
|
|
|
|
|
|
|
import { WindowTitle } from "../components/WindowTitle";
|
|
|
|
import {
|
2022-02-02 15:30:34 +00:00
|
|
|
appDetailsPath,
|
2020-07-22 10:54:15 +00:00
|
|
|
AppDetailsUrlQueryParams,
|
|
|
|
appInstallPath,
|
|
|
|
AppInstallUrlQueryParams,
|
|
|
|
AppListUrlQueryParams,
|
|
|
|
appPath,
|
|
|
|
appsListPath,
|
|
|
|
} from "./urls";
|
2022-02-02 15:30:34 +00:00
|
|
|
import AppView from "./views/App";
|
2020-07-22 10:54:15 +00:00
|
|
|
import AppDetailsView from "./views/AppDetails";
|
|
|
|
import AppInstallView from "./views/AppInstall";
|
|
|
|
import AppsListView from "./views/AppsList";
|
|
|
|
|
|
|
|
const AppDetails: React.FC<RouteComponentProps<{ id: string }>> = ({
|
2022-06-21 09:36:55 +00:00
|
|
|
match,
|
2020-07-22 10:54:15 +00:00
|
|
|
}) => {
|
|
|
|
const qs = parseQs(location.search.substr(1));
|
|
|
|
const params: AppDetailsUrlQueryParams = qs;
|
|
|
|
|
|
|
|
return (
|
|
|
|
<AppDetailsView id={decodeURIComponent(match.params.id)} params={params} />
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
2022-02-02 15:30:34 +00:00
|
|
|
const App: React.FC<RouteComponentProps<{ id: string }>> = ({ match }) => (
|
|
|
|
<AppView id={decodeURIComponent(match.params.id)} />
|
|
|
|
);
|
2020-07-22 10:54:15 +00:00
|
|
|
|
|
|
|
const AppInstall: React.FC<RouteComponentProps> = props => {
|
|
|
|
const qs = parseQs(location.search.substr(1));
|
|
|
|
const params: AppInstallUrlQueryParams = qs;
|
|
|
|
|
|
|
|
return <AppInstallView params={params} {...props} />;
|
|
|
|
};
|
|
|
|
|
|
|
|
const AppsList: React.FC<RouteComponentProps> = () => {
|
|
|
|
const qs = parseQs(location.search.substr(1));
|
|
|
|
const params: AppListUrlQueryParams = qs;
|
|
|
|
|
|
|
|
return <AppsListView params={params} />;
|
|
|
|
};
|
|
|
|
const Component = () => {
|
|
|
|
const intl = useIntl();
|
|
|
|
|
|
|
|
return (
|
|
|
|
<>
|
|
|
|
<WindowTitle title={intl.formatMessage(sectionNames.apps)} />
|
|
|
|
<Switch>
|
|
|
|
<Route exact path={appsListPath} component={AppsList} />
|
|
|
|
<Route exact path={appInstallPath} component={AppInstall} />
|
2022-02-02 15:30:34 +00:00
|
|
|
<Route exact path={appDetailsPath(":id")} component={AppDetails} />
|
|
|
|
<Route path={appPath(":id")} component={App} />
|
2020-07-22 10:54:15 +00:00
|
|
|
<WebhooksRoutes />
|
|
|
|
</Switch>
|
|
|
|
</>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
export default Component;
|