@@ -41,26 +41,6 @@ define(function (require, exports, module) {
4141 // this is to handle document click events to close popup
4242 let documentClickHandler = null ;
4343
44- const defaultLoginData = {
45- welcomeTitle : "Welcome to Phoenix Code" ,
46- signInBtnText : "Sign in to your account" ,
47- supportBtnText : "Contact support"
48- } ;
49-
50- const defaultProfileData = {
51- initials : "CA" ,
52- userName : "Charly A." ,
53- planName : "Paid Plan" ,
54- quotaLabel : "AI quota used" ,
55- quotaUsed : "7,000" ,
56- quotaTotal : "10,000" ,
57- quotaUnit : "tokens" ,
58- quotaPercent : 70 ,
59- accountBtnText : "Account details" ,
60- supportBtnText : "Contact support" ,
61- signOutBtnText : "Sign out"
62- } ;
63-
6444 function _handleSignInBtnClick ( ) {
6545 closePopup ( ) ; // need to close the current popup to show the new one
6646 KernalModeTrust . loginService . signInToAccount ( ) ;
@@ -201,19 +181,27 @@ define(function (require, exports, module) {
201181
202182 /**
203183 * Shows the user profile popup when the user is logged in
204- * @param {Object } profileData - Data to populate the template (optional)
205184 */
206- function showProfilePopup ( profileData ) {
185+ function showProfilePopup ( ) {
207186 // If popup is already visible, just close it
208187 if ( isPopupVisible ) {
209188 closePopup ( ) ;
210189 return ;
211190 }
212-
213- // Merge provided data with defaults
214- const templateData = $ . extend ( { } , defaultProfileData , profileData || { } ) ;
215-
216- closePopup ( ) ;
191+ const profileData = KernalModeTrust . loginService . getProfile ( ) ;
192+ const templateData = {
193+ initials : profileData . profileIcon . initials ,
194+ avatarColor : profileData . profileIcon . color ,
195+ userName : profileData . firstName + " " + profileData . lastName ,
196+ email : profileData . email ,
197+ planClass : "user-plan-free" ,
198+ planName : "Free Plan" ,
199+ quotaUsed : "7,000" ,
200+ quotaTotal : "10,000" ,
201+ quotaUnit : "tokens" ,
202+ quotaPercent : 70 ,
203+ Strings : Strings
204+ } ;
217205
218206 // Render template with data
219207 const renderedTemplate = Mustache . render ( profileTemplate , templateData ) ;
@@ -255,18 +243,16 @@ define(function (require, exports, module) {
255243
256244 /**
257245 * Toggle the profile popup based on the user's login status
258- * this function is called inside the src/extensionsIntegrated/Phoenix/main.js when user clicks on the profile icon
259- * @param {Object } data - Data to populate the templates (optional)
260246 */
261- function togglePopup ( data ) {
247+ function togglePopup ( ) {
262248 // check if the popup is already visible or not. if visible close it
263249 if ( isPopupVisible ) {
264250 closePopup ( ) ;
265251 return ;
266252 }
267253
268254 if ( KernalModeTrust . loginService . isLoggedIn ( ) ) {
269- showProfilePopup ( data ) ;
255+ showProfilePopup ( ) ;
270256 } else {
271257 showLoginPopup ( ) ;
272258 }
0 commit comments