Fixes
This commit is contained in:
parent
9730e44abe
commit
10a366839b
3 changed files with 15 additions and 8 deletions
|
@ -23,6 +23,7 @@ import useNotifier from "@saleor/hooks/useNotifier";
|
||||||
import { commonMessages } from "@saleor/intl";
|
import { commonMessages } from "@saleor/intl";
|
||||||
import usePageSearch from "@saleor/searches/usePageSearch";
|
import usePageSearch from "@saleor/searches/usePageSearch";
|
||||||
import useProductSearch from "@saleor/searches/useProductSearch";
|
import useProductSearch from "@saleor/searches/useProductSearch";
|
||||||
|
import { getParsedDataForJsonStringField } from "@saleor/translations/utils";
|
||||||
import createMetadataUpdateHandler from "@saleor/utils/handlers/metadataUpdateHandler";
|
import createMetadataUpdateHandler from "@saleor/utils/handlers/metadataUpdateHandler";
|
||||||
import {
|
import {
|
||||||
useMetadataUpdate,
|
useMetadataUpdate,
|
||||||
|
@ -53,7 +54,7 @@ const createPageInput = (
|
||||||
attributes: data.attributes,
|
attributes: data.attributes,
|
||||||
updatedFileAttributes
|
updatedFileAttributes
|
||||||
}),
|
}),
|
||||||
content: !!data.content?.blocks.length ? JSON.stringify(data.content) : null,
|
content: getParsedDataForJsonStringField(data.content),
|
||||||
isPublished: data.isPublished,
|
isPublished: data.isPublished,
|
||||||
publicationDate: data.publicationDate,
|
publicationDate: data.publicationDate,
|
||||||
seo: {
|
seo: {
|
||||||
|
|
|
@ -56,6 +56,7 @@ import {
|
||||||
} from "@saleor/products/types/VariantCreate";
|
} from "@saleor/products/types/VariantCreate";
|
||||||
import { mapFormsetStockToStockInput } from "@saleor/products/utils/data";
|
import { mapFormsetStockToStockInput } from "@saleor/products/utils/data";
|
||||||
import { getAvailabilityVariables } from "@saleor/products/utils/handlers";
|
import { getAvailabilityVariables } from "@saleor/products/utils/handlers";
|
||||||
|
import { getParsedDataForJsonStringField } from "@saleor/translations/utils";
|
||||||
import { ReorderEvent } from "@saleor/types";
|
import { ReorderEvent } from "@saleor/types";
|
||||||
import { move } from "@saleor/utils/lists";
|
import { move } from "@saleor/utils/lists";
|
||||||
import { diff } from "fast-array-diff";
|
import { diff } from "fast-array-diff";
|
||||||
|
@ -185,9 +186,7 @@ export function createUpdateHandler(
|
||||||
category: data.category,
|
category: data.category,
|
||||||
chargeTaxes: data.chargeTaxes,
|
chargeTaxes: data.chargeTaxes,
|
||||||
collections: data.collections,
|
collections: data.collections,
|
||||||
description: !!data.description?.blocks?.length
|
description: getParsedDataForJsonStringField(data.description),
|
||||||
? JSON.stringify(data.description)
|
|
||||||
: null,
|
|
||||||
name: data.name,
|
name: data.name,
|
||||||
rating: data.rating,
|
rating: data.rating,
|
||||||
seo: {
|
seo: {
|
||||||
|
|
|
@ -1,16 +1,23 @@
|
||||||
import { OutputData } from "@editorjs/editorjs";
|
import { OutputData } from "@editorjs/editorjs";
|
||||||
import { TranslationInput } from "@saleor/types/globalTypes";
|
|
||||||
|
|
||||||
import { TranslationInputFieldName } from "./types";
|
import {
|
||||||
|
PageTranslationInputFieldName,
|
||||||
|
TranslationInputFieldName
|
||||||
|
} from "./types";
|
||||||
|
|
||||||
export const getParsedTranslationInputData = ({
|
export const getParsedTranslationInputData = ({
|
||||||
fieldName,
|
fieldName,
|
||||||
data
|
data
|
||||||
}: {
|
}: {
|
||||||
fieldName: keyof TranslationInput;
|
fieldName: TranslationInputFieldName | PageTranslationInputFieldName;
|
||||||
data: string | OutputData;
|
data: string | OutputData;
|
||||||
}): Record<string, string | null> => {
|
}): Record<string, string | null> => {
|
||||||
if (fieldName === TranslationInputFieldName.description) {
|
const fieldsToParse = [
|
||||||
|
TranslationInputFieldName.description,
|
||||||
|
PageTranslationInputFieldName.content
|
||||||
|
];
|
||||||
|
|
||||||
|
if (fieldsToParse.includes(fieldName)) {
|
||||||
return {
|
return {
|
||||||
description: getParsedDataForJsonStringField(data as OutputData)
|
description: getParsedDataForJsonStringField(data as OutputData)
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue