Sha256: b55ccc55ffd755c490131d369d8d0bfb5239951e3466c5cc0c71ffc3efd548b1
Contents?: true
Size: 1.41 KB
Versions: 1
Compression:
Stored size: 1.41 KB
Contents
import { Fragment } from "react"; import * as Tags from "../../types/Tags"; import { MaybeLocalizedValue } from "../../types"; import { blockValue, errorsOn } from "./utils"; import usePageFormContext from "./usePageFormContext"; import LabelledField from "../LabelledField"; import { default as TagEditor } from "../TagEditor/Editor"; import Block from "./Block"; import Dates from "./Dates"; type Props = { tagsState: Tags.State; tagsDispatch: React.Dispatch<Tags.Action>; }; export default function Content({ tagsState, tagsDispatch }: Props) { const { state, dispatch } = usePageFormContext(); const { page, locale, inputDir, templateConfig } = state; const handleChange = (attr: string) => (value: MaybeLocalizedValue) => { dispatch({ type: "updateBlocks", payload: { [attr]: value } }); }; return ( <Fragment> {templateConfig.blocks.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)} /> ))} {templateConfig.dates && <Dates />} {templateConfig.tags && ( <LabelledField label="Tags"> <TagEditor name="page[serialized_tags]" state={tagsState} dispatch={tagsDispatch} /> </LabelledField> )} </Fragment> ); }
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
pages_core-3.15.5 | app/javascript/components/PageForm/Content.tsx |