Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions app/components/join-steps/status-card.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,32 @@
{{/if}}
<p data-test-status-card-description-4>You're almost there! Join our
Discord server to connect with the team.</p>
{{else if
(eq this.status this.APPLICATION_STATUS_TYPES.changes_requested)
}}
<p data-test-status-card-description-1>
Admin has requested some changes on your application.
</p>

{{#if this.feedback}}
<div class="status-card__feedback">
<p data-test-status-card-feedback-title><strong
>Feedback:</strong></p>
<p data-test-status-card-feedback-content>{{this.feedback}}</p>
</div>
{{/if}}

<p data-test-status-card-description-encouragement>
Please review the feedback and update your application accordingly.
</p>

<Reusables::Button
@text="Edit Application"
@variant="dark"
@onClick={{this.editApplication}}
@test="edit-application-btn"
@type="button"
/>
{{/if}}
</div>

Expand Down
22 changes: 21 additions & 1 deletion app/components/join-steps/status-card.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@ export default class StatusCardComponent extends Component {
heading: 'Accepted',
icon: 'square-check',
},
{
status: APPLICATION_STATUS_TYPES.changes_requested,
heading: 'Changes Requested',
icon: 'edit',
},
];

constructor() {
Expand All @@ -51,7 +56,11 @@ export default class StatusCardComponent extends Component {
}

get feedback() {
return this.args.feedback || this.fetchedFeedback;
const lastMessage = this.args.feedback || this.fetchedFeedback;
if (Array.isArray(lastMessage)) {
return lastMessage[lastMessage.length - 1].feedback;
}
return lastMessage;
}

get currentStatusDetails() {
Expand Down Expand Up @@ -101,6 +110,17 @@ export default class StatusCardComponent extends Component {
this.toast.error('Error in copying to clipboard', 'Error!', TOAST_OPTIONS);
}

@action
editApplication() {
this.router.transitionTo('join', {
queryParams: {
edit: true,
dev: true,
step: 1,
},
});
}

@action
trackApplication() {
if (this.applicationId) {
Expand Down
11 changes: 9 additions & 2 deletions app/components/new-join-steps/base-step.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,10 +101,14 @@ export default class BaseStepComponent extends Component {

@action inputHandler(e) {
if (!e?.target) return;
this.args.setIsPreValid(false);
const field = e.target.name;
const value = e.target.value;
debounceTask(this, 'handleFieldUpdate', field, value, JOIN_DEBOUNCE_TIME);
this.updateFieldValue(field, value);
const result = this.validateField(field, value);
this.updateWordCount(field, result);
this.updateErrorMessage(field, result);
this.args.setIsPreValid(this.isDataValid());
debounceTask(this, 'syncFormValidity', JOIN_DEBOUNCE_TIME);
}

validateField(field, value) {
Expand Down Expand Up @@ -159,6 +163,9 @@ export default class BaseStepComponent extends Component {
if (fieldType === 'select' || fieldType === 'dropdown') {
return 'Please choose an option';
}
if (fieldType === 'image') {
return 'Please upload a profile image';
}
if (result.remainingToMin) {
return `At least ${result.remainingToMin} more word(s) required`;
}
Expand Down
8 changes: 7 additions & 1 deletion app/components/new-join-steps/new-step-one.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,11 @@
/>

<div class="role-selection">
<p>Applying as</p>
<p>Applying as
{{#if this.isRoleAvailable}}<span
class="role-selection-message"
data-test="role-selection-message"
>(auto-applied from profile)</span>{{/if}}</p>
<div class="role-buttons" role="radiogroup" aria-label="Select your role">
{{#each this.roleOptions as |role|}}
<button
Expand All @@ -112,6 +116,8 @@
{{if (eq this.data.role role) 'role-button--selected'}}"
role="radio"
aria-checked="{{if (eq this.data.role role) 'true' 'false'}}"
disabled={{this.isRoleAvailable}}
data-test="role-button"
{{on "click" (fn this.selectRole role)}}
>
{{role}}
Expand Down
11 changes: 11 additions & 0 deletions app/components/new-join-steps/new-step-one.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
NEW_STEP_LIMITS,
ROLE_OPTIONS,
STEP_DATA_STORAGE_KEY,
USER_ROLE_MAP,
} from '../../constants/new-join-form';
import { USER_PROFILE_IMAGE_URL } from '../../constants/apis';
import { TOAST_OPTIONS } from '../../constants/toast-options';
Expand All @@ -21,6 +22,7 @@ export default class NewStepOneComponent extends BaseStepComponent {
@tracked imagePreview = null;
@tracked isImageUploading = false;
@tracked fileInputElement = null;
@tracked isRoleAvailable = false;

get storageKey() {
return STEP_DATA_STORAGE_KEY.stepOne;
Expand All @@ -31,6 +33,7 @@ export default class NewStepOneComponent extends BaseStepComponent {
state: NEW_STEP_LIMITS.stepOne.state,
city: NEW_STEP_LIMITS.stepOne.city,
role: NEW_STEP_LIMITS.stepOne.role,
imageUrl: NEW_STEP_LIMITS.stepOne.imageUrl,
};

get fullName() {
Expand All @@ -52,6 +55,14 @@ export default class NewStepOneComponent extends BaseStepComponent {
if (this.data.imageUrl) {
this.imagePreview = this.data.imageUrl;
}
const userRole = this.login.userData?.role;
if (userRole) {
const roleKey = Object.keys(USER_ROLE_MAP).find(
(key) => USER_ROLE_MAP[key] === userRole,
);
this.updateFieldValue('role', roleKey);
this.isRoleAvailable = true;
}
Comment on lines +58 to +65
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Guard unmapped profile roles before disabling role selection.

If userRole exists but has no match in USER_ROLE_MAP, Line 63 writes undefined and Line 64 still sets isRoleAvailable = true. That disables all role buttons without selecting a valid role.

Suggested fix
     const userRole = this.login.userData?.role;
     if (userRole) {
       const roleKey = Object.keys(USER_ROLE_MAP).find(
         (key) => USER_ROLE_MAP[key] === userRole,
       );
-      this.updateFieldValue('role', roleKey);
-      this.isRoleAvailable = true;
+      if (roleKey) {
+        this.updateFieldValue('role', roleKey);
+        this.isRoleAvailable = true;
+      }
     }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
const userRole = this.login.userData?.role;
if (userRole) {
const roleKey = Object.keys(USER_ROLE_MAP).find(
(key) => USER_ROLE_MAP[key] === userRole,
);
this.updateFieldValue('role', roleKey);
this.isRoleAvailable = true;
}
const userRole = this.login.userData?.role;
if (userRole) {
const roleKey = Object.keys(USER_ROLE_MAP).find(
(key) => USER_ROLE_MAP[key] === userRole,
);
if (roleKey) {
this.updateFieldValue('role', roleKey);
this.isRoleAvailable = true;
}
}
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@app/components/new-join-steps/new-step-one.js` around lines 58 - 65, The code
assumes any existing userRole maps to a key and sets isRoleAvailable true even
when unmapped; change the logic in the block that uses userRole/USER_ROLE_MAP so
you first compute roleKey (from Object.keys(USER_ROLE_MAP).find(...)) and then
only call this.updateFieldValue('role', roleKey) and set this.isRoleAvailable =
true when roleKey is defined (non-undefined); if roleKey is undefined, do not
call updateFieldValue and ensure this.isRoleAvailable remains false so role
buttons are not disabled. Also keep the checks around this.login.userData?.role
(userRole) as-is.

}

@action selectRole(role) {
Expand Down
13 changes: 7 additions & 6 deletions app/components/new-stepper.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export default class NewStepperComponent extends Component {
@service toast;

@tracked preValid = false;
@tracked isValid = getLocalStorageItem('isValid') === 'true';
@tracked isValid = false;
@tracked isSubmitting = false;

@tracked currentStep = 0;
Expand Down Expand Up @@ -135,6 +135,7 @@ export default class NewStepperComponent extends Component {
const method = this.isEditMode ? 'PATCH' : 'POST';

const response = await apiRequest(url, method, applicationData);
const data = await response.json();

if (response.status === 409) {
this.toast.error(
Expand All @@ -150,7 +151,7 @@ export default class NewStepperComponent extends Component {

if (!response.ok) {
this.toast.error(
response.message ||
data.message ||
`Failed to ${this.isEditMode ? 'edit' : 'submit'} application. Please try again.`,
'Error!',
TOAST_OPTIONS,
Expand All @@ -159,8 +160,6 @@ export default class NewStepperComponent extends Component {
return;
}

await response.json();

this.toast.success(
this.isEditMode
? 'You have successfully edited the application'
Expand All @@ -169,9 +168,10 @@ export default class NewStepperComponent extends Component {
TOAST_OPTIONS,
);

const applicationId =
data?.applicationId ?? this.onboarding.applicationData?.id;
this.clearAllStepData();
this.isSubmitting = false;
this.router.replaceWith('join', {
this.router.transitionTo('applications.detail', applicationId, {
queryParams: { dev: true },
});
} catch (error) {
Expand All @@ -181,6 +181,7 @@ export default class NewStepperComponent extends Component {
'Error!',
TOAST_OPTIONS,
);
} finally {
this.isSubmitting = false;
}
}
Expand Down
6 changes: 4 additions & 2 deletions app/components/signup-steps/step-zero.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@
data-test-rds-logo-img
/>
{{#if this.login.isLoggedIn}}
<h2 class="heading__h3" data-test-signup-heading>Thank you for connecting
your GitHub</h2>
<h2
class="heading__h3"
data-test-signup-heading
>{{this.GET_STARTED_MAIN_HEADING}}</h2>
<p class="p2-description" data-test-signup-paragraph>Please continue with
Sign Up with in order to use features display yourself on members page etc</p>
<Reusables::Button
Expand Down
2 changes: 2 additions & 0 deletions app/components/signup-steps/step-zero.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import Component from '@glimmer/component';
import { service } from '@ember/service';
import { action } from '@ember/object';
import { AUTH } from '../../constants/urls';
import { GET_STARTED_MAIN_HEADING } from '../../constants/new-signup';
import { tracked } from '@glimmer/tracking';

export default class SignupStepsStepZeroComponent extends Component {
Expand All @@ -11,6 +12,7 @@ export default class SignupStepsStepZeroComponent extends Component {
@service store;
@service controller;
@tracked currentStep = 0;
GET_STARTED_MAIN_HEADING = GET_STARTED_MAIN_HEADING;

@action loginWithGithub() {
if (!this.login.isLoggedIn) {
Expand Down
3 changes: 2 additions & 1 deletion app/constants/join.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export const JOIN_DEBOUNCE_TIME = 1000;
export const JOIN_DEBOUNCE_TIME = 300;
export const STEP_ONE_LIMITS = {
city: 1,
state: 1,
Expand All @@ -25,4 +25,5 @@ export const APPLICATION_STATUS_TYPES = {
accepted: 'accepted',
rejected: 'rejected',
pending: 'pending',
changes_requested: 'changes_requested',
};
1 change: 1 addition & 0 deletions app/constants/new-join-form.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ export const NEW_STEP_LIMITS = {
state: { min: 1 },
city: { min: 1 },
role: { min: 1, type: 'select' },
imageUrl: { min: 1, type: 'image' },
},
stepTwo: {
skills: { min: 5, max: 20 },
Expand Down
3 changes: 2 additions & 1 deletion app/constants/new-signup.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ export const CHECK_BOX_DATA = [
},
];

export const GET_STARTED_MAIN_HEADING = 'Thank you for connecting your GitHub!';
export const GET_STARTED_MAIN_HEADING =
'Thank you for connecting your socials!';
export const GET_STARTED_SUB_HEADING =
'Please complete the signup in order to:';
export const THANK_YOU_MAIN_HEADING = 'Congratulations!';
Expand Down
10 changes: 5 additions & 5 deletions app/constants/urls.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,14 @@ const APP_URLS = {
development: {
HOME: `${SCHEME}dev.${DOMAIN}`,
WELCOME: `${SCHEME}staging-welcome.${DOMAIN}`,
GOTO: '/goto',
EVENTS: '/events',
GOTO: `${SCHEME}dev.${DOMAIN}/goto`,
EVENTS: `${SCHEME}dev.${DOMAIN}/events`,
MEMBERS: `${SCHEME}staging-members.${DOMAIN}`,
STATUS: `${SCHEME}staging-status.${DOMAIN}`,
PROFILE: '/profile',
PROFILE: `${SCHEME}dev.${DOMAIN}/profile`,
TASKS: `${SCHEME}staging-status.${DOMAIN}/tasks`,
IDENTITY: '/identity',
MY_STATUS: '/status',
IDENTITY: `${SCHEME}dev.${DOMAIN}/identity`,
MY_STATUS: `${SCHEME}dev.${DOMAIN}/status`,
DASHBOARD: `${SCHEME}staging-dashboard.${DOMAIN}`,
API_BACKEND: `${SCHEME}staging-api.${DOMAIN}`,
SIGN_UP: `${SCHEME}dev.${DOMAIN}/new-signup`,
Expand Down
14 changes: 2 additions & 12 deletions app/controllers/goto.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export default class GotoController extends Controller {

WELCOME_URL = APPS.WELCOME;
SIGN_UP_URL = AUTH.SIGN_UP;
HOME_URL = 'index';
HOME_URL = APPS.HOME;

constructor() {
super(...arguments);
Expand All @@ -31,18 +31,8 @@ export default class GotoController extends Controller {
redirectionHandler(isDev, user) {
if (user.incompleteUserDetails) {
this.redirectUserToPage(this.SIGN_UP_URL);
} else if (isDev) {
if (user.roles?.developer && !user.roles?.in_discord) {
this.redirectUserToPage(this.WELCOME_URL);
} else {
this.router.transitionTo(this.HOME_URL);
}
} else {
if (!user.roles?.in_discord) {
this.redirectUserToPage(this.WELCOME_URL);
} else {
this.router.transitionTo(this.HOME_URL);
}
this.redirectUserToPage(this.HOME_URL);
}
}

Expand Down
2 changes: 2 additions & 0 deletions app/controllers/join.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ export default class JoinController extends Controller {
@tracked isLoading = false;
@tracked oldOnboarding = null;
@tracked step = null;
@tracked edit = null;
@tracked dev = null;

ANKUSH_TWITTER = ANKUSH_TWITTER;

Expand Down
4 changes: 4 additions & 0 deletions app/styles/new-stepper.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,10 @@
color: var(--color-black);
}

.role-selection-message {
font-size: 0.875rem;
}

.role-buttons {
display: flex;
gap: 0.5rem;
Expand Down
Loading