components
2 years ago
BlockInspectorControls.tsx
2 years ago
BlockPlaceholder.tsx
1 year ago
BlockPlaceholderNoEvents.tsx
2 years ago
BlockPlaceholderSelectEvent.tsx
2 years ago
index.tsx
2 years ago
styles.scss
1 year ago
index.tsx
33 lines
| 1 | import BlockInspectorControls from './BlockInspectorControls'; |
| 2 | import BlockPlaceholderNoEvents from './BlockPlaceholderNoEvents'; |
| 3 | import BlockPlaceholder from './BlockPlaceholder'; |
| 4 | import BlockPlaceholderSelectEvent from './BlockPlaceholderSelectEvent'; |
| 5 | |
| 6 | import './styles.scss'; |
| 7 | |
| 8 | /** |
| 9 | * @since 3.6.0 |
| 10 | */ |
| 11 | export default function Edit(props) { |
| 12 | const {events} = window.eventTicketsBlockSettings; |
| 13 | const { |
| 14 | attributes: {eventId}, |
| 15 | } = props; |
| 16 | |
| 17 | const eventIds = events.map((event) => event.id); |
| 18 | |
| 19 | return ( |
| 20 | <> |
| 21 | {events.length === 0 ? ( |
| 22 | <BlockPlaceholderNoEvents /> |
| 23 | ) : !eventId || !eventIds.includes(eventId) ? ( |
| 24 | <BlockPlaceholderSelectEvent {...props} /> |
| 25 | ) : ( |
| 26 | <BlockPlaceholder {...props} /> |
| 27 | )} |
| 28 | |
| 29 | <BlockInspectorControls {...props} /> |
| 30 | </> |
| 31 | ); |
| 32 | } |
| 33 |