Skip to content

Conversation

@faisal-alvi
Copy link
Contributor

Description of the Change

This PR introduces a Gutenberg block for “Jobber Schedule,” allowing users to easily insert a Jobber booking/request form into any WordPress page using the native block editor.

Closes #6

How to test the Change

Ensure the block works as expected in #6.

Changelog Entry

Added - Introduce Jobber Schedule block for easily embedding Jobber booking/request forms

Credits

Props @vikrampm1 @faisal-alvi

Checklist:

@faisal-alvi faisal-alvi added this to the 1.0.0 milestone Mar 27, 2025
@faisal-alvi faisal-alvi self-assigned this Mar 27, 2025
* Register the block types.
*/
public function register_block_types() {
register_block_type(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it be better to check if we have a valid access token before we register the block? Right now I can add the block immediately after activating the plugin, though it will show an error message. I guess I can see two approaches:

  1. Don't register the block at all until an account has been connected
  2. Register the block but update our error message in the admin to point people to the settings page so they can authenticate

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thinking about it more, there is a potential for someone to activate the plugin, totally miss the authentication step and then wonder why there isn't a block for them to use. In that scenario, I think option 2 above is the right approach. Always register the block but let's show a better error message, prompting them to go to the settings screen to authenticate.

Would be great if we could check for an access token before making the API request and instead show the component (or something similar) with messaging that prompts someone to go authenticate.

$jobber = new \Jobber\Jobber();
$response = $jobber->get_form( $form_type );

if ( is_wp_error( $response ) ) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we encounter an error or we don't have a valid URL to display, wondering if we want to output an error message. I think that would just confuse users and may be better to just not render anything

@dkotter dkotter marked this pull request as ready for review April 14, 2025 16:32
@dkotter dkotter merged commit 0c3e82b into develop Apr 14, 2025
@dkotter dkotter deleted the add/jobber-block branch April 14, 2025 16:34
@dkotter dkotter linked an issue Apr 14, 2025 that may be closed by this pull request
@jeffpaul jeffpaul mentioned this pull request Apr 16, 2025
6 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Build Jobber Scheduling Block Plugin Settings Page

2 participants