Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sync: Dev to main #877

Merged
merged 4 commits into from
Feb 26, 2024
Merged
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
58 changes: 32 additions & 26 deletions app/components/join-section.hbs
Original file line number Diff line number Diff line change
@@ -1,32 +1,38 @@
{{#if this.isDevMode}}
<section data-test-join class='join'>
<h3 data-test-join-title class='join__title'>How to Join</h3>
<h2 data-test-join-title-highlighted class='join__title-highlighted'>Real Dev
Squad</h2>
<p data-test-para='1' class='join__para'>Our squad focuses on quality and we
want to work with people who are willing to be serious about their growth in
the squad.
</p>
<p data-test-para='2' class='join__para'>It's okay if you don't know much yet,
but it won't be okay to not put in any efforts for yourself. We want to
value everyone's time and efforts.
</p>
<LinkTo data-test-join-link @route='join' class='join__link'>Join the Squad</LinkTo>
</section>
<section data-test-join class='join'>
<h3 data-test-join-title class='join__title'>How to Join</h3>
<h2 data-test-join-title-highlighted class='join__title-highlighted'>Real
Dev Squad</h2>
<p data-test-para='1' class='join__para'>Our squad focuses on quality and we
want to work with people who are willing to be serious about their growth
in the squad.
</p>
<p data-test-para='2' class='join__para'>It's okay if you don't know much
yet, but it won't be okay to not put in any efforts for yourself. We want
to value everyone's time and efforts.
</p>
<LinkTo data-test-join-link @route='join' class='join__link'>Join the Squad</LinkTo>
</section>
{{else}}
<section data-test-join class='join'>
<h3 data-test-join-title class='join__title join__title--new'>How can you join?</h3>
<section data-test-join class='join'>
<h3 data-test-join-title class='join__title join__title--new'>How can you
join?</h3>

<p data-test-para='first' class='join__para join__para--new'>Our squad focuses on quality and we
want to work with people who are willing to be serious about their growth in
the squad.It's okay if you don't know much yet,
but it won't be okay to not put in any efforts for yourself. We want to
value everyone's time and efforts.
</p>
<p data-test-para='first' class='join__para join__para--new'>Our squad
focuses on quality and we want to work with people who are willing to be
serious about their growth in the squad.It's okay if you don't know much
yet, but it won't be okay to not put in any efforts for yourself. We want
to value everyone's time and efforts.
</p>

<LinkTo data-test-join-link @route='join' class='join__link join__link--new' @disabled={{true}}>Join the Squad</LinkTo>
<LinkTo
data-test-join-link
{{! @todo add join link route when join flow gets opened }}
@route='index'
class='join__link join__link--new'
@disabled={{true}}
>Join the Squad</LinkTo>
<p data-test-join-later-text class='join__later-text'>
We're currently not accepting new applications. Please check back in
2024.</p>
</section>
We're currently not accepting new applications. Please check back in 2024.</p>
</section>
{{/if}}
78 changes: 44 additions & 34 deletions app/components/stepper.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,40 +65,50 @@ export default class StepperComponent extends Component {
}

@action async joinHandler() {
const firstName = localStorage.getItem('first_name');
const lastName = localStorage.getItem('last_name');
const data = JSON.stringify({
firstName,
lastName,
...this.stepOneData,
...this.stepTwoData,
...this.stepThreeData,
});
try {
const response = await fetch(this.JOIN_URL, {
method: 'PUT',
headers: { 'Content-Type': 'application/json' },
credentials: 'include',
body: data,
});
/* @todo-1 remove this toast and return statement when join flow gets opened*/
return this.toast.info(
"Currently we're not taking applications please keep an eye on our website for openings",
'Hey there👋',
TOAST_OPTIONS,
);
/* @todo-1 ends here*/

if (response.status === 201) {
this.toast.success(
'Successfully submitted the form',
'Success!',
TOAST_OPTIONS,
);
this.incrementStep();
} else if (response.status === 409) {
this.toast.error(
'You have already filled the form',
'User Exist!',
TOAST_OPTIONS,
);
}
} catch (err) {
this.toast.error('Some error occured', 'Error ocurred!', TOAST_OPTIONS);
console.log('Error: ', err);
}
/* @todo-2 uncomment this part when join flow gets opened */
// const firstName = localStorage.getItem('first_name');
// const lastName = localStorage.getItem('last_name');
// const data = JSON.stringify({
// firstName,
// lastName,
// ...this.stepOneData,
// ...this.stepTwoData,
// ...this.stepThreeData,
// });
// try {
// const response = await fetch(this.JOIN_URL, {
// method: 'PUT',
// headers: { 'Content-Type': 'application/json' },
// credentials: 'include',
// body: data,
// });

// if (response.status === 201) {
// this.toast.success(
// 'Successfully submitted the form',
// 'Success!',
// TOAST_OPTIONS,
// );
// this.incrementStep();
// } else if (response.status === 409) {
// this.toast.error(
// 'You have already filled the form',
// 'User Exist!',
// TOAST_OPTIONS,
// );
// }
// } catch (err) {
// this.toast.error('Some error occured', 'Error ocurred!', TOAST_OPTIONS);
// console.log('Error: ', err);
// }
/*@todo-2 ends here */
}
}
14 changes: 7 additions & 7 deletions app/controllers/live.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export default class LiveController extends Controller {
];
@tracked activeTab = 'Screenshare';
@tracked isLoading = false;
@tracked name = '';
@tracked name = this.login?.userData?.first_name ?? '';
@tracked role = '';
@tracked roomCode = '';
@tracked isCopied = false;
Expand Down Expand Up @@ -107,11 +107,11 @@ export default class LiveController extends Controller {

if (!canJoin) return;

const activeEventsdata = await this.liveService.getActiveEvents();
const activeEvent = this.isActiveEventFound && activeEventsdata?.[0];
const activeEventsData = await this.liveService.getActiveEvents();
this.isActiveEventFound = Boolean(activeEventsData?.[0]?.enabled);

if (this.isActiveEventFound) {
const roomId = activeEvent?.room_id;
const roomId = activeEventsData?.[0]?.room_id;
this.liveService.joinSession(roomId, this.name, this.role, this.roomCode);
} else {
if (this.role !== ROLES.host)
Expand Down Expand Up @@ -266,11 +266,11 @@ export default class LiveController extends Controller {
@action async selectRoleHandler(selectedRole) {
this.role = selectedRole;

this.buttonText = 'Loading...';
const activeEventData = await this.liveService.getActiveEvents();
const isActiveEvent = Boolean(activeEventData?.[0]?.enabled);
this.isActiveEventFound = isActiveEvent;
this.isActiveEventFound = Boolean(activeEventData?.[0]?.enabled);

if (!activeEventData && selectedRole === ROLES.host) {
if (!this.isActiveEventFound && selectedRole === ROLES.host) {
this.buttonText = 'Create Event';
} else if (activeEventData) {
this.buttonText = 'Join';
Expand Down
42 changes: 42 additions & 0 deletions tests/integration/components/live-join-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -169,4 +169,46 @@ module('Integration | Component | live-join', function (hooks) {

assert.dom('[data-test-live-join-title]').containsText('Create a Event');
});

test('it should prefill first name in input box', async function (assert) {
const loginService = this.owner.lookup('service:login');
loginService.userData = { first_name: 'Jayasurya' };

const controller = this.owner.lookup('controller:live');
assert.deepEqual(controller.name, 'Jayasurya');

const objToCheckFunctions = {
isInputHandler: assert.ok(true, 'inputHandler is working fine!'),
isClickHandlerWorks: assert.ok(true, 'clickHandler is working fine!'),
isBackHandlerWorks: assert.ok(true, 'backHandler is working fine!'),
};
this.setProperties({
role: 'host',
name: controller.name,
roomCode: '',
inputHandler: () => {
objToCheckFunctions.isInputHandler;
},
clickHandler: () => {
objToCheckFunctions.isClickHandlerWorks;
},
backHandler: () => {
objToCheckFunctions.isBackHandlerWorks;
},
buttonText: 'Create',
});

await render(hbs`
<LiveJoin
@role={{this.role}}
@name={{this.name}}
@roomCode={{this.roomCode}}
@inputHandler={{this.inputHandler}}
@clickHandler={{this.clickHandler}}
@backHandler={{this.backHandler}}
@buttonText={{this.buttonText}}
/>`);

assert.dom('[data-test-input-field]').hasProperty('value', 'Jayasurya');
});
});
Loading