1- import { Component , inject , linkedSignal , viewChild } from '@angular/core' ;
1+ import { Component , inject , viewChild } from '@angular/core' ;
22import { ActionCardComponent } from '../../shared/ui/action-card/action-card.component' ;
33import { FlightConnectionFormComponent } from '../shared/flight-connection-form/flight-connection-form.component' ;
44import { FlightOperatorFormComponent } from '../shared/flight-operator-form/flight-operator-form.component' ;
55import { FlightPriceFormComponent } from '../shared/flight-price-form/flight-price-form.component' ;
66import { FlightTimesFormComponent } from '../shared/flight-times-form/flight-times-form.component' ;
77import { FlightEditStore } from './flight-edit.store' ;
8- import { JsonPipe } from "@angular/common" ;
8+ import { flightSchema } from '../flight.entities' ;
9+ import { form } from '@angular/forms/signals' ;
910
1011@Component ( {
1112 selector : 'app-flight-edit' ,
12- imports : [ ActionCardComponent , FlightConnectionFormComponent , FlightOperatorFormComponent , FlightTimesFormComponent , FlightPriceFormComponent , JsonPipe ] ,
13+ imports : [ ActionCardComponent , FlightConnectionFormComponent , FlightOperatorFormComponent , FlightTimesFormComponent , FlightPriceFormComponent ] ,
1314 templateUrl : './flight-edit.component.html'
1415} )
1516export class FlightEditComponent {
1617 store = inject ( FlightEditStore ) ;
17- flightConnection = this . store . flightConnection ;
18- localFlightConnection = linkedSignal ( ( ) => this . store . flightEditVm . flight . connection ( ) ) ;
19- flightTimes = this . store . flightTimes ;
20- flightOperator = this . store . flightOperator ;
21- flightPrice = this . store . flightPrice ;
18+ flightForm = form ( this . store . localFlight , flightSchema )
2219
2320 _connectionCard = viewChild . required < ActionCardComponent > ( 'connection' ) ;
2421 _timesCard = viewChild . required < ActionCardComponent > ( 'times' ) ;
@@ -36,7 +33,7 @@ export class FlightEditComponent {
3633
3734 onUpdateTimes ( ) {
3835 try {
39- this . store . updateFlightConnection ( ) ;
36+ this . store . updateFlightTimes ( ) ;
4037 this . _timesCard ( ) . showSuccess ( ) ;
4138 } catch {
4239 this . _timesCard ( ) . showError ( ) ;
@@ -45,7 +42,7 @@ export class FlightEditComponent {
4542
4643 onUpdateOperator ( ) {
4744 try {
48- this . store . updateFlightConnection ( ) ;
45+ this . store . updateFlightOperator ( ) ;
4946 this . _operatorCard ( ) . showSuccess ( ) ;
5047 } catch {
5148 this . _operatorCard ( ) . showError ( ) ;
@@ -54,7 +51,7 @@ export class FlightEditComponent {
5451
5552 onUpdatePrice ( ) {
5653 try {
57- this . store . updateFlightConnection ( ) ;
54+ this . store . updateFlightPrice ( ) ;
5855 this . _priceCard ( ) ?. showSuccess ( ) ;
5956 } catch {
6057 this . _priceCard ( ) ?. showError ( ) ;
0 commit comments