IO-3464 Remove extra edit route
Signed-off-by: Allan Carr <allan@imexsystems.ca>
This commit is contained in:
@@ -7,7 +7,6 @@ import { connect } from "react-redux";
|
||||
import { Route, Routes, useNavigate } from "react-router-dom";
|
||||
import { createStructuredSelector } from "reselect";
|
||||
import DocumentEditorContainer from "../components/document-editor/document-editor.container";
|
||||
import DocumentEditorLocalContainer from "../components/document-editor/document-editor-local.container";
|
||||
import ErrorBoundary from "../components/error-boundary/error-boundary.component";
|
||||
import LoadingSpinner from "../components/loading-spinner/loading-spinner.component";
|
||||
import DisclaimerPage from "../pages/disclaimer/disclaimer.page";
|
||||
@@ -242,9 +241,6 @@ export function App({
|
||||
<Route path="/edit/*" element={<PrivateRoute isAuthorized={currentUser.authorized} />}>
|
||||
<Route path="*" element={<DocumentEditorContainer />} />
|
||||
</Route>
|
||||
<Route path="/edit-local/*" element={<PrivateRoute isAuthorized={currentUser.authorized} />}>
|
||||
<Route path="*" element={<DocumentEditorLocalContainer />} />
|
||||
</Route>
|
||||
</Routes>
|
||||
</SoundWrapper>
|
||||
</NotificationProvider>
|
||||
|
||||
@@ -1,34 +0,0 @@
|
||||
import { useQuery } from "@apollo/client";
|
||||
import queryString from "query-string";
|
||||
import { useEffect } from "react";
|
||||
import { connect } from "react-redux";
|
||||
import { useLocation } from "react-router-dom";
|
||||
import { QUERY_BODYSHOP } from "../../graphql/bodyshop.queries";
|
||||
import { setBodyshop } from "../../redux/user/user.actions";
|
||||
import DocumentEditorLocalComponent from "./document-editor-local.component";
|
||||
|
||||
const mapDispatchToProps = (dispatch) => ({
|
||||
setBodyshop: (bs) => dispatch(setBodyshop(bs))
|
||||
});
|
||||
|
||||
export default connect(null, mapDispatchToProps)(DocumentEditorLocalContainer);
|
||||
|
||||
export function DocumentEditorLocalContainer({ setBodyshop }) {
|
||||
// Get the imageUrl, filename, jobid from the search string.
|
||||
const { imageUrl, filename, jobid } = queryString.parse(useLocation().search);
|
||||
|
||||
const { data: dataShop } = useQuery(QUERY_BODYSHOP, {
|
||||
fetchPolicy: "network-only",
|
||||
nextFetchPolicy: "network-only"
|
||||
});
|
||||
|
||||
useEffect(() => {
|
||||
if (dataShop) setBodyshop(dataShop.bodyshops[0]);
|
||||
}, [dataShop, setBodyshop]);
|
||||
|
||||
return (
|
||||
<div>
|
||||
<DocumentEditorLocalComponent imageUrl={imageUrl} filename={filename} jobid={jobid} />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -11,6 +11,7 @@ import { setBodyshop } from "../../redux/user/user.actions";
|
||||
import AlertComponent from "../alert/alert.component";
|
||||
import LoadingSpinner from "../loading-spinner/loading-spinner.component";
|
||||
import DocumentEditor from "./document-editor.component";
|
||||
import { DocumentEditorLocalComponent } from "./document-editor-local.component";
|
||||
|
||||
const mapDispatchToProps = (dispatch) => ({
|
||||
setBodyshop: (bs) => dispatch(setBodyshop(bs))
|
||||
@@ -21,7 +22,7 @@ export default connect(null, mapDispatchToProps)(DocumentEditorContainer);
|
||||
export function DocumentEditorContainer({ setBodyshop }) {
|
||||
//Get the image details for the image to be saved.
|
||||
//Get the document id from the search string.
|
||||
const { documentId } = queryString.parse(useLocation().search);
|
||||
const { documentId, imageUrl, filename, jobid } = queryString.parse(useLocation().search);
|
||||
const { t } = useTranslation();
|
||||
const {
|
||||
loading: loadingShop,
|
||||
@@ -36,6 +37,21 @@ export function DocumentEditorContainer({ setBodyshop }) {
|
||||
if (dataShop) setBodyshop(dataShop.bodyshops[0]);
|
||||
}, [dataShop, setBodyshop]);
|
||||
|
||||
if (loadingShop) return <LoadingSpinner />;
|
||||
if (errorShop) return <AlertComponent message={errorShop.message} type="error" />;
|
||||
|
||||
if (dataShop?.bodyshops[0]?.uselocalmediaserver) {
|
||||
if (imageUrl && filename && jobid) {
|
||||
return (
|
||||
<div>
|
||||
<DocumentEditorLocalComponent imageUrl={imageUrl} filename={filename} jobid={jobid} />
|
||||
</div>
|
||||
);
|
||||
} else {
|
||||
return <Result status="404" title={t("general.errors.notfound")} />;
|
||||
}
|
||||
}
|
||||
|
||||
const { loading, error, data } = useQuery(GET_DOCUMENT_BY_PK, {
|
||||
variables: { documentId },
|
||||
skip: !documentId,
|
||||
@@ -43,8 +59,8 @@ export function DocumentEditorContainer({ setBodyshop }) {
|
||||
nextFetchPolicy: "network-only"
|
||||
});
|
||||
|
||||
if (loading || loadingShop) return <LoadingSpinner />;
|
||||
if (error || errorShop) return <AlertComponent message={error.message || errorShop.message} type="error" />;
|
||||
if (loading) return <LoadingSpinner />;
|
||||
if (error) return <AlertComponent message={error.message} type="error" />;
|
||||
|
||||
if (!data || !data.documents_by_pk) return <Result status="404" title={t("general.errors.notfound")} />;
|
||||
return (
|
||||
|
||||
Reference in New Issue
Block a user