diff --git a/src/app/pages/help/help.page.html b/src/app/pages/help/help.page.html index 037c2d167..c5f28637f 100644 --- a/src/app/pages/help/help.page.html +++ b/src/app/pages/help/help.page.html @@ -1,11 +1,23 @@ - {{"REPORT_AN_ISSUE" | translate}}
- {{"TELL_US_THE_PROBLEM" | translate}} - + + + + + + {{ option?.name }} + + + +
+
+ +
+
+
- - {{"SUBMIT" | translate}} + + {{option?.buttonText | translate}} \ No newline at end of file diff --git a/src/app/pages/help/help.page.ts b/src/app/pages/help/help.page.ts index df59e1573..47948f8a3 100644 --- a/src/app/pages/help/help.page.ts +++ b/src/app/pages/help/help.page.ts @@ -9,6 +9,9 @@ import { FormService } from 'src/app/core/services/form/form.service'; import { HELP } from 'src/app/core/constants/formConstant'; import * as _ from 'lodash'; import { App } from '@capacitor/app'; +import { TranslateService } from '@ngx-translate/core'; +import { AlertController } from '@ionic/angular'; +import { ProfileService } from 'src/app/core/services/profile/profile.service'; @Component({ selector: 'app-help', @@ -22,27 +25,36 @@ export class HelpPage implements OnInit { label: "HELP" }; public formData: JsonFormData; - metaData: { deviceName: string; androidVersion: string; version: string}; + metaData: { deviceName: string; androidVersion: string; version: string; type: string}; + selectedOption: any; + helpForms: any; + userDetails: any; + message: any; constructor(private router: Router, private loaderService: LoaderService, private toast: ToastService, private httpService: HttpService, private device: Device, - private form: FormService,) { } + private form: FormService, private translate: TranslateService,private alert: AlertController,private profileService: ProfileService,) { } - ngOnInit() { + async ngOnInit() { + this.helpForm(); + await this.profileService.profileDetails().then((userDetails) => { + this.userDetails = userDetails; + }); App.getInfo().then((data)=>{ this.metaData = { deviceName: this.device.model, androidVersion: this.device.version, - version: data.version + version: data.version, + type: '' } - this.helpForm(); }) } - onSubmit() { + onSubmit(option: any) { + this.metaData.type = option.value; this.form1.myForm.value.metaData = this.metaData; - this.submitHelpReport() - this.router.navigate([`/${CommonRoutes.TABS}/${CommonRoutes.HOME}`]) + this.form1.myForm.value.description = this.form1.myForm.value.description ? this.form1.myForm.value.description: option.value; + (option.buttonText == "DELETE_ACCOUNT") ? this.deteteAccount(): this.submitHelpReport(); } async submitHelpReport() { await this.loaderService.startLoader(); @@ -58,9 +70,44 @@ export class HelpPage implements OnInit { catch (error) { this.loaderService.stopLoader(); } + this.router.navigate([`/${CommonRoutes.TABS}/${CommonRoutes.HOME}`]) + } + async deteteAccount(){ + let texts: any; + this.translate.get(['DELETE_ALERT_MSG', 'YES', 'NO']).subscribe(text => { + texts = text; + }) + const alert = await this.alert.create({ + message: texts['DELETE_ALERT_MSG'], + buttons: [ + { + text: texts['YES'], + cssClass: "alert-button", + handler: () => { } + }, + { + text: texts['NO'], + cssClass: "alert-button-no", + role: 'no', + handler: () => { } + } + ] + }); + await alert.present(); + let data = await alert.onDidDismiss(); + if(data.role == 'no'){ + this.submitHelpReport(); + } } async helpForm(){ const result = await this.form.getForm(HELP); this.formData = _.get(result, 'result.data.fields'); + this.helpForms = _.get(result, 'result.data.fields.forms'); + this.selectedOption = this.helpForms[0]; + this.message = (this.userDetails?.isAMentor) ? this.selectedOption?.menterMessage : this.selectedOption?.menteeMessage; + } + clickOptions(event:any){ + this.selectedOption = event.detail.value; + this.message = (this.userDetails.isAMentor) ? this.selectedOption?.menterMessage : this.selectedOption?.menteeMessage; } } \ No newline at end of file diff --git a/src/assets/i18n/en.json b/src/assets/i18n/en.json index edd134993..a976bd0dd 100644 --- a/src/assets/i18n/en.json +++ b/src/assets/i18n/en.json @@ -179,5 +179,9 @@ "PASSWORD": "Password", "EDIT_SESSION_LABEL": "Edit session", "HAVING_TROUBLE_LOGIN": "Having trouble in logging in/signing up? Write to us.", - "ADD_MEETING_LINK": "Meeting link is not added, please add a link." + "ADD_MEETING_LINK": "Meeting link is not added, please add a link.", + "DELETE_ACCOUNT": "Delete account", + "DELETE_ALERT_MSG": "Deleting your account will remove all your data from the app forever. You will have to create a new account if you decide to come back. Do you want to continue?", + "YES": "Yes", + "NO": "No" } diff --git a/src/global.scss b/src/global.scss index c09d1727f..82a608e0f 100644 --- a/src/global.scss +++ b/src/global.scss @@ -294,4 +294,8 @@ ion-toast.custom-toast::part(button) { } ion-toast.custom-toast{ --background: var(--ion-color-primary); +} +.alert-button-no { + background: var(--white) !important; + color: var(--ion-color-primary) !important; } \ No newline at end of file