Mon Jul 18 2022
Copied to clipboard! Copy reply
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
 /**
     * This is the proper way to set SubMan value - on app mount (instead of of a single component
     * like MyAccount), so that it runs on root app initialization.
     * We (or, I) am currently short-cutting and doing this in MyAccount component,
     * and updating the `My Account` href based on a quick cookie check. After MVP,
     * this is to be reviseted and done properly to stay up with ZOOM's way of doing things.
     * Leaving this here to pick it up after launch.
     
      //Determine if user is subman here. 

      // This is cookie is set when user logs in via Community
      let submanCookie = getCookie('subman_user_data')

      // These next two cookies get set when user makes a purchase, and can be launched directly into the app.
      let submanBoolCookie = getCookie('subman_user_data')  // This is set after user makes a purchase
      let submanEmailCookie = getCookie('subman_user_data') // This is set after user makes a purchase
      
      const submanUserData = {}    

      if (submanCookie) {
        submanCookie = JSON.parse(decodeURIComponent(submanCookie))      
        submanUserData.email = submanCookie?.email ?? ""
        submanUserData.accountHeaderId = submanCookie?.accountHeaderId ?? ""
        // Can also keep going and set some other values sent from community, but no need
        // since we'll be fetching the user via an API. this exists here so we can 
        // display the right My Account page href.
      }
      if (submanUserData) {        
        // Dispatch action to update store state
        //dispatch(actions.fetchUserData('b@b.com'))      
      }
    }
    */