IO-3464 Remove extra edit route

Signed-off-by: Allan Carr <allan@imexsystems.ca>
This commit is contained in:
Allan Carr
2025-12-15 12:40:43 -08:00
parent 6eb432b5b7
commit c675a328a8
3 changed files with 19 additions and 41 deletions

View File

@@ -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 (