@@ -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>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user