git.iko.soy/dashared/hookah-tau
on develop help sign in
Админ: можно тапать на ячейку бронирования в профиле клиента
commite6902bb8a882467e8e4fba75bfc2f4f04d82b58d authorDarya Rednikina <rednikina.com@yandex.ru> dateWed 8 Jan 2020, 16:00 (7 years ago) parent74b3876
4 files changed+41
Hookah Tau/Controllers/Admin/Clients/ClientsViewController.swift+5 Hookah Tau/Controllers/Admin/Clients/Profile/ClientProfileCoordinator.swift+13 Hookah Tau/Controllers/Admin/Clients/Profile/ProfileTableViewController.swift+14 Hookah Tau/Models/Reservation.swift+9
Hookah Tau/Controllers/Admin/Clients/ClientsViewController.swift+5
@@ -31,6 +31,11 @@ class ClientsViewController: UITableViewController {
3131 clientsService = ClientsService(apiClient: APIClient.shared)
3232 }
3333
34+ override func viewWillAppear(_ animated: Bool) {
35+ super.viewWillAppear(animated)
36+ tabBarController?.tabBar.isHidden = false
37+ }
38+
3439 override func viewDidAppear(_ animated: Bool) {
3540 super.viewDidAppear(animated)
3641 loadClients()
Hookah Tau/Controllers/Admin/Clients/Profile/ClientProfileCoordinator.swift+13
@@ -17,6 +17,7 @@ class ClientProfileCoordinator: BaseCoordinator {
1717 let storyboard = UIStoryboard(name: "ClientList", bundle: nil)
1818 let viewController = storyboard.instantiateViewController(withIdentifier: "ProfileTableViewController") as? ProfileTableViewController
1919 viewController?.user = user
20+ viewController?.coodinator = self
2021 guard let vc = viewController else { return }
2122 navigationController?.pushViewController(vc, animated: true)
2223 }
@@ -26,4 +27,16 @@ class ClientProfileCoordinator: BaseCoordinator {
2627 func createReservation(forUserWithPhone phoneNumber: String) {
2728
2829 }
30+
31+ // Просмотр (и редактирование) брони
32+ func seeExistingReservation(data: ReservationWithUser) {
33+ let reservationCoordinator = AdminReservationEditingCoordinator(navigationController: navigationController)
34+ addDependency(reservationCoordinator)
35+ reservationCoordinator.reservationData = data
36+ reservationCoordinator.didEndFlow = { [weak self] in
37+ self?.removeDependency(reservationCoordinator)
38+ self?.navigationController?.popViewController(animated: true)
39+ }
40+ reservationCoordinator.start()
41+ }
2942}
Hookah Tau/Controllers/Admin/Clients/Profile/ProfileTableViewController.swift+14
@@ -63,6 +63,11 @@ class ProfileTableViewController: BaseTableViewController {
6363 loadReservations()
6464 }
6565
66+ override func viewWillAppear(_ animated: Bool) {
67+ super.viewDidAppear(animated)
68+ tabBarController?.tabBar.isHidden = true
69+ }
70+
6671 func loadReservations() {
6772 guard let uuid = user?.uuid else { return }
6873 clientsService?.loadReservationsForUser(withUUID: uuid,
@@ -129,6 +134,15 @@ extension ProfileTableViewController {
129134 return cell
130135 }
131136
137+ // tap
138+
139+ override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
140+ guard let u = user else { return }
141+ let r = dataSource[indexPath.row]
142+ let reservation = ReservationWithUser(reservation: r, user: u)
143+ coodinator?.seeExistingReservation(data: reservation)
144+ }
145+
132146 // Update
133147
134148 override func tableView(_ tableView: UITableView, canEditRowAt indexPath: IndexPath) -> Bool {
Hookah Tau/Models/Reservation.swift+9
@@ -59,6 +59,15 @@ struct ReservationWithUser: MyCodable {
5959 var reservedTable: Int
6060 var owner: FullUser
6161
62+ init(reservation: Reservation, user: FullUser) {
63+ self.uuid = reservation.uuid
64+ self.establishment = reservation.establishment
65+ self.startTime = reservation.startTime
66+ self.endTime = reservation.endTime
67+ self.numberOfGuests = reservation.numberOfGuests
68+ self.reservedTable = reservation.reservedTable
69+ self.owner = user
70+ }
6271}
6372
6473