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 usePageSearch from "@saleor/searches/usePageSearch";
|
||||
import useProductSearch from "@saleor/searches/useProductSearch";
|
||||
import { getParsedDataForJsonStringField } from "@saleor/translations/utils";
|
||||
import createMetadataUpdateHandler from "@saleor/utils/handlers/metadataUpdateHandler";
|
||||
import {
|
||||
useMetadataUpdate,
|
||||
|
@ -53,7 +54,7 @@ const createPageInput = (
|
|||
attributes: data.attributes,
|
||||
updatedFileAttributes
|
||||
}),
|
||||
content: !!data.content?.blocks.length ? JSON.stringify(data.content) : null,
|
||||
content: getParsedDataForJsonStringField(data.content),
|
||||
isPublished: data.isPublished,
|
||||
publicationDate: data.publicationDate,
|
||||
seo: {
|
||||
|
|
|
@ -56,6 +56,7 @@ import {
|
|||
} from "@saleor/products/types/VariantCreate";
|
||||
import { mapFormsetStockToStockInput } from "@saleor/products/utils/data";
|
||||
import { getAvailabilityVariables } from "@saleor/products/utils/handlers";
|
||||
import { getParsedDataForJsonStringField } from "@saleor/translations/utils";
|
||||
import { ReorderEvent } from "@saleor/types";
|
||||
import { move } from "@saleor/utils/lists";
|
||||
import { diff } from "fast-array-diff";
|
||||
|
@ -185,9 +186,7 @@ export function createUpdateHandler(
|
|||
category: data.category,
|
||||
chargeTaxes: data.chargeTaxes,
|
||||
collections: data.collections,
|
||||
description: !!data.description?.blocks?.length
|
||||
? JSON.stringify(data.description)
|
||||
: null,
|
||||
description: getParsedDataForJsonStringField(data.description),
|
||||
name: data.name,
|
||||
rating: data.rating,
|
||||
seo: {
|
||||
|
|
|
@ -1,16 +1,23 @@
|
|||
import { OutputData } from "@editorjs/editorjs";
|
||||
import { TranslationInput } from "@saleor/types/globalTypes";
|
||||
|
||||
import { TranslationInputFieldName } from "./types";
|
||||
import {
|
||||
PageTranslationInputFieldName,
|
||||
TranslationInputFieldName
|
||||
} from "./types";
|
||||
|
||||
export const getParsedTranslationInputData = ({
|
||||
fieldName,
|
||||
data
|
||||
}: {
|
||||
fieldName: keyof TranslationInput;
|
||||
fieldName: TranslationInputFieldName | PageTranslationInputFieldName;
|
||||
data: string | OutputData;
|
||||
}): Record<string, string | null> => {
|
||||
if (fieldName === TranslationInputFieldName.description) {
|
||||
const fieldsToParse = [
|
||||
TranslationInputFieldName.description,
|
||||
PageTranslationInputFieldName.content
|
||||
];
|
||||
|
||||
if (fieldsToParse.includes(fieldName)) {
|
||||
return {
|
||||
description: getParsedDataForJsonStringField(data as OutputData)
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue