IO-3464 Document Edit

Signed-off-by: Allan Carr <allan@imexsystems.ca>
This commit is contained in:
Allan Carr
2025-12-18 11:22:28 -08:00
parent c675a328a8
commit dfe0afd4f3
4 changed files with 56 additions and 41 deletions

View File

@@ -33,6 +33,19 @@ export function DocumentEditorContainer({ setBodyshop }) {
nextFetchPolicy: "network-only"
});
const isLocalMedia = !!dataShop?.bodyshops?.[0]?.uselocalmediaserver;
const {
loading: loadingDoc,
error: errorDoc,
data: dataDoc
} = useQuery(GET_DOCUMENT_BY_PK, {
variables: { documentId },
skip: !documentId || isLocalMedia,
fetchPolicy: "network-only",
nextFetchPolicy: "network-only"
});
useEffect(() => {
if (dataShop) setBodyshop(dataShop.bodyshops[0]);
}, [dataShop, setBodyshop]);
@@ -40,7 +53,7 @@ export function DocumentEditorContainer({ setBodyshop }) {
if (loadingShop) return <LoadingSpinner />;
if (errorShop) return <AlertComponent message={errorShop.message} type="error" />;
if (dataShop?.bodyshops[0]?.uselocalmediaserver) {
if (isLocalMedia) {
if (imageUrl && filename && jobid) {
return (
<div>
@@ -52,20 +65,13 @@ export function DocumentEditorContainer({ setBodyshop }) {
}
}
const { loading, error, data } = useQuery(GET_DOCUMENT_BY_PK, {
variables: { documentId },
skip: !documentId,
fetchPolicy: "network-only",
nextFetchPolicy: "network-only"
});
if (loadingDoc) return <LoadingSpinner />;
if (errorDoc) return <AlertComponent message={errorDoc.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")} />;
if (!dataDoc || !dataDoc.documents_by_pk) return <Result status="404" title={t("general.errors.notfound")} />;
return (
<div>
<DocumentEditor document={data ? data.documents_by_pk : null} />
<DocumentEditor document={dataDoc ? dataDoc.documents_by_pk : null} />
</div>
);
}