Sha256: b0ecc34185f1fbabf720deafe8ea88391ae00cab9c682e313315779bf355b4e4

Contents?: true

Size: 996 Bytes

Versions: 1

Compression:

Stored size: 996 Bytes

Contents

import { Fragment } from "react";

import { MaybeLocalizedValue } from "../../types";
import { blockValue, errorsOn, unconfiguredBlocks } from "./utils";
import usePageFormContext from "./usePageFormContext";

import Block from "./Block";

export default function UnconfiguredContent() {
  const { state, dispatch } = usePageFormContext();

  const { page, locale, inputDir } = state;

  const handleChange = (attr: string) => (value: MaybeLocalizedValue) => {
    dispatch({ type: "updateBlocks", payload: { [attr]: value } });
  };

  return (
    <Fragment>
      <p>
        This page has additional content fields not enabled by the selected
        template.
      </p>
      {unconfiguredBlocks(state).map((b) => (
        <Block
          key={b.name}
          block={b}
          errors={errorsOn(page, b.name)}
          dir={inputDir}
          lang={locale}
          onChange={handleChange(b.name)}
          value={blockValue(state, b)}
        />
      ))}
    </Fragment>
  );
}

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
pages_core-3.15.5 app/javascript/components/PageForm/UnconfiguredContent.tsx