homegrade_blocks_production/blocks/parcours-step/src/edit.js

33 lines
778 B
JavaScript

import { __ } from "@wordpress/i18n";
import { useBlockProps } from "@wordpress/block-editor";
import OptionsSelectControl from "./OptionsSelectControl";
import { useSelect } from "@wordpress/data";
import "./editor.scss";
export default function Edit({ attributes, setAttributes }) {
const { relatedPostId } = attributes;
const post = useSelect((select) =>
select("core").getEntityRecord("postType", "parcours", relatedPostId)
);
return (
<>
<OptionsSelectControl
relatedPostId={relatedPostId}
setAttributes={setAttributes}
/>
<div
{...useBlockProps({
className: `homegrade-blocks-parcours-step parcours-step parcours-step-card`,
})}
>
{post && (
<>
<h3>{post.title.rendered}</h3>
</>
)}
</div>
</>
);
}