46 lines
1.3 KiB
JavaScript
46 lines
1.3 KiB
JavaScript
import { useBlockProps } from '@wordpress/block-editor';
|
|
import { ExternalLink } from '@wordpress/components';
|
|
|
|
/**
|
|
* The save function defines the way in which the different attributes should
|
|
* be combined into the final markup, which is then serialized by the block
|
|
* editor into `post_content`.
|
|
*
|
|
* @see https://developer.wordpress.org/block-editor/reference-guides/block-api/block-edit-save/#save
|
|
*
|
|
* @return {WPElement} Element to render.
|
|
*/
|
|
export default function save( { attributes } ) {
|
|
const blockProps = useBlockProps.save();
|
|
return (
|
|
<div { ...blockProps } data-tournament-id={ attributes.tournament_id }>
|
|
{attributes.data && (
|
|
<table id="tournament-results-table">
|
|
<thead>
|
|
<tr>
|
|
<th>Place</th>
|
|
<th>Player</th>
|
|
<th>Points</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
{Object.keys(attributes.data).map((player, i) => {
|
|
return (
|
|
<tr key={player}>
|
|
<td>{attributes.data[i].position}</td>
|
|
<td>{attributes.data[i].name}</td>
|
|
<td>{attributes.data[i].points}</td>
|
|
</tr>
|
|
);
|
|
})}
|
|
</tbody>
|
|
</table>
|
|
)}
|
|
|
|
{/* <ExternalLink href={ `https://next.matchplay.events/tournaments/${ attributes.tournament_id }/standings` }>
|
|
Full Results on Matchplay
|
|
</ExternalLink> */}
|
|
</div>
|
|
);
|
|
}
|