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

delete flow #175

Open
wants to merge 2 commits into
base: release-2.4.1
Choose a base branch
from
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
22 changes: 17 additions & 5 deletions src/app/pages/help/help.page.html
Original file line number Diff line number Diff line change
@@ -1,11 +1,23 @@
<app-page-header [config]="headerConfig"></app-page-header>
<ion-content class="ion-padding header">
<ion-label><strong>{{"REPORT_AN_ISSUE" | translate}}</strong></ion-label>
<div class="field">
<ion-label class="field-spacing">{{"TELL_US_THE_PROBLEM" | translate}}</ion-label>
<app-dynamic-form *ngIf="formData" [jsonFormData]="formData" #form1 class="input"></app-dynamic-form>
<ion-card>
<ion-card-content>
<ion-list>
<ion-select #link class="select" [(ngModel)]="selectedOption" interface="popover" (ionChange)="clickOptions($event)" [value]="selectedOption">
<ion-select-option [value]="option" *ngFor="let option of helpForms">
{{ option?.name }}
</ion-select-option>
</ion-select>
</ion-list>
<div *ngIf="selectedOption">
<div *ngIf="message" [innerHTML]="message"></div>
<app-dynamic-form [jsonFormData]="selectedOption.form" #form1 class="input"></app-dynamic-form>
</div>
</ion-card-content>
</ion-card>
</div>
</ion-content>
<ion-footer class="ion-no-border">
<ion-button expand="full" [disabled]="form1 && !form1.myForm.valid" (click)="onSubmit()">{{"SUBMIT" | translate}}</ion-button>
<ion-footer class="ion-no-border" *ngFor="let option of helpForms">
<ion-button *ngIf="selectedOption == option" expand="full" [disabled]="form1 && !form1.myForm.valid" (click)="onSubmit(option)">{{option?.buttonText | translate}}</ion-button>
</ion-footer>
63 changes: 55 additions & 8 deletions src/app/pages/help/help.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -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();
Copy link
Collaborator

Choose a reason for hiding this comment

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

why do we need anew function here??

}
async submitHelpReport() {
await this.loaderService.startLoader();
Expand All @@ -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;
}
}
6 changes: 5 additions & 1 deletion src/assets/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
4 changes: 4 additions & 0 deletions src/global.scss
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}