Skip to content

Commit

Permalink
reolve merge conflict
Browse files Browse the repository at this point in the history
  • Loading branch information
vinit717 committed Aug 24, 2024
2 parents d4556bf + 970cf4a commit 42dbd1a
Show file tree
Hide file tree
Showing 26 changed files with 661 additions and 149 deletions.
2 changes: 1 addition & 1 deletion app/components/new-signup/input.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
{{#if @dev}}
Next
{{else}}
{{if (eq @currentStep 'username') 'Submit' 'Next'}}
{{if (eq @currentStep 'lastName') 'Submit' 'Next'}}
{{/if}}
</Button>
</div>
Expand Down
2 changes: 1 addition & 1 deletion app/components/self-clear-cache.hbs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{{#if @dev}}
{{#if @cache}}
<section class='cache'>
<div data-test-last-time class='cache__last-request'>
Last Request: {{@time}}
Expand Down
4 changes: 1 addition & 3 deletions app/components/task/holder.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@
@closeModel={{this.closeExtensionModel}}
/>
{{/if}}

{{#if (not-eq this.status this.TASK_KEYS.VERIFIED)}}
{{#if (or (not-eq this.status this.TASK_KEYS.VERIFIED) (eq @dev true))}}
<div class='task-update-container'>
<label id='task-update-label' for='task-update'><b>Status:</b></label>
<select
Expand All @@ -43,7 +42,6 @@
</select>
</div>
{{/if}}

<button
class='task-card__extensionForm-button'
data-test-task-extensionForm-button
Expand Down
4 changes: 2 additions & 2 deletions app/components/task/holder.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export default class TasksHolderComponent extends Component {
get taskStatusList() {
const statusToDisplay = this.availabletaskStatusList.filter(
(taskStatus) => {
if (this.args.dev === true) {
if (this.args.dev) {
return taskStatus.key !== 'ALL' && taskStatus.key !== 'COMPLETED';
} else {
return taskStatus.key !== 'ALL' && taskStatus.key !== 'DONE';
Expand All @@ -46,7 +46,7 @@ export default class TasksHolderComponent extends Component {

get taskStyleClass() {
const statusNotOverDueList = [
this.args.dev === true ? TASK_KEYS.DONE : TASK_KEYS.COMPLETED,
this.args.dev ? TASK_KEYS.DONE : TASK_KEYS.COMPLETED,
TASK_KEYS.VERIFIED,
TASK_KEYS.AVAILABLE,
];
Expand Down
2 changes: 0 additions & 2 deletions app/components/user-status-modal.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,13 @@
<div class="overlay">
<div class="modal" data-test-modal>
<div class="modal__inputs">
{{#if (eq @newStatus this.USER_STATES.OOO)}}
<label class="modal__inputs--description" data-test-label-from>From</label>
<Input name='fromDate' type='date' min={{this.disableDatesPrior}} value={{this.fromDate}} {{on "change"
this.updateValue}} data-test-date-picker-from />
<label class="modal__inputs--description" data-test-label-until>Until</label>
<Input name='untilDate' type='date' min={{if this.fromDate this.fromDate this.disableDatesPrior}}
value={{this.untilDate}} {{on "change" this.updateValue}} data-test-date-picker-until />
<label class="modal__inputs--description" data-test-label-reason>Reason</label>
{{/if}}

<textarea name='reason' class="modal__text-area" value={{this.reason}} {{on "input" this.handleInput}}
data-test-textarea-reason></textarea>
Expand Down
34 changes: 19 additions & 15 deletions app/components/user-status-modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import { getUTCMidnightTimestampFromDate } from '../utils/date-conversion';

export default class FormStatusModal extends Component {
@service toast;
@service featureFlag;
@tracked currentStatus;
@tracked fromDate = '';
@tracked untilDate = '';
Expand All @@ -44,6 +45,7 @@ export default class FormStatusModal extends Component {
async getCurrentStatusObj() {
let from;
let until;
const isDevMode = this.featureFlag.isDevMode;
if (this.args.newStatus === USER_STATES.OOO) {
if (!this.fromDate) {
this.toast.error(
Expand Down Expand Up @@ -102,7 +104,15 @@ export default class FormStatusModal extends Component {
message: this.reason,
state: this.args.newStatus,
};
await this.args.updateStatus({ currentStatus: newStateObj });
if (isDevMode) {
await this.args.statusUpdateDevApi(
this.fromDate,
this.untilDate,
this.reason
);
} else {
await this.args.updateStatus({ currentStatus: newStateObj });
}
this.resetInputFields();
this.disableSubmitButton = true;
}
Expand All @@ -117,20 +127,14 @@ export default class FormStatusModal extends Component {
@action
checkSubmitBtnState() {
this.disableSubmitButton = true;
if (this.args.newStatus === USER_STATES.OOO) {
if (this.checkIfFromToDatesAreClose()) {
this.disableSubmitButton = false;
} else if (
this.fromDate !== '' &&
this.untilDate !== '' &&
this.reason !== ''
) {
this.disableSubmitButton = false;
}
} else if (this.args.newStatus === USER_STATES.IDLE) {
if (this.reason !== '') {
this.disableSubmitButton = false;
}
if (this.checkIfFromToDatesAreClose()) {
this.disableSubmitButton = false;
} else if (
this.fromDate !== '' &&
this.untilDate !== '' &&
this.reason !== ''
) {
this.disableSubmitButton = false;
}
}

Expand Down
52 changes: 32 additions & 20 deletions app/components/user-status.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -24,26 +24,38 @@
</div>

<div class="buttons">
{{#each this.currentUserStatus as |currentStatus|}}
{{#if (eq @status currentStatus.status)}}
{{#if (eq currentStatus.status "OOO")}}
<button
data-test-cancel-status-OOO
class='buttons__cancel--ooo'
type='button'
disabled={{@isStatusUpdating}}
{{on 'click' (fn this.cancelOOOStatus currentStatus.status)}}
>
<span>Cancel OOO</span>
</button>
{{else}}
{{#each currentStatus.otherAvailableStatus as |otherPossibleStatus|}}
{{#each this.currentUserStatus as |currentStatus|}}
{{#if (eq @status currentStatus.status)}}
{{#if @dev}}
<button
data-test-request-status-OOO
class='buttons__request--ooo'
type='button'
{{on "click" (fn this.changeStatus)}}
>
<span>Request OOO Status</span>
</button>
{{else}}
{{#if (eq currentStatus.status "OOO")}}
<button
data-test-cancel-status-OOO
class='buttons__cancel--ooo'
type='button'
disabled={{@isStatusUpdating}}
{{on 'click' (fn this.cancelOOOStatus currentStatus.status)}}
>
<span>Cancel OOO</span>
</button>
{{else}}
{{#each currentStatus.otherAvailableStatus as |otherPossibleStatus|}}
<button data-test-update-status-OOO class={{otherPossibleStatus.class}} type="button" disabled={{@isStatusUpdating}} {{on "click" (fn this.changeStatus otherPossibleStatus.status )}}>
<span>{{otherPossibleStatus.message}}</span>
</button>
{{/each}}
{{/if}}
<span>{{otherPossibleStatus.message}}</span>
</button>
{{/each}}
{{/if}}
{{/each}}
</div>
{{/if}}
{{/if}}
{{/each}}
</div>

{{/if}}
1 change: 1 addition & 0 deletions app/constants/new-signup.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export const LABEL_TEXT = {
export const ERROR_MESSAGES = {
userName: 'username already taken!',
others: 'something went wrong',
usernameGeneration: 'Username cannot be generated',
};

export const CHECK_BOX_DATA = [
Expand Down
2 changes: 2 additions & 0 deletions app/constants/tasks.js
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,8 @@ export const TASK_MESSAGES = {
MARK_DONE: 'This task will be marked as Done',
UPDATE_TASK: 'Updating task',
FIND_TASK: 'Finding new task for you!',
CHANGE_TO_100_PROGRESS: 'Proceeding further will make task progress 100%.',
CHANGE_TO_0_PROGRESS: 'Proceeding further will make task progress 0%.',
};

export const TASK_PERCENTAGE = {
Expand Down
28 changes: 20 additions & 8 deletions app/controllers/discord.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,23 @@ import { tracked } from '@glimmer/tracking';
import { action } from '@ember/object';

export default class DiscordController extends Controller {
@service router;
@service toast;
@tracked discordId =
this.model.externalAccountData.attributes.discordId || '';
@tracked linkStatus = 'not-linked';
@tracked isLinking = false;
@tracked consent = false;

@tracked token = '';

queryParams = {
token: { refreshModel: true },
};

async model() {
this.token = this.paramsFor('discord').token;
}
@action setConsent() {
this.consent = !this.consent;
}
Expand All @@ -22,14 +32,16 @@ export default class DiscordController extends Controller {
this.isLinking = true;

if (this.consent) {
const response = await fetch(`${ENV.BASE_API_URL}/users/self`, {
method: 'PATCH',
body: JSON.stringify({ discordId: this.discordId }),
headers: {
'Content-Type': 'application/json',
},
credentials: 'include',
});
const response = await fetch(
`${ENV.BASE_API_URL}/external-accounts/link/${this.token}`,
{
method: 'PATCH',
headers: {
'Content-Type': 'application/json',
},
credentials: 'include',
}
);

if (response.status === 204) {
this.linkStatus = 'linked';
Expand Down
37 changes: 37 additions & 0 deletions app/controllers/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
MAX_CACHE_PURGE_COUNT,
LAST_UPDATED_REQUEST,
} from '../constants/self-clear-cache';
import { getUTCMidnightTimestampFromDate } from '../utils/date-conversion';

const BASE_URL = ENV.BASE_API_URL;

Expand All @@ -30,6 +31,9 @@ export default class IndexController extends Controller {
get isDevMode() {
return this.featureFlag.isDevMode;
}
get isCacheEnabled() {
return this.featureFlag.isCacheEnabled;
}

@action async updateStatus(newStatus) {
this.isStatusUpdating = true;
Expand Down Expand Up @@ -76,6 +80,39 @@ export default class IndexController extends Controller {
}
}

@action
async statusUpdateDevApi(from, until, message) {
const statusRequestBody = {
type: 'OOO',
from: getUTCMidnightTimestampFromDate(from),
until: getUTCMidnightTimestampFromDate(until),
message,
state: 'PENDING',
};
try {
const response = await fetch(`${BASE_URL}/requests?dev=true`, {
method: 'POST',
body: JSON.stringify(statusRequestBody),
headers: {
'Content-Type': 'application/json',
},
credentials: 'include',
});
if (response.ok) {
const data = await response.json();
this.toast.success(data.message, '', toastNotificationTimeoutOptions);
}
} catch (error) {
this.toast.error(
'OOO status request failed. Something went wrong.',
'',
toastNotificationTimeoutOptions
);
} finally {
this.isStatusUpdating = false;
}
}

@action changeStatus(status) {
this.newStatus = status;
this.toggleUserStateModal();
Expand Down
Loading

0 comments on commit 42dbd1a

Please sign in to comment.