diff --git a/app/components/profile-field.hbs b/app/components/profile-field.hbs index e1c00879..ca4060e5 100644 --- a/app/components/profile-field.hbs +++ b/app/components/profile-field.hbs @@ -10,6 +10,7 @@ placeholder={{@placeholder}} class="profile-field-input" required={{@required}} + disabled={{@isDeveloper}} {{on 'input' (fn this.inputFieldChanged)}} {{on 'blur' (fn this.checkInputValidation)}} /> diff --git a/app/routes/profile.js b/app/routes/profile.js index 45527b20..7254d6ce 100644 --- a/app/routes/profile.js +++ b/app/routes/profile.js @@ -8,6 +8,10 @@ export default class ProfileRoute extends Route { @service toast; async model() { try { + const res = await fetch(`${ENV.BASE_API_URL}/users/isDeveloper`, { + credentials: 'include', + }); + const { developerRoleExistsOnUser } = await res.json(); const response = await fetch(`${ENV.BASE_API_URL}/users/self`, { credentials: 'include', }); @@ -15,6 +19,7 @@ export default class ProfileRoute extends Route { if (response.status === 401) { throw new Error('You are not logged in. Please login to continue.'); } + userData.isDeveloper = developerRoleExistsOnUser; return userData; } catch (error) { console.error(error.message); diff --git a/app/styles/profile.css b/app/styles/profile.css index 9178b7ac..f518b6b6 100644 --- a/app/styles/profile.css +++ b/app/styles/profile.css @@ -39,6 +39,11 @@ border-color: var(--profile-input-outline-clr); } +.profile-page-error { + text-align: center; + color: red; +} + .profile-field-input { padding: 0 1.25rem; border: none; @@ -46,6 +51,12 @@ outline: none; } +.profile-field-input:disabled { + opacity: 0.6; + cursor: not-allowed; + pointer-events: none; +} + .profile-field-input:active { border-color: var(--profile-input-outline-clr); } diff --git a/app/templates/profile.hbs b/app/templates/profile.hbs index 88403f18..0132af9d 100644 --- a/app/templates/profile.hbs +++ b/app/templates/profile.hbs @@ -1,35 +1,58 @@ {{page-title 'Profile'}} -
-
+
+
{{#if @model.picture.url}} - user profile + user profile {{else}} - user profile + user profile {{/if}} -
+ {{#if (get @model 'isDeveloper')}} +

You can't update the profile data from UI. + You have to create a profile service(if not created yet). Find more + details about profile service + here.

+ {{/if}} {{#each this.fields as |field|}} - {{/each}}
- +
diff --git a/tests/integration/components/profile-field-test.js b/tests/integration/components/profile-field-test.js index 9fb35415..c1287b9a 100644 --- a/tests/integration/components/profile-field-test.js +++ b/tests/integration/components/profile-field-test.js @@ -44,4 +44,58 @@ module('Integration | Component | profile-field', function (hooks) { assert.dom('[data-test-profile-field]').hasClass('profile-field-error'); assert.dom('[data-test-profile-field-error]').hasText(this.errorMessage); }); + + test('disabled profile field renders when isDeveloper is true', async function (assert) { + this.setProperties({ + label: 'First Name*', + icon_url: 'icons/user.svg', + isDeveloper: true, + }); + + await render(hbs` + + `); + + assert.dom('[data-test-profile-field-label]').hasText(this.label); + assert + .dom('[data-test-profile-field-icon]') + .exists() + .hasAttribute('src', this.icon_url); + assert + .dom('[data-test-profile-field-input]') + .hasProperty('disabled', true) + .exists(); + assert.dom('[data-test-profile-field-error]').exists(); + }); + + test('profile field renders when isDeveloper is false', async function (assert) { + this.setProperties({ + label: 'First Name*', + icon_url: 'icons/user.svg', + isDeveloper: false, + }); + + await render(hbs` + + `); + + assert.dom('[data-test-profile-field-label]').hasText(this.label); + assert + .dom('[data-test-profile-field-icon]') + .exists() + .hasAttribute('src', this.icon_url); + assert + .dom('[data-test-profile-field-input]') + .hasProperty('disabled', false) + .exists(); + assert.dom('[data-test-profile-field-error]').exists(); + }); });