-
Notifications
You must be signed in to change notification settings - Fork 153
Implementation of Discord invite link display and feedback mechanism on /intro page
#901
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
Open
Achintya-Chatterjee
wants to merge
12
commits into
develop
Choose a base branch
from
feat/discord-link
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
ffc66c8
added approve and reject buttons with a feedback box
rishirishhh 6b308a2
feat: Add functionality to generate and display Discord invite link w…
Achintya-Chatterjee 6a41b35
added the reject and review functionality
rishirishhh 396649b
Refactor: Include userId in API call for generating Discord invite link
Achintya-Chatterjee 3d78242
integrate api to approve / reject
yesyash 4c86a14
fix textarea styling
yesyash 56bf942
remove unused checks add show not authorized text for non super users
yesyash 2ce641d
Merge pull request #905 from Real-Dev-Squad/yash/approve-reject-action
prakashchoudhary07 ef7048e
Merge pull request #906 from Real-Dev-Squad/yash/feeback-input
prakashchoudhary07 2472191
feat: Generate and display Discord invite link upon application accep…
Achintya-Chatterjee 5d02bd3
Merge branch 'develop' into feat/discord-link
Achintya-Chatterjee 1ecdcda
Update intro page logic to handle user-specific access and feedback d…
Achintya-Chatterjee File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| export const APPLICATION_STATUS_TYPES = { | ||
| accepted: 'accepted', | ||
| rejected: 'rejected', | ||
| pending: 'pending', | ||
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,153 @@ | ||
| import Controller from '@ember/controller'; | ||
| import { action } from '@ember/object'; | ||
| import { inject as service } from '@ember/service'; | ||
| import { tracked } from '@glimmer/tracking'; | ||
| import { APPS } from '../constants/urls'; | ||
| import { validateApplicationDetails } from '../utils/validate-application-details'; | ||
| import { APPLICATION_STATUS_TYPES } from '../constants/application'; | ||
| import { TOAST_OPTIONS } from '../constants/toast-options'; | ||
|
|
||
| export default class IntroController extends Controller { | ||
| @service login; | ||
| @service toast; | ||
| @service onboarding; | ||
|
|
||
| @tracked remarks = ''; | ||
| @tracked inviteLink = ''; | ||
| @tracked isRejected = false; | ||
| @tracked isAccepted = false; | ||
| @tracked isPending = false; | ||
| @tracked feedback = ''; | ||
|
|
||
| statusTypes = APPLICATION_STATUS_TYPES; | ||
|
|
||
| constructor() { | ||
| super(...arguments); | ||
| } | ||
|
|
||
| get applicationDetails() { | ||
| return this.model?.data?.[0]; | ||
| } | ||
|
|
||
| initializeStatusFlags() { | ||
| if (this.applicationDetails) { | ||
| const details = this.applicationDetails; | ||
| this.isAccepted = details.status === this.statusTypes.accepted; | ||
| this.isRejected = details.status === this.statusTypes.rejected; | ||
| this.isPending = details.status === this.statusTypes.pending; | ||
|
|
||
| this.feedback = details.feedback || ''; | ||
| if (this.isAccepted) { | ||
| this.inviteLink = details.inviteLink || ''; | ||
| } | ||
| } else { | ||
| this.isAccepted = false; | ||
| this.isRejected = false; | ||
| this.isPending = false; | ||
| } | ||
| } | ||
|
|
||
| @action | ||
| updateRemarks(e) { | ||
| this.remarks = e.target.value; | ||
| } | ||
|
|
||
| @action | ||
| async approveRejectAction(status) { | ||
| const initialApplicationDetails = this.model; | ||
|
|
||
| const { isValid, data } = validateApplicationDetails( | ||
| initialApplicationDetails, | ||
| ); | ||
|
|
||
| if (!isValid || !data) { | ||
| console.error('Invalid application details:', initialApplicationDetails); | ||
| this.toast.error('Invalid application details.', 'Error!', TOAST_OPTIONS); | ||
| return; | ||
| } | ||
|
|
||
| const applicationId = data.id; | ||
| const body = { status, feedback: this.remarks }; | ||
| try { | ||
| const response = await fetch( | ||
| `${APPS.API_BACKEND}/applications/${applicationId}`, | ||
| { | ||
| method: 'PATCH', | ||
| credentials: 'include', | ||
| headers: { | ||
| 'Content-Type': 'application/json', | ||
| }, | ||
| body: JSON.stringify(body), | ||
| }, | ||
| ); | ||
|
|
||
| if (!response.ok) { | ||
| console.error( | ||
| 'Failed to update application status. Response:', | ||
| response, | ||
| ); | ||
| this.toast.error( | ||
| 'Failed to update application status.', | ||
| 'Error!', | ||
| TOAST_OPTIONS, | ||
| ); | ||
| return; | ||
| } | ||
|
|
||
| if (status === this.statusTypes.accepted) { | ||
| this.inviteLink = await this.onboarding.discordInvite(); | ||
| this.isAccepted = true; | ||
| this.isRejected = false; | ||
| this.isPending = false; | ||
| } else if (status === this.statusTypes.rejected) { | ||
| this.isRejected = true; | ||
| this.isAccepted = false; | ||
| this.isPending = false; | ||
| } else if (status === this.statusTypes.pending) { | ||
| this.isPending = true; | ||
| this.isRejected = false; | ||
| this.isAccepted = false; | ||
| } | ||
|
|
||
| console.log('Updated status flags:', { | ||
| isAccepted: this.isAccepted, | ||
| isRejected: this.isRejected, | ||
| isPending: this.isPending, | ||
| }); | ||
|
|
||
| this.toast.success( | ||
| `Application ${status.toLowerCase()} successfully.`, | ||
| 'Success!', | ||
| TOAST_OPTIONS, | ||
| ); | ||
| } catch (error) { | ||
| console.error('Error updating application status:', error); | ||
| this.toast.error( | ||
| 'Something went wrong, please try again later.', | ||
| 'Error!', | ||
| TOAST_OPTIONS, | ||
| ); | ||
| } | ||
| } | ||
|
|
||
| @action | ||
| copyToClipboard(link) { | ||
| navigator.clipboard | ||
| .writeText(link) | ||
| .then(() => { | ||
| this.toast.success( | ||
| 'Invite link copied to clipboard!', | ||
| 'Success!', | ||
| TOAST_OPTIONS, | ||
| ); | ||
| }) | ||
| .catch((err) => { | ||
| console.error('Failed to copy the text: ', err); | ||
| this.toast.error( | ||
| 'Failed to copy the link. Please try again.', | ||
| 'Error!', | ||
| TOAST_OPTIONS, | ||
| ); | ||
| }); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| .superuser-feedback { | ||
| width: 34rem; | ||
| padding: 1rem 0; | ||
| display: flex; | ||
| flex-direction: column; | ||
| } | ||
|
|
||
| .superuser-feedback__label { | ||
| display: block; | ||
| font-size: 1.25rem; | ||
| font-weight: 700; | ||
| padding-bottom: 0.5rem; | ||
| } | ||
|
|
||
| .superuser-feedback__textarea { | ||
| padding: 0.5rem; | ||
| border-radius: 0.5rem; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,18 +1,65 @@ | ||
| {{page-title "Intro"}} | ||
|
|
||
| <section class="intro__container"> | ||
| {{#if this.login.isLoading}} | ||
| <div data-test-loading class='intro__loading'> | ||
| <Fa-Icon @size='2x' @icon='circle-notch' @spin={{true}} /> | ||
| <div data-test-loading class="intro__loading"> | ||
| <Fa-Icon @size="2x" @icon="circle-notch" @spin={{true}} /> | ||
| </div> | ||
| {{else}} | ||
| {{#if this.login.userData.roles.super_user}} | ||
| <ApplicantIntro | ||
| @data={{this.model}} | ||
| {{else if this.applicationDetails}} | ||
| {{#if this.isAccepted}} | ||
| <div> | ||
| <p>Congratulations. You've been approved to join our Discord server using this link:</p> | ||
| <a href="{{this.inviteLink}}" target="_blank" rel="noopener noreferrer">{{this.inviteLink}}</a> | ||
| <button type="button" class="copy-button" {{on "click" (fn this.copyToClipboard this.inviteLink)}}>Copy Link</button> | ||
| <p>{{this.feedback}}</p> | ||
| </div> | ||
| {{else if this.isRejected}} | ||
| <div> | ||
| <p>Unfortunately, at this time, your application is not approved.</p> | ||
| <p>{{this.feedback}}</p> | ||
| </div> | ||
| {{else if this.isPending}} | ||
| <div>We are reviewing your application. Please check again here after some time for an update.</div> | ||
| {{else if this.login.userData.roles.super_user}} | ||
| <ApplicantIntro | ||
| @data={{get this.model.data 0}} | ||
| @isLoading={{this.login.isLoading}} | ||
| @isSuperUser={{this.login.userData.roles.super_user}} /> | ||
| @isSuperUser={{this.login.userData.roles.super_user}} | ||
| /> | ||
|
|
||
| <div class="superuser-feedback"> | ||
| <label for="superuserFeedback" class="superuser-feedback__label"> | ||
| Your remarks: | ||
| </label> | ||
| <textarea | ||
| id="superuserFeedback" | ||
| class="superuser-feedback__textarea" | ||
| placeholder="Enter your remarks" | ||
| {{on "change" this.updateRemarks}} | ||
| ></textarea> | ||
| </div> | ||
|
|
||
| <div class="action-buttons"> | ||
| <button | ||
| type="button" | ||
| class="approve-button" | ||
| {{on "click" (fn this.approveRejectAction this.statusTypes.accepted)}} | ||
| >Accept</button> | ||
|
|
||
| <button | ||
| type="button" | ||
| class="reject-button" | ||
| {{on "click" (fn this.approveRejectAction this.statusTypes.rejected)}} | ||
| >Reject</button> | ||
|
|
||
| <button | ||
| type="button" | ||
| class="pending-button" | ||
| {{on "click" (fn this.approveRejectAction this.statusTypes.pending)}} | ||
| >Pending</button> | ||
| </div> | ||
| {{else}} | ||
| <Unauthorized /> | ||
| <div>You're not authorized to view this page.</div> | ||
| {{/if}} | ||
| {{else}} | ||
| <div>No application details found.</div> | ||
| {{/if}} | ||
| </section> | ||
| </section> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| /** | ||
| * Generate application details | ||
| * --- | ||
| * @param {Object} applicationDetails | ||
| * @param {string} applicationDetails.id | ||
| * @param {Object} applicationDetails.intro | ||
| * @param {string} applicationDetails.intro.funFact | ||
| * @param {string} applicationDetails.intro.forFun | ||
| * @param {number} applicationDetails.intro.numberOfHours | ||
| * @param {string} applicationDetails.intro.whyRds | ||
| * @param {string} applicationDetails.intro.introduction | ||
| * @param {Object} applicationDetails.biodata | ||
| * @param {string} applicationDetails.biodata.firstName | ||
| * @param {string} applicationDetails.biodata.lastName | ||
| * @param {Object} applicationDetails.location | ||
| * @param {string} applicationDetails.location.country | ||
| * @param {string} applicationDetails.location.city | ||
| * @param {string} applicationDetails.location.state | ||
| * @param {string} applicationDetails.foundFrom | ||
| * @param {string} applicationDetails.userId | ||
| * @param {Object} applicationDetails.professional | ||
| * @param {string} applicationDetails.professional.skills | ||
| * @param {string} applicationDetails.professional.institution | ||
| * @param {string} applicationDetails.status - "accepted" | "rejected" | "pending" | ||
| * | ||
| * @returns {Object} validateApplicationDetails | ||
| * @returns {boolean} validateApplicationDetails.isValid | ||
| * @returns {applicationDetails} validateApplicationDetails.data | ||
| */ | ||
| export const validateApplicationDetails = (applicationDetails) => { | ||
| if (!applicationDetails || !applicationDetails.userId) { | ||
| return { isValid: false, data: null }; | ||
| } | ||
|
|
||
| return { isValid: true, data: applicationDetails }; | ||
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.