💄 Trip create: automatically set currency using config
This commit is contained in:
parent
c64e52e872
commit
920fc43719
@ -6,6 +6,8 @@ import { FloatLabelModule } from 'primeng/floatlabel';
|
|||||||
import { InputTextModule } from 'primeng/inputtext';
|
import { InputTextModule } from 'primeng/inputtext';
|
||||||
import { FocusTrapModule } from 'primeng/focustrap';
|
import { FocusTrapModule } from 'primeng/focustrap';
|
||||||
import { DatePickerModule } from 'primeng/datepicker';
|
import { DatePickerModule } from 'primeng/datepicker';
|
||||||
|
import { ApiService } from '../../services/api.service';
|
||||||
|
import { take } from 'rxjs';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-trip-create-modal',
|
selector: 'app-trip-create-modal',
|
||||||
@ -23,6 +25,7 @@ export class TripCreateModalComponent {
|
|||||||
private ref: DynamicDialogRef,
|
private ref: DynamicDialogRef,
|
||||||
private fb: FormBuilder,
|
private fb: FormBuilder,
|
||||||
private config: DynamicDialogConfig,
|
private config: DynamicDialogConfig,
|
||||||
|
private apiService: ApiService,
|
||||||
) {
|
) {
|
||||||
this.tripForm = this.fb.group({
|
this.tripForm = this.fb.group({
|
||||||
id: -1,
|
id: -1,
|
||||||
@ -38,6 +41,13 @@ export class TripCreateModalComponent {
|
|||||||
if (patchValue) {
|
if (patchValue) {
|
||||||
if (!patchValue.image_id) delete patchValue['image'];
|
if (!patchValue.image_id) delete patchValue['image'];
|
||||||
this.tripForm.patchValue(patchValue);
|
this.tripForm.patchValue(patchValue);
|
||||||
|
} else {
|
||||||
|
this.apiService
|
||||||
|
.getSettings()
|
||||||
|
.pipe(take(1))
|
||||||
|
.subscribe({
|
||||||
|
next: (settings) => this.tripForm.get('currency')?.setValue(settings.currency),
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user