
* Add shipping method description - WIP * Wire up logic * Handle more editorjs issues * Fix minor issues Co-authored-by: Dawid Tarasiuk <tarasiukdawid@gmail.com>
28 lines
732 B
TypeScript
28 lines
732 B
TypeScript
import { OutputData } from "@editorjs/editorjs";
|
|
import { getParsedDataForJsonStringField } from "@saleor/utils/richText/misc";
|
|
|
|
import {
|
|
PageTranslationInputFieldName,
|
|
TranslationInputFieldName
|
|
} from "./types";
|
|
|
|
export const getParsedTranslationInputData = ({
|
|
fieldName,
|
|
data
|
|
}: {
|
|
fieldName: TranslationInputFieldName | PageTranslationInputFieldName;
|
|
data: string | OutputData;
|
|
}): Record<string, string | null> => {
|
|
const fieldsToParse = [
|
|
TranslationInputFieldName.description,
|
|
PageTranslationInputFieldName.content
|
|
];
|
|
|
|
if (fieldsToParse.includes(fieldName)) {
|
|
return {
|
|
[fieldName]: getParsedDataForJsonStringField(data as OutputData)
|
|
};
|
|
}
|
|
|
|
return { [fieldName]: data as string };
|
|
};
|