Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
F
flight-agency-app
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Heber Cordova
flight-agency-app
Commits
ad5dbcb1
Commit
ad5dbcb1
authored
Oct 23, 2023
by
Heber Cordova
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: finished reservation manager
parent
f4d7aaa0
Changes
14
Hide whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
385 additions
and
104 deletions
+385
-104
db.json
server/db.json
+15
-14
base-information.component.html
...mponents/base-information/base-information.component.html
+3
-9
base-information.component.ts
...components/base-information/base-information.component.ts
+27
-20
flight-information.component.html
...ents/flight-information/flight-information.component.html
+5
-6
flight-information.component.ts
...onents/flight-information/flight-information.component.ts
+43
-13
summary-information.component.html
...ts/summary-information/summary-information.component.html
+13
-17
summary-information.component.ts
...ents/summary-information/summary-information.component.ts
+65
-2
reservation.interface.ts
src/app/agent/interfaces/reservation.interface.ts
+17
-0
reservation-add.component.html
...gent/pages/reservation-add/reservation-add.component.html
+19
-4
reservation-add.component.ts
.../agent/pages/reservation-add/reservation-add.component.ts
+134
-8
reservations.component.ts
src/app/agent/pages/reservations/reservations.component.ts
+11
-9
reservations.service.ts
src/app/agent/services/reservations.service.ts
+31
-0
dialog.component.css
src/app/shared/components/dialog/dialog.component.css
+1
-1
table-search.component.ts
.../shared/components/table-search/table-search.component.ts
+1
-1
No files found.
server/db.json
View file @
ad5dbcb1
...
...
@@ -53,6 +53,21 @@
"id"
:
7
}
],
"reservations"
:
[
{
"agentId"
:
1
,
"passengerId"
:
4
,
"passengerName"
:
"Heber Cordova"
,
"travelClassCode"
:
1
,
"travelClassName"
:
"Economico"
,
"ticketTypeCode"
:
2
,
"ticketTypeName"
:
"Ejecutivo"
,
"statusCode"
:
"REGISTRADO"
,
"dateReservationMade"
:
"22/10/2023"
,
"flightId"
:
2
,
"id"
:
1
}
],
"bookings"
:
[
{
"id"
:
1
,
...
...
@@ -76,20 +91,6 @@
"status"
:
"Pendiente"
}
],
"typeDocuments"
:
[
{
"id"
:
1
,
"name"
:
"DNI"
},
{
"id"
:
2
,
"name"
:
"Carnet de Extranjeria"
},
{
"id"
:
3
,
"name"
:
"Pasaporte"
}
],
"passengers"
:
[
{
"name"
:
"Michael"
,
...
...
src/app/agent/components/base-information/base-information.component.html
View file @
ad5dbcb1
<div
class=
"base__fields"
>
<div
class=
"field field-passenger"
>
<shared-input-selector
name=
"Pasajeros"
[
value
]="
passengerSelectedName
"
[
tableModel
]="
passengerModel
"
[
tableData
]="
passengers
"
(
onSelect
)="
onSelectedPassenger
($
event
)"
></shared-input-selector>
<shared-input-selector
name=
"Pasajeros"
[
value
]="
getPassengerName
(
getControl
('
passenger
').
value
)
"
[
tableModel
]="
passengerModel
"
[
tableData
]="
passengers
"
(
onSelect
)="
onSelectedPassenger
($
event
)"
></shared-input-selector>
</div>
<div
class=
"field"
>
<label
for=
"field-ticket"
>
Tipo de ticket *
</label>
<select
class=
"field-select"
name=
"name"
id=
"field-ticket"
>
<option
*
ngFor=
"let type of ticketTypes"
[
value
]="
type
.
id
"
>
{{ type.name }}
</option>
</select>
<shared-input-dropdown
name=
"Tipo de ticket"
class=
"field-select"
[
control
]="
getControl
('
ticketType
')"
[
data
]="
ticketTypes
"
></shared-input-dropdown>
</div>
<div
class=
"field"
>
<label
for=
"field-class"
>
Clase de vuelo *
</label>
<select
class=
"field-select"
name=
"name"
id=
"field-class"
>
<option
*
ngFor=
"let class of flightClass"
[
value
]="
class
.
id
"
>
{{ class.name }}
</option>
</select>
<shared-input-dropdown
name=
"Tipo de pago"
class=
"field-select"
[
control
]="
getControl
('
flightClass
')"
[
data
]="
flightClass
"
></shared-input-dropdown>
</div>
</div>
src/app/agent/components/base-information/base-information.component.ts
View file @
ad5dbcb1
import
{
Component
,
OnInit
}
from
'@angular/core'
;
import
{
Component
,
Input
,
OnInit
}
from
'@angular/core'
;
import
{
Passenger
}
from
'../../interfaces/passenger.interface'
;
import
{
TicketType
}
from
'../../interfaces/ticket-type.interface'
;
import
{
FlightClass
}
from
'../../interfaces/flight-class.interface'
;
...
...
@@ -6,13 +6,15 @@ import { TableModel } from 'src/app/shared/interfaces/table-model.interface';
import
{
PassengerService
}
from
'../../services/passenger.service'
;
import
{
TicketTypeService
}
from
'../../services/ticket-type.service'
;
import
{
TicketClassService
}
from
'../../services/ticket-class.service'
;
import
{
DropdownElement
}
from
'src/app/shared/interfaces/dropdown-element-interface'
;
import
{
FormControl
,
FormGroup
}
from
'@angular/forms'
;
@
Component
({
selector
:
'agent-base-information'
,
templateUrl
:
'./base-information.component.html'
,
styleUrls
:
[
'./base-information.component.css'
]
})
export
class
BaseInformationComponent
implements
OnInit
{
export
class
BaseInformationComponent
{
public
passengerModel
:
TableModel
[]
=
[
{
...
...
@@ -41,34 +43,39 @@ export class BaseInformationComponent implements OnInit {
}
];
constructor
(
private
passengersService
:
PassengerService
,
private
ticketTypesService
:
TicketTypeService
,
private
ticketClassService
:
TicketClassService
)
{
}
@
Input
()
public
group
:
FormGroup
=
new
FormGroup
({
passenger
:
new
FormControl
<
string
|
null
>
(
null
),
ticketType
:
new
FormControl
<
string
|
null
>
(
null
),
flightClass
:
new
FormControl
<
string
|
null
>
(
null
),
});
ngOnInit
():
void
{
this
.
passengersService
.
getAll
()
.
subscribe
(
passengers
=>
this
.
passengers
=
passengers
);
constructor
()
{
}
this
.
ticketTypesService
.
getAll
()
.
subscribe
(
ticketTypes
=>
this
.
ticketTypes
=
ticketTypes
);
getControl
(
name
:
string
):
FormControl
<
string
|
null
>
{
return
this
.
group
.
get
(
name
)
as
FormControl
<
string
|
null
>
;
}
this
.
ticketClassService
.
getAll
()
.
subscribe
(
flightClass
=>
this
.
flightClass
=
flightClass
);
ngOnInit
():
void
{
}
@
Input
()
public
passengers
:
Passenger
[]
=
[];
public
ticketTypes
:
TicketType
[]
=
[];
@
Input
()
public
ticketTypes
:
DropdownElement
[]
=
[];
public
flightClass
:
FlightClass
[]
=
[];
@
Input
()
public
flightClass
:
DropdownElement
[]
=
[];
public
passengerSelected
?:
Passenger
;
get
passengerSelectedName
():
string
{
return
this
.
passengerSelected
?
`
${
this
.
passengerSelected
.
name
}
${
this
.
passengerSelected
.
lastname
}
`
:
''
;
onSelectedPassenger
(
passenger
:
Passenger
):
void
{
this
.
group
.
get
(
'passenger'
)?.
setValue
(
passenger
.
id
);
}
onSelectedPassenger
(
passenger
:
Passenger
):
void
{
this
.
passengerSelected
=
passenger
;
getPassengerName
(
id
:
string
|
null
):
string
|
null
{
if
(
id
)
{
const
passenger
=
this
.
passengers
.
find
(
passenger
=>
passenger
.
id
===
Number
.
parseInt
(
id
));
return
passenger
?
`
${
passenger
.
name
}
${
passenger
.
lastname
}
`
:
null
;
}
return
null
;
}
}
src/app/agent/components/flight-information/flight-information.component.html
View file @
ad5dbcb1
...
...
@@ -7,7 +7,7 @@
[
tableModel
]="
airportModel
"
[
tableData
]="
airports
"
(
onSelect
)="
onSelectAirportOrigin
($
event
)"
[
value
]="
airportValueNameOrigin
"
>
[
value
]="
getControl
('
airportOrigin
').
value
"
>
</shared-input-selector>
</div>
<div
class=
"field field-airport-destination"
>
...
...
@@ -16,17 +16,16 @@
[
tableModel
]="
airportModel
"
[
tableData
]="
airports
"
(
onSelect
)="
onSelectAirportDestination
($
event
)"
[
value
]="
airportValueNameDestination
"
>
[
value
]="
getControl
('
airportDestination
').
value
"
>
</shared-input-selector>
</div>
<div
class=
"field field-date-start"
>
<input
type=
"date"
name=
"name"
id=
"field-date-start"
>
<label
for=
"field-name"
>
Fecha partida *
</label>
<shared-input-calendar
name=
"Fecha"
[
control
]="
getControl
('
date
')"
></shared-input-calendar>
</div>
</div>
<div
class=
"search__actions"
>
<button
class=
"btn btn-filtrar"
>
Filtrar
</button>
<button
(
click
)="
onSearchFlights
()"
class=
"btn btn-filtrar"
>
Filtrar
</button>
</div>
</form>
<shared-table-search
[
tableModel
]="
flightModel
"
[
tableData
]="
[]
"
></shared-table-search>
<shared-table-search
[
tableModel
]="
flightModel
"
[
tableData
]="
flightResults
"
(
onSelect
)="
onEventSelectFlight
($
event
)
"
></shared-table-search>
</div>
src/app/agent/components/flight-information/flight-information.component.ts
View file @
ad5dbcb1
import
{
Component
,
Input
,
OnIni
t
}
from
'@angular/core'
;
import
{
Component
,
EventEmitter
,
Input
,
OnInit
,
Outpu
t
}
from
'@angular/core'
;
import
{
TableModel
}
from
'src/app/shared/interfaces/table-model.interface'
;
import
{
AirportsService
}
from
'../../services/airports.service'
;
import
{
Airport
}
from
'../../interfaces/airport.interface'
;
import
{
FlightService
}
from
'src/app/supervisor/services/flight.service'
;
import
{
FormControl
,
FormGroup
}
from
'@angular/forms'
;
import
{
Flight
}
from
'src/app/supervisor/interfaces/flight.interface'
;
@
Component
({
selector
:
'agent-flight-information'
,
...
...
@@ -32,32 +35,59 @@ export class FlightInformationComponent implements OnInit {
}
];
public
airports
:
Airport
[]
=
[];
public
flightResults
:
Flight
[]
=
[];
@
Input
()
public
group
:
FormGroup
=
new
FormGroup
({
airportOrigin
:
new
FormControl
<
string
|
null
>
(
null
),
airportDestination
:
new
FormControl
<
string
|
null
>
(
null
),
date
:
new
FormControl
<
string
|
null
>
(
null
)
});
getControl
(
name
:
string
):
FormControl
<
string
|
null
>
{
return
this
.
group
.
get
(
name
)
as
FormControl
<
string
|
null
>
;
}
public
airport
Origin
?:
Airport
;
public
airport
s
:
Airport
[]
=
[]
;
public
airportDestination
?:
Airport
;
constructor
(
private
airpotsService
:
AirportsService
)
{
}
constructor
(
private
airpotsService
:
AirportsService
,
private
flightService
:
FlightService
)
{
}
ngOnInit
():
void
{
this
.
airpotsService
.
getAll
()
.
subscribe
(
airports
=>
this
.
airports
=
airports
);
this
.
flightSelected
?
this
.
flightResults
.
push
(
this
.
flightSelected
)
:
[];
}
get
airportValueNameOrigin
():
string
{
return
this
.
airportOrigin
?.
name
||
''
;
onSelectAirportOrigin
(
airport
:
Airport
):
void
{
this
.
getControl
(
'airportOrigin'
).
setValue
(
airport
.
name
)
;
}
get
airportValueNameDestination
():
string
{
return
this
.
airportDestination
?.
name
||
''
;
onSelectAirportDestination
(
airport
:
Airport
):
void
{
this
.
getControl
(
'airportDestination'
).
setValue
(
airport
.
name
)
;
}
onSelectAirportOrigin
(
airport
:
Airport
):
void
{
this
.
airportOrigin
=
airport
;
onSearchFlights
():
void
{
this
.
group
.
markAllAsTouched
();
if
(
this
.
group
.
valid
)
{
this
.
flightService
.
searchFlight
(
this
.
group
.
value
.
airportOrigin
,
this
.
group
.
value
.
airportDestination
,
this
.
group
.
value
.
date
)
.
subscribe
(
flights
=>
{
this
.
flightResults
=
flights
;
});
}
}
onSelectAirportDestination
(
airport
:
Airport
):
void
{
this
.
airportDestination
=
airport
;
@
Output
()
public
onSelectFlight
:
EventEmitter
<
Flight
>
=
new
EventEmitter
<
Flight
>
();
@
Input
()
public
flightSelected
:
Flight
|
null
=
null
;
onEventSelectFlight
(
flight
:
Flight
):
void
{
this
.
flightSelected
=
flight
;
this
.
onSelectFlight
.
emit
(
flight
);
}
}
src/app/agent/components/summary-information/summary-information.component.html
View file @
ad5dbcb1
...
...
@@ -2,7 +2,7 @@
<section
class=
"base"
>
<div
class=
"base__header"
>
<h3
class=
"base__header-title"
>
Información base
</h3>
<button
class=
"base__header-btn"
>
<button
(
click
)="
changeStep
(
0
)"
class=
"base__header-btn"
>
<span
class=
"bi bi-pencil-square"
></span>
<span
class=
"ms-1"
>
Editar
</span>
</button>
...
...
@@ -10,22 +10,22 @@
<div
class=
"base__content"
>
<div
class=
"base__content-item"
>
<span
class=
"content__item-label"
>
Pasajero
</span>
<span
class=
"content__item-value"
>
Juan Perez
</span>
<span
class=
"content__item-value"
>
{{ passengerName }}
</span>
</div>
<div
class=
"base__content-item"
>
<span
class=
"content__item-label"
>
Tipo de ticket
</span>
<span
class=
"content__item-value"
>
Economico
</span>
<span
class=
"content__item-value"
>
{{ ticketTypeName }}
</span>
</div>
<div
class=
"base__content-item"
>
<span
class=
"content__item-label"
>
Clase de vuelo
</span>
<span
class=
"content__item-value"
>
Economico
</span>
<span
class=
"content__item-value"
>
{{ classTypeName }}
</span>
</div>
</div>
</section>
<section
class=
"flight"
>
<div
class=
"flight__header"
>
<h3
class=
"flight__header-title"
>
Selección de vuelo
</h3>
<button
class=
"flight__header-btn"
>
<button
(
click
)="
changeStep
(
1
)"
class=
"flight__header-btn"
>
<span
class=
"bi bi-pencil-square"
></span>
<span
class=
"ms-1"
>
Editar
</span>
</button>
...
...
@@ -33,35 +33,31 @@
<div
class=
"flight__content"
>
<div
class=
"flight__content-item"
>
<span
class=
"content__item-label"
>
Origen
</span>
<span
class=
"content__item_value"
>
Aeropuerto de Los Angeles
</span>
<span
class=
"content__item_value"
>
{{ flightSelected?.airportOrigin }}
</span>
</div>
<div
class=
"flight__content-item"
>
<span
class=
"content__item-label"
>
Destino
</span>
<span
class=
"content__item_value"
>
Aeropuerto de Miami
</span>
<span
class=
"content__item_value"
>
{{ flightSelected?.airportDestination }}
</span>
</div>
<div
class=
"flight__content-item"
>
<span
class=
"content__item-label"
>
Fecha de partida
</span>
<span
class=
"content__item_value"
>
12/12/2021
</span>
</div>
<div
class=
"flight__content-item"
>
<span
class=
"content__item-label"
>
Hora de partida
</span>
<span
class=
"content__item_value"
>
12:00
</span>
<span
class=
"content__item_value"
>
{{ flightSelected?.dateStart }}
</span>
</div>
<div
class=
"flight__content-item"
>
<span
class=
"content__item-label"
>
Fecha de llegada
</span>
<span
class=
"content__item_value"
>
16:00
</span>
<span
class=
"content__item_value"
>
{{ flightSelected?.dateEnd }}
</span>
</div>
<div
class=
"flight__content-item"
>
<span
class=
"content__item-label"
>
Aerolinea
</span>
<span
class=
"content__item_value"
>
American Airlines
</span>
<span
class=
"content__item_value"
>
{{ flightSelected?.airline }}
</span>
</div>
<div
class=
"flight__content-item"
>
<span
class=
"content__item-label"
>
Tipo de vuelo
</span>
<span
class=
"content__item_value"
>
Directo
</span>
<span
class=
"content__item_value"
>
{{ flighType }}
</span>
</div>
<div
class=
"flight__content-item"
>
<span
class=
"content__item-label"
>
Precio
</span>
<span
class=
"content__item_value"
>
200
USD
</span>
<span
class=
"content__item_value"
>
{{ totalCost }}
USD
</span>
</div>
</div>
</section>
...
...
@@ -70,7 +66,7 @@
<h3
class=
"detail__header-title"
>
Detalle de vuelo
</h3>
</div>
<div
class=
"detail__content"
>
<shared-table-search
[
tableModel
]="
flightModel
"
></shared-table-search>
<shared-table-search
[
tableModel
]="
scaleModel
"
[
tableData
]="
flightSelected
?.
scales
||
[]
"
></shared-table-search>
</div>
</section>
</div>
src/app/agent/components/summary-information/summary-information.component.ts
View file @
ad5dbcb1
import
{
Component
,
In
put
}
from
'@angular/core'
;
import
{
Component
,
EventEmitter
,
Input
,
Out
put
}
from
'@angular/core'
;
import
{
TableModel
}
from
'src/app/shared/interfaces/table-model.interface'
;
import
{
CostFlight
}
from
'src/app/supervisor/interfaces/cost-flight.interface'
;
import
{
Flight
}
from
'src/app/supervisor/interfaces/flight.interface'
;
@
Component
({
selector
:
'agent-summary-information'
,
...
...
@@ -8,6 +10,67 @@ import { TableModel } from 'src/app/shared/interfaces/table-model.interface';
})
export
class
SummaryInformationComponent
{
public
scaleModel
:
TableModel
[]
=
[
{
name
:
'id'
,
title
:
'#'
},
{
name
:
'airportOrigin'
,
title
:
'Origen'
},
{
name
:
'airportDestination'
,
title
:
'Destino'
},
{
name
:
'dateStart'
,
title
:
'Fecha de salida'
},
{
name
:
'dateEnd'
,
title
:
'Fecha de llegada'
}
]
@
Input
()
public
passengerName
:
string
=
''
;
@
Input
()
public
ticketTypeName
:
string
=
''
;
@
Input
()
public
classTypeName
:
string
=
''
;
@
Input
()
public
flightModel
:
TableModel
[]
=
[];
public
flightSelected
:
Flight
|
null
=
null
;
@
Output
()
public
onChangeStep
:
EventEmitter
<
number
>
=
new
EventEmitter
<
number
>
();
get
flighType
():
string
{
return
this
.
flightSelected
?
this
.
flightSelected
.
scales
.
length
>
1
?
'Con escalas'
:
'Directo'
:
''
;
}
get
totalCost
():
number
|
null
{
const
costs
=
this
.
flightSelected
?.
costs
;
const
date
:
Date
=
new
Date
(
this
.
flightSelected
?.
dateStart
as
string
);
const
cost
:
CostFlight
|
null
=
null
;
if
(
costs
)
{
for
(
let
i
=
0
;
i
<
costs
.
length
;
i
++
)
{
const
dateStart
:
Date
=
new
Date
(
costs
[
i
].
dateStart
);
const
dateEnd
:
Date
=
new
Date
(
costs
[
i
].
dateEnd
);
if
(
date
>=
dateStart
&&
date
<=
dateEnd
)
{
return
costs
[
i
].
cost
;
}
}
}
return
null
;
}
public
changeStep
(
step
:
number
):
void
{
this
.
onChangeStep
.
emit
(
step
);
}
}
src/app/agent/interfaces/reservation.interface.ts
0 → 100644
View file @
ad5dbcb1
interface
Reservation
{
id
?:
number
;
agentId
:
number
;
passengerId
:
number
;
passengerName
:
string
;
statusCode
:
ReservationStatusCode
;
ticketTypeCode
:
number
;
ticketTypeName
:
string
;
travelClassCode
:
number
;
travelClassName
:
string
;
dateReservationMade
:
string
;
flightId
:
number
;
}
type
ReservationStatusCode
=
'REGISTRADO'
|
'PROCESANDO_PAGO'
|
'CANCELADO'
|
'PAGADO'
;
export
{
Reservation
,
ReservationStatusCode
};
src/app/agent/pages/reservation-add/reservation-add.component.html
View file @
ad5dbcb1
...
...
@@ -7,13 +7,28 @@
<shared-stepper
[
steps
]="
steps
"
[
selectedStepIndex
]="
stepIndex
"
>
<div
class=
"p-4"
[
ngSwitch
]="
stepIndex
"
>
<div
*
ngSwitchCase=
"0"
>
<agent-base-information></agent-base-information>
<agent-base-information
[
passengers
]="
passengers
"
[
flightClass
]="
flightClass
"
[
ticketTypes
]="
ticketTypes
"
[
group
]="
formBaseInformation
"
>
</agent-base-information>
</div>
<div
*
ngSwitchCase=
"1"
>
<agent-flight-information
[
flightModel
]="
flightModel
"
></agent-flight-information>
<agent-flight-information
(
onSelectFlight
)="
onSelectFlight
($
event
)"
[
group
]="
formFlightInformation
"
[
flightSelected
]="
flightSelected
"
[
flightModel
]="
flightModel
"
>
</agent-flight-information>
</div>
<div
*
ngSwitchCase=
"2"
>
<agent-summary-information
[
flightModel
]="
flightModel
"
></agent-summary-information>
<agent-summary-information
[
passengerName
]="
passengerName
"
[
ticketTypeName
]="
ticketTypeName
"
[
classTypeName
]="
flightClassName
"
[
flightSelected
]="
flightSelected
"
(
onChangeStep
)="
onChangeStep
($
event
)"
>
</agent-summary-information>
</div>
</div>
</shared-stepper>
...
...
@@ -23,7 +38,7 @@
<span>
Anterior
</span>
</button>
<div
class=
"flex-fill"
></div>
<button
[
ngClass
]="['
btn
',
isLastStep
()
?
'
btn-save
'
:
'
btn-next
']"
(
click
)="
nextStep
()"
>
<button
[
disabled
]="
isInvalidThisStep
"
[
ngClass
]="['
btn
',
isLastStep
()
?
'
btn-save
'
:
'
btn-next
']"
(
click
)="
nextStep
()"
>
<i
*
ngIf=
"isLastStep()"
class=
"bi bi-floppy"
></i>
<span>
{{ isLastStep() ? 'Guardar' : 'Siguiente' }}
</span>
<i
*
ngIf=
"!isLastStep()"
class=
"bi bi-chevron-right"
></i>
...
...
src/app/agent/pages/reservation-add/reservation-add.component.ts
View file @
ad5dbcb1
...
...
@@ -3,8 +3,16 @@ import { Step } from 'src/app/shared/interfaces/step.interface';
import
{
TableModel
}
from
'src/app/shared/interfaces/table-model.interface'
;
import
{
PassengerService
}
from
'../../services/passenger.service'
;
import
{
Passenger
}
from
'../../interfaces/passenger.interface'
;
import
{
TicketType
}
from
'../../interfaces/ticket-type.interface'
;
import
{
FlightClass
}
from
'../../interfaces/flight-class.interface'
;
import
{
FormControl
,
FormGroup
,
Validators
}
from
'@angular/forms'
;
import
{
Flight
}
from
'src/app/supervisor/interfaces/flight.interface'
;
import
{
TicketTypeService
}
from
'../../services/ticket-type.service'
;
import
{
TicketClassService
}
from
'../../services/ticket-class.service'
;
import
{
DropdownElement
}
from
'src/app/shared/interfaces/dropdown-element-interface'
;
import
{
Reservation
,
ReservationStatusCode
}
from
'../../interfaces/reservation.interface'
;
import
{
ReservationsService
}
from
'../../services/reservations.service'
;
import
{
Location
}
from
'@angular/common'
;
import
{
ActivatedRoute
}
from
'@angular/router'
;
import
{
FlightService
}
from
'src/app/supervisor/services/flight.service'
;
@
Component
({
selector
:
'app-reservation-add'
,
...
...
@@ -40,7 +48,7 @@ export class ReservationAddComponent implements OnInit{
title
:
'#'
},
{
name
:
'a
ero
line'
,
name
:
'a
ir
line'
,
title
:
'Aerolinea'
},
{
...
...
@@ -52,11 +60,11 @@ export class ReservationAddComponent implements OnInit{
title
:
'Tipo de vuelo'
},
{
name
:
'
hour
Start'
,
name
:
'
date
Start'
,
title
:
'Hora de inicio'
},
{
name
:
'
hour
End'
,
name
:
'
date
End'
,
title
:
'Hora de llegada'
},
{
...
...
@@ -65,19 +73,106 @@ export class ReservationAddComponent implements OnInit{
}
];
// Base Information Form
public
formBaseInformation
:
FormGroup
=
new
FormGroup
({
ticketType
:
new
FormControl
<
string
|
null
>
(
null
,
[
Validators
.
required
]),
flightClass
:
new
FormControl
<
string
|
null
>
(
null
,
[
Validators
.
required
]),
passenger
:
new
FormControl
<
string
|
null
>
(
null
,
[
Validators
.
required
])
});
public
formFlightInformation
:
FormGroup
=
new
FormGroup
({
airportOrigin
:
new
FormControl
<
string
|
null
>
(
null
,
[
Validators
.
required
]),
airportDestination
:
new
FormControl
<
string
|
null
>
(
null
,
[
Validators
.
required
]),
date
:
new
FormControl
<
string
|
null
>
(
null
,
[
Validators
.
required
])
});
public
passengers
:
Passenger
[]
=
[];
public
ticketTypes
:
DropdownElement
[]
=
[];
public
flightClass
:
DropdownElement
[]
=
[];
get
passengerName
():
string
{
const
passengerId
=
this
.
formBaseInformation
.
get
(
'passenger'
)?.
value
;
const
passenger
=
this
.
passengers
.
find
(
passenger
=>
passenger
.
id
===
passengerId
);
return
passenger
?
passenger
.
name
+
' '
+
passenger
.
lastname
:
''
;
}
get
ticketTypeName
():
string
{
const
ticketTypeId
=
this
.
formBaseInformation
.
get
(
'ticketType'
)?.
value
;
const
ticketType
=
this
.
ticketTypes
.
find
(
ticketType
=>
ticketType
.
value
===
ticketTypeId
);
return
ticketType
?
ticketType
.
text
:
''
;
}
get
flightClassName
():
string
{
const
flightClassId
=
this
.
formBaseInformation
.
get
(
'flightClass'
)?.
value
;
const
flightClass
=
this
.
flightClass
.
find
(
flightClass
=>
flightClass
.
value
===
flightClassId
);
return
flightClass
?
flightClass
.
text
:
''
;
}
constructor
(
private
passengersService
:
PassengerService
)
{
}
get
isInvalidThisStep
():
boolean
{
if
(
this
.
stepIndex
==
0
)
return
this
.
formBaseInformation
.
invalid
;
if
(
this
.
stepIndex
==
1
)
return
this
.
formFlightInformation
.
invalid
||
this
.
flightSelected
===
null
;
return
false
;
}
constructor
(
private
passengersService
:
PassengerService
,
private
ticketTypesService
:
TicketTypeService
,
private
ticketClassService
:
TicketClassService
,
private
reservationsService
:
ReservationsService
,
private
flightService
:
FlightService
,
private
location
:
Location
,
private
activatedRoute
:
ActivatedRoute
)
{
}
ngOnInit
():
void
{
this
.
activatedRoute
.
params
.
subscribe
(
params
=>
{
if
(
params
[
'id'
])
{
this
.
reservationsService
.
getById
(
params
[
'id'
])
.
subscribe
(
reservation
=>
{
this
.
formBaseInformation
.
get
(
'passenger'
)?.
setValue
(
reservation
.
passengerId
);
this
.
formBaseInformation
.
get
(
'ticketType'
)?.
setValue
(
reservation
.
travelClassCode
.
toString
());
this
.
formBaseInformation
.
get
(
'flightClass'
)?.
setValue
(
reservation
.
ticketTypeCode
.
toString
());
this
.
flightService
.
getById
(
reservation
.
flightId
)
.
subscribe
(
flight
=>
{
this
.
flightSelected
=
flight
;
this
.
formFlightInformation
.
get
(
'airportOrigin'
)?.
setValue
(
flight
.
airportOrigin
);
this
.
formFlightInformation
.
get
(
'airportDestination'
)?.
setValue
(
flight
.
airportDestination
);
this
.
formFlightInformation
.
get
(
'date'
)?.
setValue
(
flight
.
dateStart
);
})
})
}
this
.
getAllData
();
})
}
getAllData
():
void
{
this
.
passengersService
.
getAll
()
.
subscribe
(
passengers
=>
this
.
passengers
=
passengers
);
.
subscribe
(
passengers
=>
this
.
passengers
=
passengers
);
this
.
ticketTypesService
.
getAll
()
.
subscribe
(
ticketTypes
=>
{
ticketTypes
.
map
(
ticketType
=>
{
this
.
ticketTypes
.
push
({
text
:
ticketType
.
name
,
value
:
ticketType
.
id
.
toString
()
});
});
});
this
.
ticketClassService
.
getAll
()
.
subscribe
(
flightClass
=>
{
flightClass
.
map
(
flight
=>
{
this
.
flightClass
.
push
({
text
:
flight
.
name
,
value
:
flight
.
id
.
toString
()
});
})
});
}
public
flightSelected
:
Flight
|
null
=
null
;
public
stepIndex
:
number
=
0
;
nextStep
():
void
{
if
(
this
.
stepIndex
===
this
.
steps
.
length
)
return
;
if
(
this
.
stepIndex
===
this
.
steps
.
length
-
1
)
{
this
.
onSaveBooking
();
return
;
};
this
.
stepIndex
++
;
}
...
...
@@ -86,6 +181,10 @@ export class ReservationAddComponent implements OnInit{
this
.
stepIndex
--
;
}
onChangeStep
(
step
:
number
):
void
{
this
.
stepIndex
=
step
;
}
isFirstStep
():
boolean
{
return
this
.
stepIndex
===
0
;
}
...
...
@@ -93,4 +192,31 @@ export class ReservationAddComponent implements OnInit{
isLastStep
():
boolean
{
return
this
.
stepIndex
===
this
.
steps
.
length
-
1
;
}
onSelectFlight
(
flight
:
Flight
):
void
{
this
.
flightSelected
=
flight
;
}
onSaveBooking
():
void
{
const
reservation
:
Reservation
=
{
agentId
:
1
,
passengerId
:
this
.
formBaseInformation
.
value
.
passenger
,
passengerName
:
this
.
passengerName
,
travelClassCode
:
parseInt
(
this
.
formBaseInformation
.
value
.
ticketType
),
travelClassName
:
this
.
ticketTypeName
,
ticketTypeCode
:
parseInt
(
this
.
formBaseInformation
.
value
.
flightClass
),
ticketTypeName
:
this
.
flightClassName
,
statusCode
:
'REGISTRADO'
,
dateReservationMade
:
new
Date
().
toLocaleDateString
(),
flightId
:
this
.
flightSelected
?.
id
||
0
};
this
.
reservationsService
.
save
(
reservation
)
.
subscribe
(()
=>
{
this
.
formBaseInformation
.
reset
();
this
.
formFlightInformation
.
reset
();
this
.
flightSelected
=
null
;
this
.
location
.
back
();
})
}
}
src/app/agent/pages/reservations/reservations.component.ts
View file @
ad5dbcb1
...
...
@@ -3,6 +3,8 @@ import { TableModel } from 'src/app/shared/interfaces/table-model.interface';
import
{
BookingService
}
from
'../../services/booking.service'
;
import
{
Booking
}
from
'../../interfaces/booking.interface'
;
import
{
ResultDelete
}
from
'src/app/shared/interfaces/result-delete.interface'
;
import
{
Reservation
}
from
'../../interfaces/reservation.interface'
;
import
{
ReservationsService
}
from
'../../services/reservations.service'
;
@
Component
({
selector
:
'app-reservations'
,
...
...
@@ -11,7 +13,7 @@ import { ResultDelete } from 'src/app/shared/interfaces/result-delete.interface'
})
export
class
ReservationsComponent
implements
OnInit
{
tableData
:
Booking
[]
=
[];
tableData
:
Reservation
[]
=
[];
tableModel
:
TableModel
[]
=
[
{
...
...
@@ -19,37 +21,37 @@ export class ReservationsComponent implements OnInit{
title
:
'#'
},
{
name
:
'passenger
Id
'
,
name
:
'passenger
Name
'
,
title
:
'Pasajero'
},
{
name
:
't
ypeTicket
'
,
title
:
'Tipo de Ti
quete
'
name
:
't
icketTypeName
'
,
title
:
'Tipo de Ti
cket
'
},
{
name
:
'
class
'
,
name
:
'
travelClassName
'
,
title
:
'Clase'
},
{
name
:
'status'
,
name
:
'status
Code
'
,
title
:
'Estado'
}
];
constructor
(
private
bookingService
:
Booking
Service
)
{
}
constructor
(
private
reservationsService
:
Reservations
Service
)
{
}
ngOnInit
():
void
{
this
.
getAll
();
}
getAll
():
void
{
this
.
booking
Service
.
getAll
()
this
.
reservations
Service
.
getAll
()
.
subscribe
(
bookings
=>
this
.
tableData
=
bookings
);
}
onDelete
(
result
:
ResultDelete
):
void
{
if
(
!
result
.
result
)
return
;
this
.
booking
Service
.
delete
(
result
.
id
)
this
.
reservations
Service
.
delete
(
result
.
id
)
.
subscribe
(()
=>
this
.
getAll
());
}
}
src/app/agent/services/reservations.service.ts
0 → 100644
View file @
ad5dbcb1
import
{
Injectable
}
from
'@angular/core'
;
import
{
HttpClient
}
from
'@angular/common/http'
;
import
{
Reservation
}
from
'../interfaces/reservation.interface'
;
import
{
Observable
}
from
'rxjs'
;
@
Injectable
({
providedIn
:
'root'
})
export
class
ReservationsService
{
constructor
(
private
http
:
HttpClient
)
{
}
URL_BASE
:
string
=
'http://localhost:3000/reservations'
;
getAll
():
Observable
<
Reservation
[]
>
{
return
this
.
http
.
get
<
Reservation
[]
>
(
this
.
URL_BASE
);
}
getById
(
id
:
number
):
Observable
<
Reservation
>
{
return
this
.
http
.
get
<
Reservation
>
(
`
${
this
.
URL_BASE
}
/
${
id
}
`
);
}
save
(
reservation
:
Reservation
):
Observable
<
Reservation
>
{
return
this
.
http
.
post
<
Reservation
>
(
this
.
URL_BASE
,
reservation
);
}
edit
(
id
:
number
,
reservation
:
Reservation
):
Observable
<
Reservation
>
{
return
this
.
http
.
put
<
Reservation
>
(
`
${
this
.
URL_BASE
}
/
${
id
}
`
,
reservation
);
}
delete
(
id
:
number
):
Observable
<
Reservation
>
{
return
this
.
http
.
delete
<
Reservation
>
(
`
${
this
.
URL_BASE
}
/
${
id
}
`
);
}
}
src/app/shared/components/dialog/dialog.component.css
View file @
ad5dbcb1
...
...
@@ -14,7 +14,7 @@
.dialog__content
{
background-color
:
white
;
width
:
4
0%
;
width
:
10
0%
;
max-width
:
70vw
;
max-height
:
80vh
;
border-radius
:
5px
;
...
...
src/app/shared/components/table-search/table-search.component.ts
View file @
ad5dbcb1
...
...
@@ -15,7 +15,7 @@ export class TableSearchComponent {
public
tableModel
:
TableModel
[]
=
[];
@
Output
()
public
onSelect
:
EventEmitter
<
any
[]
>
=
new
EventEmitter
<
any
[]
>
();
public
onSelect
:
EventEmitter
<
any
>
=
new
EventEmitter
<
any
>
();
onSelectRow
(
row
:
any
):
void
{
this
.
onSelect
.
emit
(
row
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment