<?php

declare( strict_types=1 );

use WPDesk\ShopMagic\Components\Routing\RoutesConfigurator;
use WPDesk\ShopMagicGoogleSheets\Controller\GoogleSheetsController;

$authorize = fn () => current_user_can('manage_options') || current_user_can( 'edit_others_shop_orders' );

return static function ( RoutesConfigurator $routes ) use ( $authorize ) {
	$routes
		->add( 'shopmagic/google-sheets/authorize' )
		->authorize( $authorize )
		->controller( [ GoogleSheetsController::class, 'authorize_start' ] );

	$routes
		->add( 'shopmagic/google-sheets/revoke' )
		->authorize( $authorize )
		->controller( [ GoogleSheetsController::class, 'revoke' ] );
};
