Display Welcome Text with members name/ Update Profile

Hello,
Can I get some help with the code below. When a user registers as a member. I would like to display a Welcome " UserName"
But I can not figure out what I am doing wrong. Does anyone have another or simple code

Next once the member update their account info I would like to display the following:
Welcome UserName but this changes quickly to Update Complete, then back to Welcome Username.

I feel like I am missing a onclick event… My button is connect to my dataset for updating the members info.

any recommendations?

$w.onReady(function () {
 $w("#welcomeText").text = `Welcome ${theName}`;
       }
  $w("#updateacctButton").onAfterSave( () => {
    let theName = $w("#firstName").value;
    $w("#welcomeText").text = "Update Completed!";
   const millisecondsToDelay = 2500;
  setTimeout(() => {
$w("#welcomeText").text = `Welcome ${theName}`;
}, millisecondsToDelay);
  });
});

My onAfterSave is stating its not valid with my button.

Have a look at this YouTube video from Nayeli (Code Queen) with the page code and backend code here .

yes, I have I just need to learn how to formart the Welcome User code. I only want that part, now the rest of the code as I have no need for it on the front in.

You can take her code shown below and modify it for your needs which I think you have done partly already, plus try putting your onReady function on the dataset that your field values are saved into and not the button itself.

import wixData from 'wix-data';
$w.onReady(function () {
$w("#updateProfile").onReady( () => {
let isEmpty = $w("#updateProfile").getCurrentItem();
    let theName = $w("#firstName").value;
    if ( isEmpty === null ) {
      $w("#createProfileButton").show();
      $w("#updateProfileButton").hide();
      $w("#profileArea").collapse();
      $w("#welcomeUser").text = `Welcome New User. Please create a profile!`;
    } else {
      $w("#updateProfileButton").show();
      $w("#welcomeUser").text = `Welcome ${theName}`;
      $w("#profileArea").expand();
    }
} );
  $w("#updateProfile").onAfterSave( () => {
    let theName = $w("#firstName").value;
    $w("#welcomeUser").text = "Update Completed!";
   const millisecondsToDelay = 2500;
  setTimeout(() => {
$w("#welcomeUser").text = `Welcome ${theName}`;
}, millisecondsToDelay);
  });
});

How can i upload products to database by custom form create on a page please