Minor bugfixes

This commit is contained in:
Geomitron
2024-01-16 09:26:03 -06:00
parent f9c599726f
commit 4f883bf4fa
5 changed files with 48 additions and 38 deletions

View File

@@ -1,6 +1,6 @@
import { HttpClient } from '@angular/common/http'
import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core'
import { FormControl } from '@angular/forms'
import { FormControl, Validators } from '@angular/forms'
import { sortBy } from 'lodash'
import { environment } from 'src-angular/environments/environment'
@@ -33,7 +33,7 @@ export class ChartSidebarMenutComponent implements OnInit {
this.selectedVersion.valueChanges.subscribe(v => this.selectedVersionChanges.emit(v))
this.reportOption = new FormControl<string>(this.reportOptions[0], { nonNullable: true })
this.reportExtraInfo = new FormControl<string>('', { nonNullable: true })
this.reportExtraInfo = new FormControl<string>('', { nonNullable: true, validators: [Validators.required] })
}
get displayVersions() {
@@ -78,13 +78,17 @@ export class ChartSidebarMenutComponent implements OnInit {
}
report() {
this.http.post(`${environment.apiUrl}/report`, {
chartId: this.selectedVersion.value.chartId,
reason: this.reportOption.value,
extraInfo: this.reportExtraInfo.value,
}).subscribe((response: { message: string }) => {
this.reportMessage = response.message
this.reportSent = true
})
if (this.reportExtraInfo.valid) {
this.http.post(`${environment.apiUrl}/report`, {
chartId: this.selectedVersion.value.chartId,
reason: this.reportOption.value,
extraInfo: this.reportExtraInfo.value,
}).subscribe((response: { message: string }) => {
this.reportMessage = response.message
this.reportSent = true
})
} else {
this.reportExtraInfo.markAsTouched()
}
}
}