Skip to content

Commit be1aa78

Browse files
committed
Make registration popover work
1 parent f3829d3 commit be1aa78

File tree

3 files changed

+28
-8
lines changed

3 files changed

+28
-8
lines changed

assets/src/components/Popovers/SubscribeFormPopover.js

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -78,12 +78,30 @@ export default function SubscribeFormPopover( { task, onSubmit, onClose } ) {
7878

7979
if ( response.success ) {
8080
setSuccess( true );
81-
// Call onSubmit after a short delay to show success message
82-
setTimeout( () => {
83-
if ( onSubmit ) {
84-
onSubmit( task.id, task );
81+
82+
// Save license key locally via WordPress AJAX and reload page.
83+
if ( response.license_key ) {
84+
const { ajaxUrl = '', nonce = '' } =
85+
window.prplDashboardConfig || {};
86+
87+
if ( ajaxUrl && nonce ) {
88+
const saveFormData = new FormData();
89+
saveFormData.append(
90+
'action',
91+
'progress_planner_save_onboard_data'
92+
);
93+
saveFormData.append( '_ajax_nonce', nonce );
94+
saveFormData.append( 'key', response.license_key );
95+
96+
await fetch( ajaxUrl, {
97+
method: 'POST',
98+
body: saveFormData,
99+
} );
85100
}
86-
}, 1500 );
101+
102+
// Reload page to reflect the new license state.
103+
window.location.reload();
104+
}
87105
} else {
88106
throw new Error(
89107
response.message ||

build/SubscribeFormPopover.chunk.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

classes/rest/class-subscribe.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,9 @@ public function subscribe( $request ) {
127127
);
128128
}
129129

130-
// License key is already saved by make_remote_onboarding_request.
130+
// Save the license key to the database.
131+
\update_option( 'progress_planner_license_key', $license_key, false );
132+
131133
return new \WP_REST_Response(
132134
[
133135
'success' => true,

0 commit comments

Comments
 (0)