Skip to content

Commit 820ebff

Browse files
committed
chore: fill in correct profile details
1 parent 35cfbae commit 820ebff

File tree

5 files changed

+57
-42
lines changed

5 files changed

+57
-42
lines changed

src/nls/root/strings.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1583,5 +1583,8 @@ define({
15831583
"OPEN_SIGN_IN_URL": "Open Sign In Page",
15841584
"PROFILE_POP_TITLE": "{APP_NAME} Account",
15851585
"PROFILE_SIGN_IN": "Sign in to your account",
1586-
"CONTACT_SUPPORT": "Contact support"
1586+
"CONTACT_SUPPORT": "Contact support",
1587+
"SIGN_OUT": "Sign out",
1588+
"ACCOUNT_DETAILS": "Account Details",
1589+
"AI_QUOTA_USED": "AI quota used"
15871590
});

src/services/html/profile-popup.html

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,20 @@
11
<div class="profile-popup">
22
<div class="popup-header">
33
<div class="user-profile-header">
4-
<div class="user-avatar">
4+
<div class="user-avatar" style="background-color: {{avatarColor}};">
55
{{initials}}
66
</div>
77
<div class="user-info">
88
<div class="user-name">{{userName}}</div>
9-
<div class="user-plan">{{planName}}</div>
9+
<div class="user-email">{{email}}</div>
10+
<div class="{{planClass}}">{{planName}}</div>
1011
</div>
1112
</div>
1213
</div>
1314
<div class="popup-body">
1415
<div class="quota-section">
1516
<div class="quota-header">
16-
<span>{{quotaLabel}}</span>
17+
<span>{{Strings.AI_QUOTA_USED}}</span>
1718
<span>{{quotaUsed}} / {{quotaTotal}} {{quotaUnit}}</span>
1819
</div>
1920
<div class="progress-bar">
@@ -23,18 +24,18 @@
2324

2425
<button id="phoenix-account-btn" class="btn dialog-button menu-button">
2526
<i class="fa fa-user"></i>
26-
{{accountBtnText}}
27+
{{Strings.ACCOUNT_DETAILS}}
2728
</button>
2829

2930
<button id="phoenix-signout-btn" class="btn dialog-button menu-button signout">
3031
<i class="fa fa-sign-out-alt"></i>
31-
{{signOutBtnText}}
32+
{{Strings.SIGN_OUT}}
3233
</button>
3334

3435
<div class="support-link">
3536
<button id="phoenix-support-btn" class="text-link">
3637
<i class="fa fa-question-circle"></i>
37-
{{supportBtnText}}
38+
{{Strings.CONTACT_SUPPORT}}
3839
</button>
3940
</div>
4041
</div>

src/services/login.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,10 @@ define(function (require, exports, module) {
5757
return isLoggedInUser;
5858
}
5959

60+
function getProfile() {
61+
return userProfile;
62+
}
63+
6064
const ERR_RETRY_LATER = "retry_later";
6165
const ERR_INVALID = "invalid";
6266

@@ -330,6 +334,7 @@ define(function (require, exports, module) {
330334
secureExports.isLoggedIn = isLoggedIn;
331335
secureExports.signInToAccount = signInToAccount;
332336
secureExports.signOutAccount = signOutAccount;
337+
secureExports.getProfile = getProfile;
333338

334339
// public exports
335340
exports.isLoggedIn = isLoggedIn;

src/services/profile-menu.js

Lines changed: 17 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -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
}

src/styles/UserProfile.less

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,13 +54,24 @@
5454

5555
.user-name {
5656
font-weight: @font-weight-semibold;
57+
font-size: 16px;
5758
color: @bc-menu-text;
5859
}
5960

60-
.user-plan {
61-
color: #3c3;
62-
//color: #2b7d2b;
63-
font-size: 16px;
61+
.user-email {
62+
font-size: 12px;
63+
color: @bc-menu-text;
64+
}
65+
66+
.user-plan-paid {
67+
color: #2ea56c;
68+
font-size: 12px;
69+
font-weight: @font-weight-semibold;
70+
}
71+
72+
.user-plan-free {
73+
color: #3b82f6;
74+
font-size: 12px;
6475
}
6576

6677
.quota-section {
@@ -204,10 +215,19 @@
204215
color: @dark-bc-text-alt;
205216
}
206217

218+
.user-plan-paid {
219+
color: #3c3;
220+
font-size: 12px;
221+
}
222+
207223
.user-name {
208224
color: @dark-bc-menu-text;
209225
}
210226

227+
.user-email {
228+
color: @dark-bc-menu-text;
229+
}
230+
211231
.progress-bar {
212232
background-color: @dark-bc-input-bg;
213233
border-color: @dark-bc-btn-border;

0 commit comments

Comments
 (0)