git.iko.soy/dashared/hookah-tau
on develop help sign in
35 files changed+1042−173
since splitsnapshots
unifiedsplit
Hookah Tau.xcodeproj/project.pbxproj+75−23 Hookah Tau/API/APIClient.swift+2 Hookah Tau/API/ClientsService/ClientsService.swift+46 Hookah Tau/API/Settings/Resolvers/AddOtherAdminResolver.swift → Hookah Tau/API/ClientsService/Resolvers/AddOtherAdminResolver.swift Hookah Tau/API/ClientsService/Resolvers/DeleteOtherAdminResolver.swift+35 Hookah Tau/API/ClientsService/Resolvers/GetClientByPhoneNumberResolver.swift+35 Hookah Tau/API/Reservations api/ReservationsService.swift+23 Hookah Tau/API/Reservations api/Resolvers/Admin/ACreateReservationResolver.swift+37 Hookah Tau/API/ServerError.swift+1 Hookah Tau/API/Settings/SettingsService.swift−34 Hookah Tau/Components/PhoneTextField.swift+63 Hookah Tau/Controllers/Admin/Clients/Cells/ClientTableViewCell.swift+7−5 Hookah Tau/Controllers/Admin/Clients/ClientList.storyboard+25−26 Hookah Tau/Controllers/Admin/Clients/ClientsCoordinator.swift+1−4 Hookah Tau/Controllers/Admin/Clients/ClientsViewController.swift+92−6 Hookah Tau/Controllers/Admin/Clients/Profile/ClientProfileCoordinator.swift+12−2 Hookah Tau/Controllers/Admin/Clients/Profile/ProfileTableViewController.swift+22−6 Hookah Tau/Controllers/Admin/Reservations/AdminReservationEditingCoordinator.swift+3−1 Hookah Tau/Controllers/Admin/Reservations/AdminReservationEditingViewController.swift+52−21 Hookah Tau/Controllers/Admin/Reservations/AdminReservations.storyboard+67−3 Hookah Tau/Controllers/Admin/Reservations/List of reservations/AdminReservationsController.swift+4−3 Hookah Tau/Controllers/Admin/Reservations/List of reservations/AdminReservationsCoordinator.swift+16 Hookah Tau/Controllers/Admin/Reservations/Making a reeservation/1/AdminFirstStepReservationViewCoordinator.swift+108 Hookah Tau/Controllers/Admin/Reservations/Making a reeservation/2/AdminSecondStepReservationViewController.swift+124 Hookah Tau/Controllers/Admin/Reservations/Making a reeservation/2/AdminSecondStepReservationViewCoordinator.swift+54 Hookah Tau/Controllers/Admin/Reservations/Making a reeservation/3/AdminFinalStepReservationCoordinator.swift+47 Hookah Tau/Controllers/Admin/Reservations/Views/AdminReservationView.swift+11−4 Hookah Tau/Controllers/Admin/Reservations/Views/AdminReservationView.xib+36−21 Hookah Tau/Controllers/BaseViewController.swift+1−1 Hookah Tau/Controllers/Client/Profile/ProfileChangeViewController.swift+3−3 Hookah Tau/Controllers/Client/Reservations/Active Reservations/ReservationsViewController.swift+1−1 Hookah Tau/Controllers/Client/Reservations/Steps/1/FirstStepReservationCoordinator.swift+8−1 Hookah Tau/Controllers/Client/Reservations/Steps/1/FirstStepReservationViewController.swift+15−6 Hookah Tau/Models/Reservation.swift+15−1 Hookah Tau/Models/User.swift+1−1
Hookah Tau.xcodeproj/project.pbxproj+75−23
@@ -17,6 +17,9 @@
1717 12118B9E23682049006BAEE3 /* PhoneCodeResolver.swift in Sources */ = {isa = PBXBuildFile; fileRef = 12118B9D23682049006BAEE3 /* PhoneCodeResolver.swift */; };
1818 1212048C23914CFD00CAF162 /* DeleteReservationResolver.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1212048B23914CFD00CAF162 /* DeleteReservationResolver.swift */; };
1919 1212048E23915A0A00CAF162 /* ChangeReservationResolver.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1212048D23915A0A00CAF162 /* ChangeReservationResolver.swift */; };
20+ 1220A6F423CDB1AD00365E36 /* GetClientByPhoneNumberResolver.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1220A6F323CDB1AD00365E36 /* GetClientByPhoneNumberResolver.swift */; };
21+ 1220A6F723CDB64A00365E36 /* AdminSecondStepReservationViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1220A6F623CDB64A00365E36 /* AdminSecondStepReservationViewController.swift */; };
22+ 1220A6FA23CDBE7E00365E36 /* AdminFinalStepReservationCoordinator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1220A6F923CDBE7E00365E36 /* AdminFinalStepReservationCoordinator.swift */; };
2023 12219CEF2353A63F0057DDEE /* ReservationsCoordinator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 12219CEE2353A63E0057DDEE /* ReservationsCoordinator.swift */; };
2124 12230AEA238FD8B3004A01E5 /* MapView2.xib in Resources */ = {isa = PBXBuildFile; fileRef = 12230AE9238FD8B3004A01E5 /* MapView2.xib */; };
2225 12230AEC238FD8C5004A01E5 /* MapView2.swift in Sources */ = {isa = PBXBuildFile; fileRef = 12230AEB238FD8C5004A01E5 /* MapView2.swift */; };
@@ -40,6 +43,7 @@
4043 124D007C23721FD400AE76B9 /* Reservation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 124D007B23721FD400AE76B9 /* Reservation.swift */; };
4144 124D007F237222B200AE76B9 /* ReservationsResolver.swift in Sources */ = {isa = PBXBuildFile; fileRef = 124D007E237222B200AE76B9 /* ReservationsResolver.swift */; };
4245 124D0081237222C900AE76B9 /* ReservationsService.swift in Sources */ = {isa = PBXBuildFile; fileRef = 124D0080237222C900AE76B9 /* ReservationsService.swift */; };
46+ 1252D9E523CDCDB300446B6F /* ACreateReservationResolver.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1252D9E423CDCDB300446B6F /* ACreateReservationResolver.swift */; };
4347 125AE51D2395583E00F847BD /* ChangeReservationCoordinator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 125AE51C2395583E00F847BD /* ChangeReservationCoordinator.swift */; };
4448 125AE51F2395585300F847BD /* ChangeReservationViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 125AE51E2395585300F847BD /* ChangeReservationViewController.swift */; };
4549 125AE5212395753400F847BD /* HFunc.swift in Sources */ = {isa = PBXBuildFile; fileRef = 125AE5202395753400F847BD /* HFunc.swift */; };
@@ -51,6 +55,9 @@
5155 12838EB4236779C700CEF108 /* ApiResolver.swift in Sources */ = {isa = PBXBuildFile; fileRef = 12838EB3236779C700CEF108 /* ApiResolver.swift */; };
5256 12838EB623677FB900CEF108 /* ApiRequest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 12838EB523677FB900CEF108 /* ApiRequest.swift */; };
5357 12838EB82367834900CEF108 /* MyCodable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 12838EB72367834900CEF108 /* MyCodable.swift */; };
58+ 129F162723CC838200EE13FC /* AdminFirstStepReservationViewCoordinator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 129F162623CC838200EE13FC /* AdminFirstStepReservationViewCoordinator.swift */; };
59+ 129F162C23CC8D2E00EE13FC /* AdminSecondStepReservationViewCoordinator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 129F162B23CC8D2E00EE13FC /* AdminSecondStepReservationViewCoordinator.swift */; };
60+ 129F163023CC8EF600EE13FC /* PhoneTextField.swift in Sources */ = {isa = PBXBuildFile; fileRef = 129F162F23CC8EF600EE13FC /* PhoneTextField.swift */; };
5461 12A075F72373535C00D749BB /* FirstStepReservationViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 12A075F62373535C00D749BB /* FirstStepReservationViewController.swift */; };
5562 12A075F9237353F500D749BB /* MapView1.xib in Resources */ = {isa = PBXBuildFile; fileRef = 12A075F8237353F500D749BB /* MapView1.xib */; };
5663 12A075FB2373561A00D749BB /* Reservation.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 12A075FA2373561A00D749BB /* Reservation.storyboard */; };
@@ -69,7 +76,6 @@
6976 12B3A7AF23AC1872009E2FA6 /* AdminNoReservationsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 12B3A7AE23AC1872009E2FA6 /* AdminNoReservationsView.swift */; };
7077 12B3A7B123AC1885009E2FA6 /* AdminNoReservationsView.xib in Resources */ = {isa = PBXBuildFile; fileRef = 12B3A7B023AC1885009E2FA6 /* AdminNoReservationsView.xib */; };
7178 12B3A7B423AC1D09009E2FA6 /* AdminReservationCellView.xib in Resources */ = {isa = PBXBuildFile; fileRef = 12B3A7B323AC1D09009E2FA6 /* AdminReservationCellView.xib */; };
72− 12B3A7B723ACCD07009E2FA6 /* SettingsService.swift in Sources */ = {isa = PBXBuildFile; fileRef = 12B3A7B623ACCD07009E2FA6 /* SettingsService.swift */; };
7379 12B3A7B923ACCD83009E2FA6 /* AddOtherAdminResolver.swift in Sources */ = {isa = PBXBuildFile; fileRef = 12B3A7B823ACCD83009E2FA6 /* AddOtherAdminResolver.swift */; };
7480 12B3A7BC23ACFD75009E2FA6 /* ReservationsAroundResolver.swift in Sources */ = {isa = PBXBuildFile; fileRef = 12B3A7BB23ACFD75009E2FA6 /* ReservationsAroundResolver.swift */; };
7581 12B3A7BE23AD0049009E2FA6 /* AdminReservationEditingViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 12B3A7BD23AD0048009E2FA6 /* AdminReservationEditingViewController.swift */; };
@@ -115,6 +121,7 @@
115121 12F9652A23868E6000FCA696 /* SecondStepView.xib in Resources */ = {isa = PBXBuildFile; fileRef = 12F9652923868E6000FCA696 /* SecondStepView.xib */; };
116122 12F9652C23868E7200FCA696 /* SecondStepView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 12F9652B23868E7200FCA696 /* SecondStepView.swift */; };
117123 12F9652E23869F3100FCA696 /* SecondStepReservationCoordinator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 12F9652D23869F3100FCA696 /* SecondStepReservationCoordinator.swift */; };
124+ 12FC07B923C8D17600EDC55B /* DeleteOtherAdminResolver.swift in Sources */ = {isa = PBXBuildFile; fileRef = 12FC07B823C8D17600EDC55B /* DeleteOtherAdminResolver.swift */; };
118125 12FC40382382C93D00AB593B /* TableButtonStyle.swift in Sources */ = {isa = PBXBuildFile; fileRef = 12FC40372382C93C00AB593B /* TableButtonStyle.swift */; };
119126 12FC403A2382CB6F00AB593B /* TableButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = 12FC40392382CB6F00AB593B /* TableButton.swift */; };
120127 F30369B5233679EA00A8EA84 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = F30369B4233679EA00A8EA84 /* LaunchScreen.storyboard */; };
@@ -175,6 +182,9 @@
175182 12118B9D23682049006BAEE3 /* PhoneCodeResolver.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PhoneCodeResolver.swift; sourceTree = "<group>"; };
176183 1212048B23914CFD00CAF162 /* DeleteReservationResolver.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DeleteReservationResolver.swift; sourceTree = "<group>"; };
177184 1212048D23915A0A00CAF162 /* ChangeReservationResolver.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ChangeReservationResolver.swift; sourceTree = "<group>"; };
185+ 1220A6F323CDB1AD00365E36 /* GetClientByPhoneNumberResolver.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GetClientByPhoneNumberResolver.swift; sourceTree = "<group>"; };
186+ 1220A6F623CDB64A00365E36 /* AdminSecondStepReservationViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AdminSecondStepReservationViewController.swift; sourceTree = "<group>"; };
187+ 1220A6F923CDBE7E00365E36 /* AdminFinalStepReservationCoordinator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AdminFinalStepReservationCoordinator.swift; sourceTree = "<group>"; };
178188 12219CEE2353A63E0057DDEE /* ReservationsCoordinator.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ReservationsCoordinator.swift; sourceTree = "<group>"; };
179189 12230AE9238FD8B3004A01E5 /* MapView2.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = MapView2.xib; sourceTree = "<group>"; };
180190 12230AEB238FD8C5004A01E5 /* MapView2.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MapView2.swift; sourceTree = "<group>"; };
@@ -198,6 +208,7 @@
198208 124D007B23721FD400AE76B9 /* Reservation.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Reservation.swift; sourceTree = "<group>"; };
199209 124D007E237222B200AE76B9 /* ReservationsResolver.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ReservationsResolver.swift; sourceTree = "<group>"; };
200210 124D0080237222C900AE76B9 /* ReservationsService.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ReservationsService.swift; sourceTree = "<group>"; };
211+ 1252D9E423CDCDB300446B6F /* ACreateReservationResolver.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ACreateReservationResolver.swift; sourceTree = "<group>"; };
201212 125AE51C2395583E00F847BD /* ChangeReservationCoordinator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ChangeReservationCoordinator.swift; sourceTree = "<group>"; };
202213 125AE51E2395585300F847BD /* ChangeReservationViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ChangeReservationViewController.swift; sourceTree = "<group>"; };
203214 125AE5202395753400F847BD /* HFunc.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HFunc.swift; sourceTree = "<group>"; };
@@ -208,6 +219,9 @@
208219 12838EB3236779C700CEF108 /* ApiResolver.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ApiResolver.swift; sourceTree = "<group>"; };
209220 12838EB523677FB900CEF108 /* ApiRequest.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ApiRequest.swift; sourceTree = "<group>"; };
210221 12838EB72367834900CEF108 /* MyCodable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MyCodable.swift; sourceTree = "<group>"; };
222+ 129F162623CC838200EE13FC /* AdminFirstStepReservationViewCoordinator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AdminFirstStepReservationViewCoordinator.swift; sourceTree = "<group>"; };
223+ 129F162B23CC8D2E00EE13FC /* AdminSecondStepReservationViewCoordinator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AdminSecondStepReservationViewCoordinator.swift; sourceTree = "<group>"; };
224+ 129F162F23CC8EF600EE13FC /* PhoneTextField.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PhoneTextField.swift; sourceTree = "<group>"; };
211225 12A075F62373535C00D749BB /* FirstStepReservationViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FirstStepReservationViewController.swift; sourceTree = "<group>"; };
212226 12A075F8237353F500D749BB /* MapView1.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = MapView1.xib; sourceTree = "<group>"; };
213227 12A075FA2373561A00D749BB /* Reservation.storyboard */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; path = Reservation.storyboard; sourceTree = "<group>"; };
@@ -226,7 +240,6 @@
226240 12B3A7AE23AC1872009E2FA6 /* AdminNoReservationsView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AdminNoReservationsView.swift; sourceTree = "<group>"; };
227241 12B3A7B023AC1885009E2FA6 /* AdminNoReservationsView.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = AdminNoReservationsView.xib; sourceTree = "<group>"; };
228242 12B3A7B323AC1D09009E2FA6 /* AdminReservationCellView.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = AdminReservationCellView.xib; sourceTree = "<group>"; };
229− 12B3A7B623ACCD07009E2FA6 /* SettingsService.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SettingsService.swift; sourceTree = "<group>"; };
230243 12B3A7B823ACCD83009E2FA6 /* AddOtherAdminResolver.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AddOtherAdminResolver.swift; sourceTree = "<group>"; };
231244 12B3A7BB23ACFD75009E2FA6 /* ReservationsAroundResolver.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ReservationsAroundResolver.swift; sourceTree = "<group>"; };
232245 12B3A7BD23AD0048009E2FA6 /* AdminReservationEditingViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AdminReservationEditingViewController.swift; sourceTree = "<group>"; };
@@ -272,6 +285,7 @@
272285 12F9652923868E6000FCA696 /* SecondStepView.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = SecondStepView.xib; sourceTree = "<group>"; };
273286 12F9652B23868E7200FCA696 /* SecondStepView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SecondStepView.swift; sourceTree = "<group>"; };
274287 12F9652D23869F3100FCA696 /* SecondStepReservationCoordinator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SecondStepReservationCoordinator.swift; sourceTree = "<group>"; };
288+ 12FC07B823C8D17600EDC55B /* DeleteOtherAdminResolver.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DeleteOtherAdminResolver.swift; sourceTree = "<group>"; };
275289 12FC40372382C93C00AB593B /* TableButtonStyle.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TableButtonStyle.swift; sourceTree = "<group>"; };
276290 12FC40392382CB6F00AB593B /* TableButton.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TableButton.swift; sourceTree = "<group>"; };
277291 F30369B4233679EA00A8EA84 /* LaunchScreen.storyboard */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; path = LaunchScreen.storyboard; sourceTree = "<group>"; };
@@ -392,6 +406,31 @@
392406 path = Reservations;
393407 sourceTree = "<group>";
394408 };
409+ 1220A6F523CDB63000365E36 /* 2 */ = {
410+ isa = PBXGroup;
411+ children = (
412+ 1220A6F623CDB64A00365E36 /* AdminSecondStepReservationViewController.swift */,
413+ 129F162B23CC8D2E00EE13FC /* AdminSecondStepReservationViewCoordinator.swift */,
414+ );
415+ path = 2;
416+ sourceTree = "<group>";
417+ };
418+ 1220A6F823CDB65C00365E36 /* 1 */ = {
419+ isa = PBXGroup;
420+ children = (
421+ 129F162623CC838200EE13FC /* AdminFirstStepReservationViewCoordinator.swift */,
422+ );
423+ path = 1;
424+ sourceTree = "<group>";
425+ };
426+ 1220A6FB23CDBED900365E36 /* 3 */ = {
427+ isa = PBXGroup;
428+ children = (
429+ 1220A6F923CDBE7E00365E36 /* AdminFinalStepReservationCoordinator.swift */,
430+ );
431+ path = 3;
432+ sourceTree = "<group>";
433+ };
395434 12230AED238FD8D5004A01E5 /* 1 */ = {
396435 isa = PBXGroup;
397436 children = (
@@ -468,6 +507,7 @@
468507 123D25ED239E3D50002FA32B /* Reservations */ = {
469508 isa = PBXGroup;
470509 children = (
510+ 129F162523CC836600EE13FC /* Making a reeservation */,
471511 12B3A79623ABAD9A009E2FA6 /* Views */,
472512 12B3A7C123AD0751009E2FA6 /* Editing */,
473513 12B3A7C223AD0762009E2FA6 /* List of reservations */,
@@ -549,7 +589,6 @@
549589 12838EB923679AEB00CEF108 /* API */ = {
550590 isa = PBXGroup;
551591 children = (
552− 12B3A7B523ACCCD0009E2FA6 /* Settings */,
553592 12838EA8236764A600CEF108 /* APIClient.swift */,
554593 12838EB3236779C700CEF108 /* ApiResolver.swift */,
555594 12838EAF236777D400CEF108 /* ServerError.swift */,
@@ -563,9 +602,27 @@
563602 path = API;
564603 sourceTree = "<group>";
565604 };
605+ 129F162523CC836600EE13FC /* Making a reeservation */ = {
606+ isa = PBXGroup;
607+ children = (
608+ 1220A6F823CDB65C00365E36 /* 1 */,
609+ 1220A6F523CDB63000365E36 /* 2 */,
610+ 1220A6FB23CDBED900365E36 /* 3 */,
611+ );
612+ path = "Making a reeservation";
613+ sourceTree = "<group>";
614+ };
615+ 129F162823CC89EA00EE13FC /* Phone number */ = {
616+ isa = PBXGroup;
617+ children = (
618+ );
619+ path = "Phone number";
620+ sourceTree = "<group>";
621+ };
566622 12B3A79623ABAD9A009E2FA6 /* Views */ = {
567623 isa = PBXGroup;
568624 children = (
625+ 129F162823CC89EA00EE13FC /* Phone number */,
569626 12B3A7B223AC1A1F009E2FA6 /* No reserv */,
570627 12B3A79723ABADB9009E2FA6 /* AdminReservationView.xib */,
571628 12B3A79E23ABCA21009E2FA6 /* AdminReservationView.swift */,
@@ -597,6 +654,7 @@
597654 12B3A7AC23ABEABF009E2FA6 /* AReservationsResolver.swift */,
598655 12B3A7C323AD2FCD009E2FA6 /* AChangeReservationResolver.swift */,
599656 12D928AE23C47DCF0051724D /* ADeleteReservationResolver.swift */,
657+ 1252D9E423CDCDB300446B6F /* ACreateReservationResolver.swift */,
600658 );
601659 path = Admin;
602660 sourceTree = "<group>";
@@ -610,23 +668,6 @@
610668 path = "No reserv";
611669 sourceTree = "<group>";
612670 };
613− 12B3A7B523ACCCD0009E2FA6 /* Settings */ = {
614− isa = PBXGroup;
615− children = (
616− 12B3A7B623ACCD07009E2FA6 /* SettingsService.swift */,
617− 12B3A7BA23ACCD88009E2FA6 /* Resolvers */,
618− );
619− path = Settings;
620− sourceTree = "<group>";
621− };
622− 12B3A7BA23ACCD88009E2FA6 /* Resolvers */ = {
623− isa = PBXGroup;
624− children = (
625− 12B3A7B823ACCD83009E2FA6 /* AddOtherAdminResolver.swift */,
626− );
627− path = Resolvers;
628− sourceTree = "<group>";
629− };
630671 12B3A7C123AD0751009E2FA6 /* Editing */ = {
631672 isa = PBXGroup;
632673 children = (
@@ -711,9 +752,12 @@
711752 12E35075239FAF8F004BB188 /* Resolvers */ = {
712753 isa = PBXGroup;
713754 children = (
755+ 12FC07B823C8D17600EDC55B /* DeleteOtherAdminResolver.swift */,
756+ 12B3A7B823ACCD83009E2FA6 /* AddOtherAdminResolver.swift */,
714757 12E35077239FAFA4004BB188 /* ClientsListResolver.swift */,
715758 12E3507C239FD1F3004BB188 /* ClientReservationsResolver.swift */,
716759 12D928B223C7464B0051724D /* BlocklistPutResolver.swift */,
760+ 1220A6F323CDB1AD00365E36 /* GetClientByPhoneNumberResolver.swift */,
717761 );
718762 path = Resolvers;
719763 sourceTree = "<group>";
@@ -828,6 +872,7 @@
828872 F3DC5A04233E89D500B5E751 /* Button.swift */,
829873 12FC40372382C93C00AB593B /* TableButtonStyle.swift */,
830874 12FC40392382CB6F00AB593B /* TableButton.swift */,
875+ 129F162F23CC8EF600EE13FC /* PhoneTextField.swift */,
831876 );
832877 path = Components;
833878 sourceTree = "<group>";
@@ -1152,6 +1197,8 @@
11521197 files = (
11531198 12EA99482362B684005D9FE9 /* AddresViewController.swift in Sources */,
11541199 124D007F237222B200AE76B9 /* ReservationsResolver.swift in Sources */,
1200+ 129F163023CC8EF600EE13FC /* PhoneTextField.swift in Sources */,
1201+ 129F162C23CC8D2E00EE13FC /* AdminSecondStepReservationViewCoordinator.swift in Sources */,
11551202 12230AF723900D44004A01E5 /* EstablishmentResolver.swift in Sources */,
11561203 1246B719235CD3AD004CBFA1 /* NoReservationsView.swift in Sources */,
11571204 F3895F4A233D323700FA6A37 /* CodeCoordinator.swift in Sources */,
@@ -1186,6 +1233,7 @@
11861233 F3895F48233D2EEA00FA6A37 /* CodeSmsViewController.swift in Sources */,
11871234 12219CEF2353A63F0057DDEE /* ReservationsCoordinator.swift in Sources */,
11881235 12230AF423900BCB004A01E5 /* EstablishmentService.swift in Sources */,
1236+ 129F162723CC838200EE13FC /* AdminFirstStepReservationViewCoordinator.swift in Sources */,
11891237 12A07601237359BB00D749BB /* MapView1.swift in Sources */,
11901238 125AE5212395753400F847BD /* HFunc.swift in Sources */,
11911239 12BD95B8237EDB01009614D8 /* TimePointView.swift in Sources */,
@@ -1211,10 +1259,13 @@
12111259 12B3A7A323ABD594009E2FA6 /* AdminReservationsController.swift in Sources */,
12121260 F3FC7DCD2315BE610080D851 /* AppDelegate.swift in Sources */,
12131261 12838EB623677FB900CEF108 /* ApiRequest.swift in Sources */,
1262+ 1220A6FA23CDBE7E00365E36 /* AdminFinalStepReservationCoordinator.swift in Sources */,
12141263 12118B9E23682049006BAEE3 /* PhoneCodeResolver.swift in Sources */,
12151264 F30369BE2336924D00A8EA84 /* ClientTabbarCoordinator.swift in Sources */,
12161265 F3FC7DFD2315C4710080D851 /* BaseCoordinator.swift in Sources */,
1266+ 1220A6F723CDB64A00365E36 /* AdminSecondStepReservationViewController.swift in Sources */,
12171267 12E35071239FA8CA004BB188 /* Extensions+String.swift in Sources */,
1268+ 12FC07B923C8D17600EDC55B /* DeleteOtherAdminResolver.swift in Sources */,
12181269 F3DC59FF233E893400B5E751 /* Extensions+UIFont.swift in Sources */,
12191270 F3895F53233D5EEB00FA6A37 /* BlackButtonStyle.swift in Sources */,
12201271 12F9652C23868E7200FCA696 /* SecondStepView.swift in Sources */,
@@ -1228,13 +1279,14 @@
12281279 F3851B302340A513009EE0B6 /* RegistationViewModel.swift in Sources */,
12291280 12B3A7AF23AC1872009E2FA6 /* AdminNoReservationsView.swift in Sources */,
12301281 12838EAE2367701300CEF108 /* AuthorizationService.swift in Sources */,
1231− 12B3A7B723ACCD07009E2FA6 /* SettingsService.swift in Sources */,
12321282 12C72EDF23537D1B00AD7004 /* ProfileCoordinator.swift in Sources */,
12331283 12E3507D239FD1F3004BB188 /* ClientReservationsResolver.swift in Sources */,
12341284 12EA994E2362FCE8005D9FE9 /* AddressView.swift in Sources */,
1285+ 1220A6F423CDB1AD00365E36 /* GetClientByPhoneNumberResolver.swift in Sources */,
12351286 F3895F4C233D347E00FA6A37 /* PhoneNumberViewController.swift in Sources */,
12361287 12EE4A76234BB8FE005B4D1A /* CodeView.swift in Sources */,
12371288 12230AF123900974004A01E5 /* TotalStorage.swift in Sources */,
1289+ 1252D9E523CDCDB300446B6F /* ACreateReservationResolver.swift in Sources */,
12381290 12BD95B2237EC22B009614D8 /* FirstStepView.swift in Sources */,
12391291 F3EBE2472340FE87000FEE1A /* NameTextView.swift in Sources */,
12401292 120BFC7723891925001EBE89 /* ThirdStepReservationViewController.swift in Sources */,
@@ -1414,7 +1466,7 @@
14141466 buildSettings = {
14151467 ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
14161468 CODE_SIGN_STYLE = Automatic;
1417− CURRENT_PROJECT_VERSION = 3;
1469+ CURRENT_PROJECT_VERSION = 5;
14181470 DEVELOPMENT_TEAM = 23S94LRHD8;
14191471 INFOPLIST_FILE = "Hookah Tau/Info.plist";
14201472 IPHONEOS_DEPLOYMENT_TARGET = 11.0;
@@ -1434,7 +1486,7 @@
14341486 buildSettings = {
14351487 ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
14361488 CODE_SIGN_STYLE = Automatic;
1437− CURRENT_PROJECT_VERSION = 3;
1489+ CURRENT_PROJECT_VERSION = 5;
14381490 DEVELOPMENT_TEAM = 23S94LRHD8;
14391491 INFOPLIST_FILE = "Hookah Tau/Info.plist";
14401492 IPHONEOS_DEPLOYMENT_TARGET = 11.0;
Hookah Tau/API/APIClient.swift+2
@@ -48,6 +48,8 @@ class APIClient {
4848 let json = String(data: data, encoding: String.Encoding.utf8)
4949 print("Failure Response: \(String(describing: json))")
5050 }
51+ case 404:
52+ return GeneralError.notFound
5153 case 422:
5254 if let data = response.data, let error = SE.fromJSONToSelf(data: data) {
5355 print(error)
Hookah Tau/API/ClientsService/ClientsService.swift+46
@@ -80,4 +80,50 @@ class ClientsService {
8080 }
8181 }
8282 }
83+
84+ /// Метод для изменения статуса админки
85+ func changeAdmin(crud: CrudMethod, data: String, completion: @escaping ((Bool) -> Void)) {
86+ var resolver: ApiResolver!
87+ if crud == .put {
88+ resolver = AddOtherAdminResolver(phone: data)
89+ } else {
90+ resolver = DeleteOtherAdminResolver(uuid: data)
91+ }
92+
93+ let request = ApiRequest(resolver: resolver, httpMethod: crud)
94+
95+ apiClient.load(request: request.request) { result in
96+ switch result {
97+ case .failure:
98+ completion(false)
99+ return
100+ case .success:
101+ completion(true)
102+ return
103+ }
104+ }
105+ }
106+
107+ func getClientByPhoneNumber(userPhone: String, completion: @escaping ((Result<FullUser, GeneralError>) -> Void)) {
108+ let resolver = GetClientByPhoneNumberResolver<ClientInResponce>(userPhone: userPhone)
109+ let request = ApiRequest(resolver: resolver, httpMethod: .get)
110+
111+ apiClient.load(request: request.request) { (result) in
112+ switch result {
113+ case .failure(let err):
114+ completion(.failure(err))
115+ return
116+ case .success(let responce):
117+ guard
118+ let d = responce.data,
119+ let decData = resolver.targetClass().fromJSONToSelf(data: d)
120+ else {
121+ completion(.failure(GeneralError.decodeError))
122+ return
123+ }
124+
125+ completion(.success(decData.client))
126+ }
127+ }
128+ }
83129}
Hookah Tau/API/Settings/Resolvers/AddOtherAdminResolver.swift → Hookah Tau/API/ClientsService/Resolvers/AddOtherAdminResolver.swiftrenamed

The content is the same.

Hookah Tau/API/ClientsService/Resolvers/DeleteOtherAdminResolver.swiftnew file+35
@@ -0,0 +1,35 @@
1+//
2+// DeleteOtherAdminResolver.swift
3+// Hookah Tau
4+//
5+// Created by cstore on 10/01/2020.
6+// Copyright © 2020 Daria Rednikina. All rights reserved.
7+//
8+
9+import Foundation
10+
11+
12+class DeleteOtherAdminResolver: ApiResolver {
13+
14+ var name: String {
15+ return "/other"
16+ }
17+
18+ var groupName: String? {
19+ return "/admin"
20+ }
21+
22+ struct Request: MyCodable {
23+ let badAdmin: String
24+ }
25+
26+ let uuid: String
27+
28+ init(uuid: String) {
29+ self.uuid = uuid
30+ }
31+
32+ func parameters() -> MyCodable? {
33+ return Request(badAdmin: self.uuid)
34+ }
35+}
Hookah Tau/API/ClientsService/Resolvers/GetClientByPhoneNumberResolver.swiftnew file+35
@@ -0,0 +1,35 @@
1+//
2+// GetClientByPhoneNumberResolver.swift
3+// Hookah Tau
4+//
5+// Created by cstore on 14/01/2020.
6+// Copyright © 2020 Daria Rednikina. All rights reserved.
7+//
8+
9+import Foundation
10+
11+struct ClientInResponce: MyCodable {
12+ var client: FullUser
13+}
14+
15+/// `GET /admin/clients/by-phone/{user id}`
16+class GetClientByPhoneNumberResolver<Responce: MyCodable>: ApiResolver {
17+
18+ var name: String {
19+ return "/clients/by-phone/\(userPhone)"
20+ }
21+
22+ var groupName: String? {
23+ return "/admin"
24+ }
25+
26+ var userPhone: String
27+
28+ init(userPhone: String) {
29+ self.userPhone = userPhone
30+ }
31+
32+ func targetClass() -> Responce.Type {
33+ return Responce.self
34+ }
35+}
Hookah Tau/API/Reservations api/ReservationsService.swift+23
@@ -205,4 +205,27 @@ class ReservationsService {
205205 }
206206 }
207207 }
208+
209+ func createReservation(reservation: AdminCreateReservation, completion: @escaping ((Result<String, GeneralError>) -> Void)) {
210+ let resolver = ACreateReservationResolver<ACreateAdminResonce>(data: reservation)
211+ let request = ApiRequest(resolver: resolver, httpMethod: .post)
212+
213+ apiClient.load(request: request.request) { (res) in
214+ switch res {
215+ case .failure(let err):
216+ completion(.failure(err))
217+ return
218+ case .success(let responce):
219+ guard
220+ let d = responce.data,
221+ let decData = resolver.targetClass().fromJSONToSelf(data: d)
222+ else {
223+ completion(.failure(GeneralError.decodeError))
224+ return
225+ }
226+
227+ completion(.success(decData.reservationUUID))
228+ }
229+ }
230+ }
208231}
Hookah Tau/API/Reservations api/Resolvers/Admin/ACreateReservationResolver.swiftnew file+37
@@ -0,0 +1,37 @@
1+//
2+// ACreateReservationResolver.swift
3+// Hookah Tau
4+//
5+// Created by cstore on 14/01/2020.
6+// Copyright © 2020 Daria Rednikina. All rights reserved.
7+//
8+
9+import Foundation
10+
11+struct ACreateAdminResonce: MyCodable {
12+ var reservationUUID: String
13+}
14+
15+class ACreateReservationResolver<Responce: MyCodable>: ApiResolver {
16+ var name: String {
17+ return "/reservations"
18+ }
19+
20+ var groupName: String? {
21+ return "/admin"
22+ }
23+
24+ var data: AdminCreateReservation
25+
26+ init(data: AdminCreateReservation) {
27+ self.data = data
28+ }
29+
30+ func parameters() -> MyCodable? {
31+ return data
32+ }
33+
34+ func targetClass() -> Responce.Type {
35+ return Responce.self
36+ }
37+}
Hookah Tau/API/ServerError.swift+1
@@ -16,6 +16,7 @@ enum GeneralError: Error {
1616 case serverError(SE)
1717 case decodeError
1818 case noData
19+ case notFound
1920 case Error400
2021 case somethingWentCompletelyWrong
2122 case alamofireError
Hookah Tau/API/Settings/SettingsService.swiftdeleted−34
@@ -1,34 +0,0 @@
1−//
2−// AdminServise.swift
3−// Hookah Tau
4−//
5−// Created by cstore on 20/12/2019.
6−// Copyright © 2019 Daria Rednikina. All rights reserved.
7−//
8−
9−import Foundation
10−
11−class SettingsService {
12−
13− private var apiClient: APIClient
14−
15− init(apiClient: APIClient) {
16− self.apiClient = apiClient
17− }
18−
19− func addOtherAdmin(phone: String, completion: @escaping ((Bool) -> Void)) {
20− let resolver = AddOtherAdminResolver(phone: phone)
21− let request = ApiRequest(resolver: resolver, httpMethod: .put)
22−
23− apiClient.load(request: request.request) { result in
24− switch result {
25− case .failure:
26− completion(false)
27− return
28− case .success:
29− completion(true)
30− return
31− }
32− }
33− }
34−}
Hookah Tau/Components/PhoneTextField.swiftnew file+63
@@ -0,0 +1,63 @@
1+//
2+// PhoneTextField.swift
3+// Hookah Tau
4+//
5+// Created by cstore on 13/01/2020.
6+// Copyright © 2020 Daria Rednikina. All rights reserved.
7+//
8+
9+import UIKit
10+
11+class PhoneTextField: UITextField, UITextFieldDelegate {
12+
13+ override func awakeFromNib() {
14+ super.awakeFromNib()
15+
16+ self.delegate = self
17+ self.keyboardType = .numberPad
18+ }
19+
20+ func bind(withModel model: String) {
21+ self.text = model.formattedNumber()
22+ }
23+
24+ func textField(_ textField: UITextField, shouldChangeCharactersIn range: NSRange, replacementString string: String) -> Bool {
25+ let newString = (textField.text! as NSString).replacingCharacters(in: range, with: string)
26+ textField.text = formattedNumber(newString)
27+ return false
28+ }
29+
30+ private func formattedNumber(_ number: String) -> String {
31+ let cleanPhoneNumber = number.components(separatedBy: CharacterSet.decimalDigits.inverted).joined()
32+
33+ var result = ""
34+ let phoneMask = "+X (XXX) XXX XX XX"
35+ var index = cleanPhoneNumber.startIndex
36+ for ch in phoneMask where index < cleanPhoneNumber.endIndex {
37+ if ch == "X" {
38+ result.append(cleanPhoneNumber[index])
39+ index = cleanPhoneNumber.index(after: index)
40+ } else {
41+ result.append(ch)
42+ }
43+ }
44+ return result
45+ }
46+
47+ /// +o (oxx) xxx xx xx
48+ ///
49+ /// need tor return only `x`, length is 9. And it has to have prefix +7 (9...) or +8 (9..)
50+ func getFormattedNumber() -> String? {
51+ guard let number = self.text else { return nil }
52+
53+ let cleanPhoneNumber = String(number.components(separatedBy: CharacterSet.decimalDigits.inverted).joined())
54+ let hasPrefix = cleanPhoneNumber.hasPrefix("79") || cleanPhoneNumber.hasPrefix("89")
55+
56+ let result = String(cleanPhoneNumber.dropFirst(2))
57+ if result.count == 9 && hasPrefix {
58+ return result
59+ }
60+
61+ return nil
62+ }
63+}
Hookah Tau/Controllers/Admin/Clients/Cells/ClientTableViewCell.swift+7−5
@@ -20,9 +20,11 @@ class ClientTableViewCell: UITableViewCell {
2020
2121 @IBOutlet weak var numberOfReservationsLabel: UILabel!
2222
23− @IBOutlet weak var blockListImage: UIImageView!
2423
25− @IBOutlet weak var isAdminImage: UIImageView!
24+ @IBOutlet weak var blockListLabel: UILabel!
25+
26+ @IBOutlet weak var isAdminLabel: UILabel!
27+
2628
2729
2830 // MARK: - Lifecycle
@@ -41,11 +43,11 @@ class ClientTableViewCell: UITableViewCell {
4143 // MARK: - Bind
4244
4345 func bind(withModel model: Client) {
44− blockListImage.isHidden = !model.isBlocked
45− isAdminImage.isHidden = !model.isAdmin
46+ blockListLabel.isHidden = !model.isBlocked
47+ isAdminLabel.isHidden = !model.isAdmin
4648 nameLabel.text = model.name ?? "❔"
4749 phoneNumberLabel.text = model.phoneNumber.formattedNumber()
48− numberOfReservationsLabel.text = "\(model.reservationCount)"
50+ numberOfReservationsLabel.text = model.reservationCount > 99 ? "99+" : "\(model.reservationCount)"
4951 }
5052
5153}
Hookah Tau/Controllers/Admin/Clients/ClientList.storyboard+25−26
@@ -34,7 +34,7 @@
3434 <stackView opaque="NO" contentMode="scaleToFill" distribution="equalSpacing" alignment="center" spacingType="standard" translatesAutoresizingMaskIntoConstraints="NO" id="uoO-w2-5yG">
3535 <rect key="frame" x="0.0" y="0.0" width="78.5" height="26.5"/>
3636 <subviews>
37− <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Стасик" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="4Cp-jh-0Gq">
37+ <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Стасик" textAlignment="natural" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="4Cp-jh-0Gq">
3838 <rect key="frame" x="0.0" y="0.0" width="78.5" height="26.5"/>
3939 <fontDescription key="fontDescription" type="boldSystem" pointSize="22"/>
4040 <color key="textColor" white="0.0" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
@@ -51,32 +51,30 @@
5151 </subviews>
5252 </stackView>
5353 <stackView opaque="NO" contentMode="scaleToFill" alignment="center" spacingType="standard" translatesAutoresizingMaskIntoConstraints="NO" id="tJg-ju-bFY">
54− <rect key="frame" x="215.5" y="0.0" width="127.5" height="53"/>
54+ <rect key="frame" x="219.5" y="0.0" width="123.5" height="53"/>
5555 <subviews>
56− <stackView opaque="NO" contentMode="scaleToFill" spacing="40" translatesAutoresizingMaskIntoConstraints="NO" id="4et-BC-7iY">
57− <rect key="frame" x="0.0" y="14" width="107.5" height="25"/>
56+ <stackView opaque="NO" contentMode="scaleToFill" distribution="equalSpacing" spacingType="standard" translatesAutoresizingMaskIntoConstraints="NO" id="4et-BC-7iY">
57+ <rect key="frame" x="0.0" y="14.5" width="103.5" height="24"/>
5858 <subviews>
5959 <stackView opaque="NO" contentMode="scaleToFill" spacing="5" translatesAutoresizingMaskIntoConstraints="NO" id="BHD-cD-L1c">
60− <rect key="frame" x="0.0" y="0.0" width="55" height="25"/>
60+ <rect key="frame" x="0.0" y="0.0" width="51" height="24"/>
6161 <subviews>
62− <imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="blacklist" translatesAutoresizingMaskIntoConstraints="NO" id="yw1-jl-Iil">
63− <rect key="frame" x="0.0" y="0.0" width="25" height="25"/>
64− <constraints>
65− <constraint firstAttribute="width" constant="25" id="k7r-sC-Yro"/>
66− <constraint firstAttribute="height" constant="25" id="kjF-aV-kTo"/>
67− </constraints>
68− </imageView>
69− <imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="admin" translatesAutoresizingMaskIntoConstraints="NO" id="Tlq-hK-YHS">
70− <rect key="frame" x="30" y="0.0" width="25" height="25"/>
71− <constraints>
72− <constraint firstAttribute="width" constant="25" id="NSy-Ih-fCV"/>
73− <constraint firstAttribute="height" constant="25" id="nOu-SF-8Yd"/>
74− </constraints>
75− </imageView>
62+ <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="❌" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="MaQ-TW-666">
63+ <rect key="frame" x="0.0" y="0.0" width="23" height="24"/>
64+ <fontDescription key="fontDescription" type="system" pointSize="17"/>
65+ <nil key="textColor"/>
66+ <nil key="highlightedColor"/>
67+ </label>
68+ <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="👑" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="0Xa-FL-GVr">
69+ <rect key="frame" x="28" y="0.0" width="23" height="24"/>
70+ <fontDescription key="fontDescription" type="system" pointSize="17"/>
71+ <nil key="textColor"/>
72+ <nil key="highlightedColor"/>
73+ </label>
7674 </subviews>
7775 </stackView>
78− <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="3" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Gzo-kW-60Z">
79− <rect key="frame" x="95" y="0.0" width="12.5" height="25"/>
76+ <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="99+" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Gzo-kW-60Z">
77+ <rect key="frame" x="66" y="0.0" width="37.5" height="24"/>
8078 <fontDescription key="fontDescription" type="system" pointSize="20"/>
8179 <nil key="textColor"/>
8280 <nil key="highlightedColor"/>
@@ -84,9 +82,12 @@
8482 </subviews>
8583 </stackView>
8684 <imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="arrow" translatesAutoresizingMaskIntoConstraints="NO" id="DrQ-Ss-gIT">
87− <rect key="frame" x="115.5" y="16.5" width="12" height="20"/>
85+ <rect key="frame" x="111.5" y="16.5" width="12" height="20"/>
8886 </imageView>
8987 </subviews>
88+ <constraints>
89+ <constraint firstAttribute="width" constant="123.5" id="eeb-nt-pTB"/>
90+ </constraints>
9091 </stackView>
9192 </subviews>
9293 </stackView>
@@ -99,8 +100,8 @@
99100 </constraints>
100101 </tableViewCellContentView>
101102 <connections>
102− <outlet property="blockListImage" destination="yw1-jl-Iil" id="p09-KQ-ayQ"/>
103− <outlet property="isAdminImage" destination="Tlq-hK-YHS" id="KZP-yS-8YQ"/>
103+ <outlet property="blockListLabel" destination="MaQ-TW-666" id="Us0-tw-9tj"/>
104+ <outlet property="isAdminLabel" destination="0Xa-FL-GVr" id="fzz-2t-Lda"/>
104105 <outlet property="nameLabel" destination="4Cp-jh-0Gq" id="g6e-c0-x0u"/>
105106 <outlet property="numberOfReservationsLabel" destination="Gzo-kW-60Z" id="9J2-S4-fKq"/>
106107 <outlet property="phoneNumberLabel" destination="0gY-h5-AV2" id="rdb-GS-ceF"/>
@@ -190,8 +191,6 @@
190191 </scene>
191192 </scenes>
192193 <resources>
193− <image name="admin" width="26" height="25"/>
194194 <image name="arrow" width="12" height="20"/>
195− <image name="blacklist" width="25" height="25"/>
196195 </resources>
197196</document>
Hookah Tau/Controllers/Admin/Clients/ClientsCoordinator.swift+1−4
@@ -23,10 +23,7 @@ class ClientsCoordinator: BaseCoordinator {
2323 /// TODO
2424 func openUserProfile(_ profile: Client) {
2525 let profileCoordinator = ClientProfileCoordinator(navigationController: navigationController)
26− profileCoordinator.user = FullUser(uuid: profile.uuid,
27− name: profile.name,
28− phoneNumber: profile.phoneNumber,
29− isAdmin: profile.isAdmin)
26+ profileCoordinator.user = profile
3027
3128 self.addDependency(profileCoordinator)
3229 profileCoordinator.didEndFlow = {
Hookah Tau/Controllers/Admin/Clients/ClientsViewController.swift+92−6
@@ -18,16 +18,29 @@ class ClientsViewController: BaseTableViewController {
1818 }
1919 }
2020
21+ var filteredDataSource: [Client] = []
22+
2123 var clientsService: ClientsService?
2224
2325 weak var coordinator: ClientsCoordinator?
2426
27+ var searchControl: UISearchController?
28+
29+ var isFiltering: Bool {
30+ return searchControl?.isActive ?? false && !searchBarIsEmpty()
31+ }
32+
33+ func searchBarIsEmpty() -> Bool {
34+ return searchControl?.searchBar.text?.isEmpty ?? true
35+ }
36+
2537 // MARK: - Lifecycle
2638
2739 override func viewDidLoad() {
2840 super.viewDidLoad()
2941
3042 setupNavigationBar()
43+ setupSearchController()
3144 clientsService = ClientsService(apiClient: APIClient.shared)
3245 }
3346
@@ -49,6 +62,15 @@ class ClientsViewController: BaseTableViewController {
4962 navigationItem.rightBarButtonItem = UIBarButtonItem(barButtonSystemItem: .action, target: self, action: #selector(shareCSVFile))
5063 }
5164
65+ func setupSearchController() {
66+ searchControl = UISearchController(searchResultsController: nil)
67+ navigationItem.searchController = searchControl
68+ navigationItem.hidesSearchBarWhenScrolling = false
69+ searchControl?.obscuresBackgroundDuringPresentation = false
70+ definesPresentationContext = true
71+ searchControl?.searchResultsUpdater = self
72+ }
73+
5274 // MARK: - Api calls
5375
5476 /// Загружаем клиентов кальянки
@@ -100,7 +122,17 @@ class ClientsViewController: BaseTableViewController {
100122 if res {
101123 self.tableView?.beginUpdates()
102124 self.tableView?.reloadRows(at: [indexPath], with: .automatic)
103− self.dataSource[indexPath.row].isBlocked = !wasBlocked
125+ if self.isFiltering {
126+ self.filteredDataSource[indexPath.row].isBlocked = !wasBlocked
127+ let changed = self.filteredDataSource[indexPath.row]
128+ let filtered = self.dataSource.map { (one: Client) -> Client in
129+ if one.uuid == changed.uuid {
130+ return changed
131+ } else { return one } }
132+ self.dataSource = filtered
133+ } else {
134+ self.dataSource[indexPath.row].isBlocked = !wasBlocked
135+ }
104136 self.tableView?.endUpdates()
105137 } else {
106138 self.displayAlert(with: "Не удалось \(wasBlocked ? "удалить" : "добавить") пользователя \(wasBlocked ? "из" : "в") чс! Попробуйте еще раз!")
@@ -108,6 +140,35 @@ class ClientsViewController: BaseTableViewController {
108140 }
109141 })
110142 }
143+
144+ func updateAdminStatus(user: Client, indexPath: IndexPath) {
145+
146+ let wasAdmin = user.isAdmin
147+ let crudMethod = wasAdmin ? CrudMethod.delete : CrudMethod.put
148+ let data = user.isAdmin ? user.uuid : user.phoneNumber
149+
150+ clientsService?.changeAdmin(crud: crudMethod, data: data, completion: { (res) in
151+ if res {
152+ self.tableView?.beginUpdates()
153+ self.tableView?.reloadRows(at: [indexPath], with: .automatic)
154+ if self.isFiltering {
155+ self.filteredDataSource[indexPath.row].isAdmin = !wasAdmin
156+ let changed = self.filteredDataSource[indexPath.row]
157+ let filtered = self.dataSource.map { (one: Client) -> Client in
158+ if one.uuid == changed.uuid {
159+ return changed
160+ } else { return one } }
161+ self.dataSource = filtered
162+ } else {
163+ self.dataSource[indexPath.row].isAdmin = !wasAdmin
164+ }
165+ self.tableView?.endUpdates()
166+ } else {
167+ self.displayAlert(with: "Не удалось \(wasAdmin ? "распромоутить" : "запромоутить") пользователя! Попробуйте еще раз!")
168+ return
169+ }
170+ })
171+ }
111172}
112173
113174// MARK: - Tableview
@@ -117,19 +178,20 @@ extension ClientsViewController {
117178 override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
118179 let cell = tableView.dequeueReusableCell(withIdentifier: clientTableViewCellId, for: indexPath) as! ClientTableViewCell
119180
120− let userModel = dataSource[indexPath.row]
181+ let userModel = isFiltering ? filteredDataSource[indexPath.row] : dataSource[indexPath.row]
121182 cell.bind(withModel: userModel)
122183
123184 return cell
124185 }
125186
126187 override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
127− return dataSource.count
188+ return isFiltering ? filteredDataSource.count : dataSource.count
128189 }
129190
130191 override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
131− let user = dataSource[indexPath.row]
192+ let user = isFiltering ? filteredDataSource[indexPath.row] : dataSource[indexPath.row]
132193 coordinator?.openUserProfile(user)
194+ searchControl?.dismiss(animated: true, completion: nil)
133195 }
134196
135197 // Update
@@ -140,8 +202,8 @@ extension ClientsViewController {
140202
141203 override func tableView(_ tableView: UITableView, editActionsForRowAt indexPath: IndexPath) -> [UITableViewRowAction]? {
142204
143− let user = dataSource[indexPath.row]
144− let blockButton = UITableViewRowAction(style: .normal, title: "\(!user.isBlocked ? "🙅🏻‍♀️" : "👍🏻")") { _,_ in
205+ let user = isFiltering ? filteredDataSource[indexPath.row] : dataSource[indexPath.row]
206+ let blockButton = UITableViewRowAction(style: .normal, title: "\(!user.isBlocked ? "в чс" : "убрать из чс")") { _,_ in
145207
146208 self.updateUserBlockStatus(wasBlocked: user.isBlocked, phone: user.phoneNumber, indexPath: indexPath)
147209 }
@@ -150,4 +212,28 @@ extension ClientsViewController {
150212
151213 return [blockButton]
152214 }
215+
216+ override func tableView(_ tableView: UITableView, leadingSwipeActionsConfigurationForRowAt indexPath: IndexPath) -> UISwipeActionsConfiguration? {
217+
218+ let user = isFiltering ? filteredDataSource[indexPath.row] : dataSource[indexPath.row]
219+
220+ let promote = UIContextualAction(style: .normal, title: "\(!user.isAdmin ? "дать админку" : "забрать админку")") { (_, _, _) in
221+ self.updateAdminStatus(user: user, indexPath: indexPath)
222+ }
223+ promote.backgroundColor = .black
224+
225+ return UISwipeActionsConfiguration(actions: [promote])
226+ }
227+}
228+
229+extension ClientsViewController: UISearchResultsUpdating {
230+ func filterContentForSearchText(_ searchText: String, scope: String = "All")
231+ {
232+ filteredDataSource = dataSource.filter { ($0.name?.lowercased().contains(searchText.lowercased()) ?? false) || ($0.phoneNumber.lowercased().contains(searchText.lowercased())) }
233+ tableView.reloadData()
234+ }
235+
236+ func updateSearchResults(for searchController: UISearchController) {
237+ filterContentForSearchText(searchController.searchBar.text ?? "")
238+ }
153239}
Hookah Tau/Controllers/Admin/Clients/Profile/ClientProfileCoordinator.swift+12−2
@@ -11,7 +11,7 @@ import UIKit
1111
1212class ClientProfileCoordinator: BaseCoordinator {
1313
14− var user: FullUser?
14+ var user: Client?
1515
1616 override func start() {
1717 let storyboard = UIStoryboard(name: "ClientList", bundle: nil)
@@ -24,8 +24,18 @@ class ClientProfileCoordinator: BaseCoordinator {
2424
2525
2626 // Создание бронирования из профиля клиента
27− func createReservation(forUserWithPhone phoneNumber: String) {
27+ func createReservation(forUserWithPhone phoneNumber: String, user fullUser: FullUser) {
28+ let coordinator = AdminFirstStepReservationViewCoordinator(navigationController: navigationController)
29+ coordinator.phone = phoneNumber
30+ coordinator.fullUser = fullUser
2831
32+ addDependency(coordinator)
33+ coordinator.didFinish = { [weak self] in
34+ self?.removeDependency(coordinator)
35+ self?.navigationController?.popViewController(animated: true)
36+ }
37+
38+ coordinator.start()
2939 }
3040
3141 // Просмотр (и редактирование) брони
Hookah Tau/Controllers/Admin/Clients/Profile/ProfileTableViewController.swift+22−6
@@ -41,7 +41,7 @@ class ProfileTableViewController: BaseViewController {
4141
4242 var reservationsService: ReservationsService?
4343
44− var user: FullUser?
44+ var user: Client?
4545
4646 weak var coodinator: ClientProfileCoordinator?
4747
@@ -79,19 +79,25 @@ class ProfileTableViewController: BaseViewController {
7979 setupNavBar()
8080 setupTable()
8181 setupActivityIndicator()
82− loadReservations()
82+ //loadReservations()
8383 }
8484
8585 override func viewWillAppear(_ animated: Bool) {
86− super.viewDidAppear(animated)
86+ super.viewWillAppear(animated)
8787 tabBarController?.tabBar.isHidden = true
8888 }
8989
90+ override func viewDidAppear(_ animated: Bool) {
91+ super.viewDidAppear(animated)
92+ loadReservations()
93+ }
94+
9095 // MARK: - Setup
9196
9297 func setupNavBar() {
9398 guard let u = user else { return }
94− navigationItem.title = u.name
99+
100+ navigationItem.title = "\(u.name ?? "❔")\(u.isAdmin ? "👑" : "")\(u.isBlocked ? "❌" : "")"
95101 navigationItem.rightBarButtonItem = UIBarButtonItem(barButtonSystemItem: .add, target: self, action: #selector(book))
96102 }
97103
@@ -182,7 +188,16 @@ class ProfileTableViewController: BaseViewController {
182188 }
183189
184190 @objc func book() {
191+ guard
192+ let phone = user?.phoneNumber,
193+ let user = user
194+ else { return }
185195
196+ let fullUser = FullUser(uuid: user.uuid,
197+ name: user.name,
198+ phoneNumber: user.phoneNumber,
199+ isAdmin: user.isAdmin)
200+ coodinator?.createReservation(forUserWithPhone: phone, user: fullUser)
186201 }
187202}
188203
@@ -207,7 +222,8 @@ extension ProfileTableViewController: UITableViewDelegate, UITableViewDataSource
207222 func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
208223 guard let u = user else { return }
209224 let r = dataSource[indexPath.row]
210− let reservation = ReservationWithUser(reservation: r, user: u)
225+ let user = FullUser(uuid: u.uuid, name: u.name, phoneNumber: u.phoneNumber, isAdmin: u.isAdmin)
226+ let reservation = ReservationWithUser(reservation: r, user: user)
211227 coodinator?.seeExistingReservation(data: reservation)
212228 }
213229
@@ -220,7 +236,7 @@ extension ProfileTableViewController: UITableViewDelegate, UITableViewDataSource
220236 func tableView(_ tableView: UITableView, editActionsForRowAt indexPath: IndexPath) -> [UITableViewRowAction]? {
221237
222238 let uuid = dataSource[indexPath.row].uuid
223− let cancelButton = UITableViewRowAction(style: .normal, title: "❌") { _,_ in
239+ let cancelButton = UITableViewRowAction(style: .normal, title: "отменить бронь") { _,_ in
224240
225241 self.deleteReservation(uuid: uuid) { optionalNewVal in
226242 if let newval = optionalNewVal {
Hookah Tau/Controllers/Admin/Reservations/AdminReservationEditingCoordinator.swift+3−1
@@ -9,10 +9,12 @@
99import UIKit
1010
1111
12−class AdminReservationEditingCoordinator: BaseCoordinator {
12+class AdminReservationEditingCoordinator: BaseCoordinator, ShowReservationCoordinator {
1313
1414 // MARK: - Peoperties
1515
16+ var didFinish: (() -> Void)?
17+
1618 var reservationData: ReservationWithUser?
1719
1820 // MARK: - Lifecycle
Hookah Tau/Controllers/Admin/Reservations/AdminReservationEditingViewController.swift+52−21
@@ -24,22 +24,17 @@ class AdminReservationEditingViewController: BaseViewController {
2424
2525 var reservationData: ReservationWithUser?
2626
27− weak var coordinator: AdminReservationEditingCoordinator?
27+ weak var coordinator: ShowReservationCoordinator?
2828
2929 var reservationService: ReservationsService?
3030
3131 var reservedPeriods: [ReservationPeriod] = [] {
3232 didSet {
33− setupReservationViewWithIntervals()
33+ if let _ = reservationView {
34+ setupReservationViewWithIntervals()
35+ }
3436 }
3537 }
36−
37− var saveButton: Button = {
38− let button = Button()
39− let style = BlackButtonStyle()
40− style.apply(to: button, withTitle: "СОХРАНИТЬ")
41− return button
42− }()
4338
4439 // MARK:- Lifecycle
4540
@@ -64,10 +59,8 @@ class AdminReservationEditingViewController: BaseViewController {
6459 // MARK: - Setup
6560
6661 func setupButtons() {
67− addStackViewWithButtons(rightBtn: saveButton,
68− constant: -mainContentView.frame.height - 10)
6962
70− saveButton.addTarget(self, action: #selector(saveReservation), for: .touchUpInside)
63+ reservationView?.saveButton?.addTarget(self, action: #selector(saveReservation), for: .touchUpInside)
7164 reservationView?.cancelButton?.addTarget(self, action: #selector(cancelReservation), for: .touchUpInside)
7265 }
7366
@@ -100,9 +93,14 @@ class AdminReservationEditingViewController: BaseViewController {
10093 }
10194
10295 func loadReservedPeriods() {
103− guard let model = reservationData else { return }
96+ guard
97+ let model = reservationData,
98+ let uuid = model.uuid
99+ else {
100+ setupReservationViewWithIntervals()
101+ return }
104102
105− reservationService?.getReservationsAround(uuid: model.uuid, completion: { [weak self] (res) in
103+ reservationService?.getReservationsAround(uuid: uuid, completion: { [weak self] (res) in
106104 switch res {
107105 case .failure(let err):
108106 self?.displayAlert(forError: err)
@@ -120,9 +118,12 @@ class AdminReservationEditingViewController: BaseViewController {
120118 guard
121119 let r = reservationView?.data,
122120 let uuid = reservationData?.uuid
123− else { return }
121+ else {
122+ createReservation()
123+ return
124+ }
124125
125− saveButton.loading = true
126+ reservationView?.saveButton?.loading = true
126127
127128 reservationService?.updateReservation(startTime: r.startTime,
128129 numberOfGuests: r.numberOfGuests,
@@ -131,26 +132,56 @@ class AdminReservationEditingViewController: BaseViewController {
131132 isAdmin: true,
132133 completion: { [weak self] (res) in
133134 if res {
134− self?.coordinator?.didEndFlow?()
135+ self?.coordinator?.didFinish?()
135136 } else {
136137 self?.displayAlert(with: "Что-то пошло не так! Попробуешь еще раз?")
137138 }
138139
139− self?.saveButton.loading = false
140+ self?.reservationView?.saveButton?.loading = false
141+ })
142+ }
143+
144+ func createReservation() {
145+ guard
146+ let r = reservationData,
147+ let d = reservationData?.owner.phoneNumber else { return }
148+
149+ let data = ReservationData(establishment: r.establishment,
150+ startTime: r.startTime,
151+ endTime: r.endTime,
152+ numberOfGuests: r.numberOfGuests,
153+ reservedTable: r.reservedTable)
154+ print(data)
155+ reservationService?.createReservation(reservation: AdminCreateReservation(reservation: data, user: d), completion: { (res) in
156+ switch res {
157+ case .failure(_):
158+ self.displayAlert(with: "Что-то пошло не так!\nПопробуешь еще раз?")
159+ return
160+ case .success(let uuid):
161+ self.reservationData?.uuid = uuid
162+ self.coordinator?.didFinish?()
163+ return
164+ }
140165 })
141166 }
142167
143168 @objc func cancelReservation() {
144169 guard
145− let uuid = reservationData?.uuid
146− else { return }
170+ let uuid = reservationData?.uuid
171+ else {
172+ cancelPrereservation()
173+ return }
147174
148175 reservationService?.deleteReservation(isAdmin: true, uuid: uuid, completion: { [weak self] (res) in
149176 if res {
150− self?.coordinator?.didEndFlow?()
177+ self?.coordinator?.didFinish?()
151178 } else {
152179 self?.displayAlert(with: "Что-то пошло не так!\nПопробуешь еще раз?")
153180 }
154181 })
155182 }
183+
184+ func cancelPrereservation() {
185+ coordinator?.didFinish?()
186+ }
156187}
Hookah Tau/Controllers/Admin/Reservations/AdminReservations.storyboard+67−3
@@ -32,14 +32,14 @@
3232 <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
3333 <subviews>
3434 <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="uNU-TW-vfq">
35− <rect key="frame" x="0.0" y="206" width="375" height="441"/>
35+ <rect key="frame" x="0.0" y="262" width="375" height="385"/>
3636 <color key="backgroundColor" white="0.66666666666666663" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
3737 <constraints>
38− <constraint firstAttribute="height" constant="441" id="wfZ-i9-ruU"/>
38+ <constraint firstAttribute="height" constant="385" id="wfZ-i9-ruU"/>
3939 </constraints>
4040 </view>
4141 <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="ghQ-Jv-1Uo">
42− <rect key="frame" x="0.0" y="0.0" width="375" height="198"/>
42+ <rect key="frame" x="0.0" y="0.0" width="375" height="254"/>
4343 <color key="backgroundColor" systemColor="systemGreenColor" red="0.20392156859999999" green="0.78039215689999997" blue="0.34901960780000002" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
4444 </view>
4545 </subviews>
@@ -64,5 +64,69 @@
6464 </objects>
6565 <point key="canvasLocation" x="959.20000000000005" y="158.77061469265368"/>
6666 </scene>
67+ <!--Admin Second Step Reservation View Controller-->
68+ <scene sceneID="VhI-Z9-iqB">
69+ <objects>
70+ <viewController storyboardIdentifier="AdminSecondStepReservationViewController" id="eNJ-Ja-201" customClass="AdminSecondStepReservationViewController" customModule="Hookah_Tau" customModuleProvider="target" sceneMemberID="viewController">
71+ <view key="view" contentMode="scaleToFill" id="7mk-5I-JJs">
72+ <rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
73+ <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
74+ <subviews>
75+ <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="oAV-GW-iea">
76+ <rect key="frame" x="0.0" y="0.0" width="375" height="293"/>
77+ <color key="backgroundColor" systemColor="systemIndigoColor" red="0.34509803919999998" green="0.33725490200000002" blue="0.83921568629999999" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
78+ </view>
79+ <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="a4v-ng-lm7">
80+ <rect key="frame" x="0.0" y="293" width="375" height="374"/>
81+ <subviews>
82+ <stackView opaque="NO" contentMode="scaleToFill" axis="vertical" alignment="center" spacing="13" translatesAutoresizingMaskIntoConstraints="NO" id="1Bb-cO-4qW">
83+ <rect key="frame" x="20" y="22" width="335" height="88.5"/>
84+ <subviews>
85+ <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Номер клиента" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="bME-Wr-gh7">
86+ <rect key="frame" x="62.5" y="0.0" width="210.5" height="33.5"/>
87+ <fontDescription key="fontDescription" type="boldSystem" pointSize="28"/>
88+ <nil key="textColor"/>
89+ <nil key="highlightedColor"/>
90+ </label>
91+ <textField opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" borderStyle="roundedRect" placeholder="+7 (988) 888-88-88" textAlignment="natural" minimumFontSize="28" translatesAutoresizingMaskIntoConstraints="NO" id="wBC-oa-ekQ" customClass="PhoneTextField" customModule="Hookah_Tau" customModuleProvider="target">
92+ <rect key="frame" x="13.5" y="46.5" width="308.5" height="42"/>
93+ <fontDescription key="fontDescription" type="boldSystem" pointSize="28"/>
94+ <textInputTraits key="textInputTraits"/>
95+ </textField>
96+ </subviews>
97+ </stackView>
98+ </subviews>
99+ <color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
100+ <constraints>
101+ <constraint firstItem="1Bb-cO-4qW" firstAttribute="top" secondItem="a4v-ng-lm7" secondAttribute="top" constant="22" id="7fb-Up-Wmb"/>
102+ <constraint firstAttribute="trailing" secondItem="1Bb-cO-4qW" secondAttribute="trailing" constant="20" id="934-Ef-0xf"/>
103+ <constraint firstItem="1Bb-cO-4qW" firstAttribute="leading" secondItem="a4v-ng-lm7" secondAttribute="leading" constant="20" id="sr5-aO-q1p"/>
104+ <constraint firstAttribute="height" constant="374" id="uRW-2Q-OyM"/>
105+ </constraints>
106+ </view>
107+ </subviews>
108+ <color key="backgroundColor" systemColor="systemBackgroundColor" cocoaTouchSystemColor="whiteColor"/>
109+ <constraints>
110+ <constraint firstItem="a4v-ng-lm7" firstAttribute="leading" secondItem="8aV-w1-NXE" secondAttribute="leading" id="OjU-Pl-gu1"/>
111+ <constraint firstItem="oAV-GW-iea" firstAttribute="trailing" secondItem="8aV-w1-NXE" secondAttribute="trailing" id="bPj-q1-pY6"/>
112+ <constraint firstItem="oAV-GW-iea" firstAttribute="top" secondItem="8aV-w1-NXE" secondAttribute="top" id="gUc-es-YHL"/>
113+ <constraint firstItem="a4v-ng-lm7" firstAttribute="bottom" secondItem="8aV-w1-NXE" secondAttribute="bottom" id="hZH-fU-zM5"/>
114+ <constraint firstItem="oAV-GW-iea" firstAttribute="leading" secondItem="8aV-w1-NXE" secondAttribute="leading" id="mos-8B-wjS"/>
115+ <constraint firstItem="a4v-ng-lm7" firstAttribute="trailing" secondItem="8aV-w1-NXE" secondAttribute="trailing" id="ntK-1r-AUW"/>
116+ <constraint firstItem="a4v-ng-lm7" firstAttribute="top" secondItem="oAV-GW-iea" secondAttribute="bottom" id="siv-Xa-Nl5"/>
117+ </constraints>
118+ <viewLayoutGuide key="safeArea" id="8aV-w1-NXE"/>
119+ </view>
120+ <connections>
121+ <outlet property="heightConstraint" destination="uRW-2Q-OyM" id="fmn-uI-ooi"/>
122+ <outlet property="mapContainerView" destination="oAV-GW-iea" id="jmP-q0-WbS"/>
123+ <outlet property="phoneContentView" destination="a4v-ng-lm7" id="W1O-A7-6EP"/>
124+ <outlet property="phoneTextField" destination="wBC-oa-ekQ" id="Btg-A3-tpm"/>
125+ </connections>
126+ </viewController>
127+ <placeholder placeholderIdentifier="IBFirstResponder" id="hNg-aQ-v7C" userLabel="First Responder" customClass="UIResponder" sceneMemberID="firstResponder"/>
128+ </objects>
129+ <point key="canvasLocation" x="1664.8" y="158.77061469265368"/>
130+ </scene>
67131 </scenes>
68132</document>
Hookah Tau/Controllers/Admin/Reservations/List of reservations/AdminReservationsController.swift+4−3
@@ -123,7 +123,8 @@ class AdminReservationsController: BaseViewController {
123123 // MARK:- Button handler
124124
125125 @objc func book() {
126−
126+ guard let establishmentId = id else { return }
127+ coordinator?.book(inEstablishment: establishmentId)
127128 }
128129
129130 func deleteReservation(uuid: String, completion: @escaping (([ReservationWithUser]?) -> Void)) {
@@ -195,8 +196,8 @@ extension AdminReservationsController: UITableViewDelegate, UITableViewDataSourc
195196
196197 func tableView(_ tableView: UITableView, editActionsForRowAt indexPath: IndexPath) -> [UITableViewRowAction]? {
197198
198− let uuid = activeReservations[indexPath.row].uuid
199− let cancelButton = UITableViewRowAction(style: .normal, title: "❌") { _,_ in
199+ guard let uuid = activeReservations[indexPath.row].uuid else { return [] }
200+ let cancelButton = UITableViewRowAction(style: .normal, title: "отменить бронь") { _,_ in
200201
201202 self.deleteReservation(uuid: uuid) { optionalNewVal in
202203 if let newval = optionalNewVal {
Hookah Tau/Controllers/Admin/Reservations/List of reservations/AdminReservationsCoordinator.swift+16
@@ -12,6 +12,8 @@ class AdminReservationsCoordinator: BaseCoordinator {
1212
1313 // MARK: - Properties
1414
15+ var didFinish: (() -> Void)?
16+
1517 var establishmentId: Int?
1618
1719 // MARK: - Lifecycle
@@ -35,4 +37,18 @@ class AdminReservationsCoordinator: BaseCoordinator {
3537 }
3638 reservationCoordinator.start()
3739 }
40+
41+ /// Сюда мы идем после нажатия кнопочки "Забронировать" или плюсика справа сверху
42+ func book(inEstablishment establishmentId: Int) {
43+ let reservationCoordinator = AdminFirstStepReservationViewCoordinator(navigationController: navigationController)
44+ reservationCoordinator.establishment = establishmentId
45+ addDependency(reservationCoordinator)
46+ reservationCoordinator.didFinish = { [weak self] in
47+ self?.navigationController?.popViewController(animated: false)
48+ self?.removeDependency(reservationCoordinator)
49+ self?.didFinish?()
50+ }
51+
52+ reservationCoordinator.start()
53+ }
3854}
Hookah Tau/Controllers/Admin/Reservations/Making a reeservation/1/AdminFirstStepReservationViewCoordinator.swiftnew file+108
@@ -0,0 +1,108 @@
1+//
2+// AdminFirstStepReservationViewCoordinator.swift
3+// Hookah Tau
4+//
5+// Created by cstore on 13/01/2020.
6+// Copyright © 2020 Daria Rednikina. All rights reserved.
7+//
8+
9+import UIKit
10+
11+enum UserType {
12+ case admin
13+ case client
14+}
15+
16+protocol FirstStepReservationProtocol: BaseCoordinator {
17+
18+ var user: UserType { get }
19+
20+ func makeReservation(model: SecondStepModel, mapView: MapImageScroll?)
21+}
22+
23+class AdminFirstStepReservationViewCoordinator: BaseCoordinator{
24+
25+ // MARK: - Properties
26+
27+ var didFinish: (() -> Void)?
28+
29+ var establishment: Int = 1
30+
31+ var phone: String?
32+
33+ var fullUser: FullUser?
34+
35+ var model: SecondStepModel?
36+
37+ // MARK: - Lifecycle
38+
39+ override func start() {
40+ let storyboard = UIStoryboard(name: "Reservation", bundle: nil)
41+ let reservationVC = storyboard.instantiateViewController(withIdentifier: "ReservationViewController") as! FirstStepReservationViewController
42+
43+ reservationVC.coordinator = self
44+ reservationVC.establishmentId = establishment
45+
46+ navigationController?.pushViewController(reservationVC, animated: true)
47+ }
48+
49+
50+}
51+
52+extension AdminFirstStepReservationViewCoordinator: FirstStepReservationProtocol {
53+
54+ var user: UserType {
55+ get {
56+ return .admin
57+ }
58+ }
59+
60+ func makeReservation(model: SecondStepModel, mapView: MapImageScroll?) {
61+ self.model = model
62+
63+ if let p = phone {
64+ goToFinalStep(with: fullUser, phone: p)
65+ } else {
66+ goToSecondStep(model: model, mapView: mapView)
67+ }
68+ }
69+
70+ func goToFinalStep(with user: FullUser?, phone phoneNumber: String) {
71+ let finalStepCoordinator = AdminFinalStepReservationCoordinator(navigationController: navigationController)
72+ finalStepCoordinator.model = self.model
73+
74+ addDependency(finalStepCoordinator)
75+ finalStepCoordinator.didFinish = { [weak self] in
76+ self?.navigationController?.popViewController(animated: false)
77+ self?.removeDependency(finalStepCoordinator)
78+ self?.didFinish?()
79+ }
80+
81+ if let u = user {
82+ finalStepCoordinator.user = u
83+ } else {
84+ finalStepCoordinator.user = FullUser(uuid: nil,
85+ name: nil,
86+ phoneNumber: phoneNumber,
87+ isAdmin: true)
88+ }
89+
90+ finalStepCoordinator.start()
91+ }
92+
93+ func goToSecondStep(model: SecondStepModel, mapView: MapImageScroll?) {
94+ let reservationCoordinaotor = AdminSecondStepReservationViewCoordinator(navigationController: navigationController)
95+ reservationCoordinaotor.model = model
96+ reservationCoordinaotor.map = mapView
97+
98+ addDependency(reservationCoordinaotor)
99+ reservationCoordinaotor.didFinish = { [weak self] in
100+ self?.navigationController?.popViewController(animated: false)
101+ self?.removeDependency(reservationCoordinaotor)
102+ self?.didFinish?()
103+ }
104+
105+ reservationCoordinaotor.start()
106+ }
107+}
108+
Hookah Tau/Controllers/Admin/Reservations/Making a reeservation/2/AdminSecondStepReservationViewController.swiftnew file+124
@@ -0,0 +1,124 @@
1+//
2+// AdminSecondStepReservationViewController.swift
3+// Hookah Tau
4+//
5+// Created by cstore on 13/01/2020.
6+// Copyright © 2020 Daria Rednikina. All rights reserved.
7+//
8+
9+import UIKit
10+
11+class AdminSecondStepReservationViewController: BaseViewController {
12+
13+ // MARK: - IBAOutlets
14+
15+ @IBOutlet weak var mapContainerView: UIView!
16+
17+ @IBOutlet weak var heightConstraint: NSLayoutConstraint!
18+
19+ @IBOutlet weak var phoneTextField: PhoneTextField!
20+
21+ @IBOutlet weak var phoneContentView: UIView!
22+
23+ // MARK: - Properties
24+
25+ var table: Int?
26+
27+ var mapScrollView: MapImageScroll?
28+
29+ var clientsService: ClientsService?
30+
31+ weak var coordinator: AdminSecondStepReservationViewCoordinator?
32+
33+ let continueButton: Button = {
34+ let button = Button()
35+ let style = BlackButtonStyle()
36+ style.apply(to: button, withTitle: "ДАЛЕЕ")
37+ return button
38+ }()
39+
40+ let cancelButton: Button = {
41+ let button = Button()
42+ let style = BlackButtonStyle()
43+ style.apply(to: button, withTitle: "ОТМЕНИТЬ")
44+ return button
45+ }()
46+
47+ // MARK: - Lifecycle
48+
49+ override func viewDidLoad() {
50+ super.viewDidLoad()
51+
52+ setupMap()
53+ setupButtons()
54+ setUpKeyboard()
55+
56+ clientsService = ClientsService(apiClient: APIClient.shared)
57+ phoneTextField.becomeFirstResponder()
58+ }
59+
60+ // MARK: - Set up
61+
62+ func setupMap() {
63+ guard let t = table else { return }
64+ mapScrollView?.scrollToTable(table: t)
65+ mapContainerView.addSubviewThatFills(mapScrollView)
66+ }
67+
68+ func setupButtons() {
69+ addStackViewWithButtons(leftBtn: cancelButton,
70+ rightBtn: continueButton,
71+ constant: -phoneContentView.frame.height - 20)
72+
73+ cancelButton.addTarget(self, action: #selector(cancel), for: .touchUpInside)
74+ continueButton.addTarget(self, action: #selector(continueBooking), for: .touchUpInside)
75+ }
76+
77+ // MARK: - Keyboad
78+
79+ @objc
80+ override func handleKeyboardNotifications(notification: NSNotification) {
81+ if let userInfo = notification.userInfo {
82+ let keyBoardFrame = (userInfo[UIResponder.keyboardFrameEndUserInfoKey] as! NSValue).cgRectValue
83+ heightConstraint?.constant = notification.name == UIResponder.keyboardWillShowNotification ? keyBoardFrame.height + view.safeAreaInsets.bottom + 120.5 : 120.5
84+ bottomConstraint?.constant = notification.name == UIResponder.keyboardWillShowNotification ? -keyBoardFrame.height + view.safeAreaInsets.bottom - 140.5 : -140.5
85+
86+ UIView.animate(withDuration: 0, delay: 0, options: .curveEaseOut, animations: {
87+ self.view.layoutIfNeeded()
88+ })
89+ }
90+ }
91+
92+ // MARK: - Button handlers
93+
94+ @objc func cancel() {
95+ coordinator?.didEndFlow?()
96+ }
97+
98+ @objc func continueBooking() {
99+ continueButton.loading = true
100+
101+ guard let phone = phoneTextField.text?.toApiPhoneNumberFormat(), phone.count == 9 else {
102+ displayAlert(with: "Сначала укажи номер!")
103+ return
104+ }
105+
106+ clientsService?.getClientByPhoneNumber(userPhone: phone, completion: { [unowned self] (res) in
107+ switch res {
108+ case .failure(let err):
109+ switch err {
110+ case .notFound:
111+ self.coordinator?.continueReservation(with: nil, phone: phone)
112+ default:
113+ self.displayAlert(with: "Что-то пошло не так! Попробуй еще раз :)")
114+ }
115+ case .success(let user):
116+ self.coordinator?.continueReservation(with: user, phone: phone)
117+ }
118+
119+ self.continueButton.loading = false
120+ })
121+ }
122+
123+
124+}
Hookah Tau/Controllers/Admin/Reservations/Making a reeservation/2/AdminSecondStepReservationViewCoordinator.swiftnew file+54
@@ -0,0 +1,54 @@
1+//
2+// AdminSecondStepReservationViewCoordinator.swift
3+// Hookah Tau
4+//
5+// Created by cstore on 13/01/2020.
6+// Copyright © 2020 Daria Rednikina. All rights reserved.
7+//
8+
9+import UIKit
10+
11+class AdminSecondStepReservationViewCoordinator: BaseCoordinator {
12+
13+ // MARK: - Properties
14+
15+ var didFinish: (() -> Void)?
16+
17+ var map: MapImageScroll?
18+
19+ var model: SecondStepModel?
20+
21+ // MARK: - Lifecycle
22+
23+ override func start() {
24+ let storyboard = UIStoryboard(name: "AdminReservations", bundle: nil)
25+ let reservationVC = storyboard.instantiateViewController(withIdentifier: "AdminSecondStepReservationViewController") as! AdminSecondStepReservationViewController
26+ reservationVC.mapScrollView = map
27+ reservationVC.table = model?.table
28+ reservationVC.coordinator = self
29+ navigationController?.pushViewController(reservationVC, animated: true)
30+ }
31+
32+ func continueReservation(with user: FullUser?, phone phoneNumber: String) {
33+ let finalStepCoordinator = AdminFinalStepReservationCoordinator(navigationController: navigationController)
34+ finalStepCoordinator.model = self.model
35+
36+ addDependency(finalStepCoordinator)
37+ finalStepCoordinator.didFinish = { [weak self] in
38+ self?.navigationController?.popViewController(animated: false)
39+ self?.removeDependency(finalStepCoordinator)
40+ self?.didFinish?()
41+ }
42+
43+ if let u = user {
44+ finalStepCoordinator.user = u
45+ } else {
46+ finalStepCoordinator.user = FullUser(uuid: nil,
47+ name: nil,
48+ phoneNumber: phoneNumber,
49+ isAdmin: true)
50+ }
51+
52+ finalStepCoordinator.start()
53+ }
54+}
Hookah Tau/Controllers/Admin/Reservations/Making a reeservation/3/AdminFinalStepReservationCoordinator.swiftnew file+47
@@ -0,0 +1,47 @@
1+//
2+// AdminFinalStepReservationCoordinator.swift
3+// Hookah Tau
4+//
5+// Created by cstore on 14/01/2020.
6+// Copyright © 2020 Daria Rednikina. All rights reserved.
7+//
8+
9+import UIKit
10+
11+protocol ShowReservationCoordinator: BaseCoordinator {
12+ var didFinish: (() -> Void)? { get }
13+}
14+
15+class AdminFinalStepReservationCoordinator: BaseCoordinator, ShowReservationCoordinator {
16+
17+ // MARK: - Properties
18+
19+ var didFinish: (() -> Void)?
20+
21+ var user: FullUser?
22+
23+ var model: SecondStepModel?
24+
25+ // MARK: - Lifecycle
26+
27+ override func start() {
28+ let storyboard = UIStoryboard(name: "AdminReservations", bundle: nil)
29+ let vc = storyboard.instantiateViewController(withIdentifier: "AdminReservationEditingViewController") as! AdminReservationEditingViewController
30+
31+ guard
32+ let model = model,
33+ let u = user else { return }
34+ vc.reservationData = ReservationWithUser(uuid: nil,
35+ establishment: model.establishment,
36+ startTime: model.startTime,
37+ endTime: model.startTime.addHours(2),
38+ numberOfGuests: 2,
39+ reservedTable: model.table,
40+ owner: u)
41+
42+ vc.reservedPeriods = model.reservedintervals
43+ vc.coordinator = self
44+
45+ navigationController?.pushViewController(vc, animated: true)
46+ }
47+}
Hookah Tau/Controllers/Admin/Reservations/Views/AdminReservationView.swift+11−4
@@ -39,6 +39,13 @@ class AdminReservationView: UIView {
3939
4040 @IBOutlet weak var intervalsStackView: UIStackView!
4141
42+ @IBOutlet weak var saveButton: Button? {
43+ didSet {
44+ let style = BlackButtonStyle()
45+ style.apply(to: saveButton, withTitle: "СОХРАНИТЬ")
46+ }
47+ }
48+
4249 // MARK: - Properties
4350
4451 // констрейнты начала и конца интервала
@@ -109,7 +116,7 @@ class AdminReservationView: UIView {
109116
110117 startDate = start
111118
112− setUpIntervals(model.owner.isAdmin)
119+ setUpIntervals()
113120
114121 guestSlider?.maximumValue = Float((TotalStorage.standard.getTable(establishment: model.establishment, table: model.reservedTable)?.maxGuestNumber ?? 2) + 1)
115122 }
@@ -158,11 +165,11 @@ class AdminReservationView: UIView {
158165 // MARK: - Setup
159166
160167 /// Тут происходит установка интервалов. Разное для клиента и админа
161− func setUpIntervals(_ isAdmin: Bool) {
168+ func setUpIntervals() {
162169 guard let startPoint = startDate else { return }
163170
164− let startingPoint = isAdmin ? startPoint.getAdminsStartingPoint() : Constants.clientStartingPoint
165− let endingPoint = startingPoint + (isAdmin ? Constants.adminDuration : Constants.clientDuration)
171+ let startingPoint = startPoint.getAdminsStartingPoint()
172+ let endingPoint = Constants.adminDuration
166173
167174 for period in startingPoint...endingPoint {
168175 let timePointView = TimePointView.loadFromNib()
Hookah Tau/Controllers/Admin/Reservations/Views/AdminReservationView.xib+36−21
@@ -11,14 +11,14 @@
1111 <placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner"/>
1212 <placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
1313 <view contentMode="scaleToFill" id="iN0-l3-epB" customClass="AdminReservationView" customModule="Hookah_Tau" customModuleProvider="target">
14− <rect key="frame" x="0.0" y="0.0" width="414" height="441"/>
14+ <rect key="frame" x="0.0" y="0.0" width="414" height="385"/>
1515 <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
1616 <subviews>
17− <stackView opaque="NO" contentMode="scaleToFill" axis="vertical" alignment="center" spacing="48" translatesAutoresizingMaskIntoConstraints="NO" id="AEf-R4-K1F">
18− <rect key="frame" x="0.0" y="16" width="414" height="404"/>
17+ <stackView opaque="NO" contentMode="scaleToFill" axis="vertical" alignment="center" spacing="24" translatesAutoresizingMaskIntoConstraints="NO" id="AEf-R4-K1F">
18+ <rect key="frame" x="0.0" y="16" width="414" height="349"/>
1919 <subviews>
2020 <stackView opaque="NO" contentMode="scaleToFill" alignment="top" spacing="4" translatesAutoresizingMaskIntoConstraints="NO" id="oh7-ka-ctS">
21− <rect key="frame" x="21" y="0.0" width="372" height="143.5"/>
21+ <rect key="frame" x="21" y="0.0" width="372" height="136.5"/>
2222 <subviews>
2323 <stackView opaque="NO" contentMode="scaleToFill" axis="vertical" alignment="top" spacing="22" translatesAutoresizingMaskIntoConstraints="NO" id="IY6-F4-aln">
2424 <rect key="frame" x="0.0" y="0.0" width="129" height="136.5"/>
@@ -66,21 +66,35 @@
6666 <constraint firstItem="hEV-kW-bBH" firstAttribute="leading" secondItem="IY6-F4-aln" secondAttribute="leading" id="tsb-PN-YGB"/>
6767 </constraints>
6868 </stackView>
69− <stackView opaque="NO" contentMode="scaleToFill" axis="vertical" alignment="bottom" spacing="8" translatesAutoresizingMaskIntoConstraints="NO" id="59c-nG-5Fh">
70− <rect key="frame" x="133" y="0.0" width="239" height="71.5"/>
69+ <stackView opaque="NO" contentMode="scaleToFill" axis="vertical" distribution="equalSpacing" alignment="bottom" spacing="28" translatesAutoresizingMaskIntoConstraints="NO" id="Kjb-P4-v2B">
70+ <rect key="frame" x="133" y="0.0" width="239" height="136.5"/>
7171 <subviews>
72− <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Стасик" textAlignment="natural" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="OoG-F4-OVu">
73− <rect key="frame" x="160.5" y="0.0" width="78.5" height="26.5"/>
74− <fontDescription key="fontDescription" type="boldSystem" pointSize="22"/>
75− <nil key="textColor"/>
76− <nil key="highlightedColor"/>
77− </label>
78− <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="Xkd-xQ-cFd" customClass="Button" customModule="Hookah_Tau" customModuleProvider="target">
79− <rect key="frame" x="65" y="34.5" width="174" height="37"/>
72+ <stackView opaque="NO" contentMode="scaleToFill" axis="vertical" alignment="bottom" spacing="8" translatesAutoresizingMaskIntoConstraints="NO" id="59c-nG-5Fh">
73+ <rect key="frame" x="65" y="0.0" width="174" height="71.5"/>
74+ <subviews>
75+ <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Стасик" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="OoG-F4-OVu">
76+ <rect key="frame" x="95.5" y="0.0" width="78.5" height="26.5"/>
77+ <fontDescription key="fontDescription" type="boldSystem" pointSize="22"/>
78+ <nil key="textColor"/>
79+ <nil key="highlightedColor"/>
80+ </label>
81+ <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="Xkd-xQ-cFd" customClass="Button" customModule="Hookah_Tau" customModuleProvider="target">
82+ <rect key="frame" x="0.0" y="34.5" width="174" height="37"/>
83+ <color key="backgroundColor" white="0.66666666669999997" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
84+ <constraints>
85+ <constraint firstAttribute="height" constant="37" id="7Wj-WF-xzD"/>
86+ <constraint firstAttribute="width" constant="174" id="ZYo-ko-rwn"/>
87+ </constraints>
88+ <state key="normal" title="Button"/>
89+ </button>
90+ </subviews>
91+ </stackView>
92+ <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="npC-AF-3pj" customClass="Button" customModule="Hookah_Tau" customModuleProvider="target">
93+ <rect key="frame" x="103" y="99.5" width="136" height="37"/>
8094 <color key="backgroundColor" white="0.66666666669999997" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
8195 <constraints>
82− <constraint firstAttribute="height" constant="37" id="7Wj-WF-xzD"/>
83− <constraint firstAttribute="width" constant="174" id="ZYo-ko-rwn"/>
96+ <constraint firstAttribute="width" constant="136" id="jg5-lP-Ekd"/>
97+ <constraint firstAttribute="height" constant="37" id="w98-8a-pmH"/>
8498 </constraints>
8599 <state key="normal" title="Button"/>
86100 </button>
@@ -89,7 +103,7 @@
89103 </subviews>
90104 </stackView>
91105 <stackView opaque="NO" contentMode="scaleToFill" axis="vertical" spacing="8" translatesAutoresizingMaskIntoConstraints="NO" id="9RO-aK-yNh">
92− <rect key="frame" x="21" y="191.5" width="372" height="58.5"/>
106+ <rect key="frame" x="21" y="160.5" width="372" height="58.5"/>
93107 <subviews>
94108 <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Количество гостей: 2" textAlignment="natural" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="yTM-U5-XjI">
95109 <rect key="frame" x="0.0" y="0.0" width="372" height="20.5"/>
@@ -106,7 +120,7 @@
106120 </subviews>
107121 </stackView>
108122 <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="vKS-ia-RxW">
109− <rect key="frame" x="0.0" y="298" width="414" height="106"/>
123+ <rect key="frame" x="0.0" y="243" width="414" height="106"/>
110124 <subviews>
111125 <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="EiP-QO-PbU">
112126 <rect key="frame" x="0.0" y="20" width="414" height="85"/>
@@ -182,10 +196,10 @@
182196 </subviews>
183197 <color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
184198 <constraints>
185− <constraint firstItem="vUN-kp-3ea" firstAttribute="bottom" secondItem="AEf-R4-K1F" secondAttribute="bottom" constant="21" id="4MN-Yl-hYv"/>
186199 <constraint firstItem="vUN-kp-3ea" firstAttribute="trailing" secondItem="AEf-R4-K1F" secondAttribute="trailing" id="C1h-bA-S6p"/>
187200 <constraint firstItem="AEf-R4-K1F" firstAttribute="leading" secondItem="iN0-l3-epB" secondAttribute="leading" id="H1o-ua-Tnn"/>
188− <constraint firstItem="vUN-kp-3ea" firstAttribute="top" secondItem="AEf-R4-K1F" secondAttribute="top" constant="-16" id="eYI-is-YLt"/>
201+ <constraint firstAttribute="top" secondItem="AEf-R4-K1F" secondAttribute="top" constant="-16" id="eYI-is-YLt"/>
202+ <constraint firstAttribute="bottom" secondItem="AEf-R4-K1F" secondAttribute="bottom" constant="20" id="fdG-zZ-LeV"/>
189203 </constraints>
190204 <freeformSimulatedSizeMetrics key="simulatedDestinationMetrics"/>
191205 <viewLayoutGuide key="safeArea" id="vUN-kp-3ea"/>
@@ -198,11 +212,12 @@
198212 <outlet property="intervalsStackView" destination="bpJ-pe-tQf" id="aF0-Qm-kuh"/>
199213 <outlet property="nameLabel" destination="OoG-F4-OVu" id="rnW-fG-jFs"/>
200214 <outlet property="numberOfGuestLabel" destination="yTM-U5-XjI" id="z0O-94-Mp7"/>
215+ <outlet property="saveButton" destination="npC-AF-3pj" id="Rfm-Zl-zES"/>
201216 <outlet property="scrollView" destination="trF-VM-0qV" id="P5v-fg-hUW"/>
202217 <outlet property="tableLabel" destination="qNR-EO-oMK" id="63P-AS-fgf"/>
203218 <outlet property="timeLabel" destination="gau-aS-vtT" id="7Iy-Cz-zdY"/>
204219 </connections>
205− <point key="canvasLocation" x="137.59999999999999" y="120.98950524737631"/>
220+ <point key="canvasLocation" x="137.59999999999999" y="95.802098950524751"/>
206221 </view>
207222 </objects>
208223</document>
Hookah Tau/Controllers/BaseViewController.swift+1−1
@@ -97,7 +97,7 @@ class BaseViewController: UIViewController {
9797 }
9898
9999 @objc
100− private func handleKeyboardNotifications(notification: NSNotification){
100+ func handleKeyboardNotifications(notification: NSNotification){
101101 if let userInfo = notification.userInfo {
102102 let keyBoardFrame = (userInfo[UIResponder.keyboardFrameEndUserInfoKey] as! NSValue).cgRectValue
103103 bottomConstraint?.constant = notification.name == UIResponder.keyboardWillShowNotification ? -keyBoardFrame.height + view.safeAreaInsets.bottom - 20 : 0
Hookah Tau/Controllers/Client/Profile/ProfileChangeViewController.swift+3−3
@@ -23,7 +23,7 @@ class ProfileChangeViewController: BaseViewController {
2323
2424 var changeView: ChangeView?
2525
26− var settingsService: SettingsService?
26+ var settingsService: ClientsService?
2727
2828 var contentView: UIView = {
2929 let view = UIView()
@@ -60,7 +60,7 @@ class ProfileChangeViewController: BaseViewController {
6060 setUpView()
6161 setUpKeyboard()
6262
63− settingsService = SettingsService(apiClient: APIClient.shared)
63+ settingsService = ClientsService(apiClient: APIClient.shared)
6464 }
6565
6666 func setUpView() {
@@ -106,7 +106,7 @@ class ProfileChangeViewController: BaseViewController {
106106 func addNewAdmin(phone: String) {
107107 doneButton.loading = true
108108
109− settingsService?.addOtherAdmin(phone: phone) { [weak self] res in
109+ settingsService?.changeAdmin(crud: CrudMethod.put, data: phone) { [weak self] res in
110110 if res {
111111 self?.coordinator?.update(withModel: nil)
112112 } else {
Hookah Tau/Controllers/Client/Reservations/Active Reservations/ReservationsViewController.swift+1−1
@@ -192,7 +192,7 @@ extension ReservationsViewController: UITableViewDelegate, UITableViewDataSource
192192 func tableView(_ tableView: UITableView, editActionsForRowAt indexPath: IndexPath) -> [UITableViewRowAction]? {
193193
194194 let uuid = activeReservations[indexPath.row].uuid
195− let cancelButton = UITableViewRowAction(style: .normal, title: "❌") { _,_ in
195+ let cancelButton = UITableViewRowAction(style: .normal, title: "отменить бронь") { _,_ in
196196
197197 self.deleteReservation(uuid: uuid) { optionalNewVal in
198198 if let newval = optionalNewVal {
Hookah Tau/Controllers/Client/Reservations/Steps/1/FirstStepReservationCoordinator.swift+8−1
@@ -8,7 +8,7 @@
88
99import UIKit
1010
11−class FirstStepReservationCoordinator: BaseCoordinator {
11+class FirstStepReservationCoordinator: BaseCoordinator, FirstStepReservationProtocol {
1212
1313 // MARK: - Properties
1414
@@ -28,6 +28,13 @@ class FirstStepReservationCoordinator: BaseCoordinator {
2828 navigationController?.pushViewController(reservationVC, animated: true)
2929 }
3030
31+ var user: UserType {
32+ get {
33+ return .client
34+ }
35+ }
36+
37+
3138 func makeReservation(model: SecondStepModel,
3239 mapView: MapImageScroll?) {
3340
Hookah Tau/Controllers/Client/Reservations/Steps/1/FirstStepReservationViewController.swift+15−6
@@ -13,7 +13,7 @@ class FirstStepReservationViewController: BaseViewController {
1313
1414 // MARK: - Properties
1515
16− weak var coordinator: FirstStepReservationCoordinator?
16+ weak var coordinator: FirstStepReservationProtocol?
1717
1818 @IBOutlet weak var childContentView: UIView!
1919
@@ -82,12 +82,21 @@ class FirstStepReservationViewController: BaseViewController {
8282 }
8383
8484 func setupButtons() {
85− addStackViewWithButtons(leftBtn: callButton,
86− rightBtn: continueButton,
87− constant: -childContentView.frame.height - 20)
85+
86+ guard let coord = coordinator else { return }
87+
88+ if coord.user == .admin {
89+ addStackViewWithButtons(rightBtn: continueButton,
90+ constant: -childContentView.frame.height - 20)
91+ } else {
92+ addStackViewWithButtons(leftBtn: callButton,
93+ rightBtn: continueButton,
94+ constant: -childContentView.frame.height - 20)
95+
96+ callButton.addTarget(self, action: #selector(call), for: .touchUpInside)
97+ }
8898
8999 continueButton.addTarget(self, action: #selector(continueBooking), for: .touchUpInside)
90− callButton.addTarget(self, action: #selector(call), for: .touchUpInside)
91100 }
92101
93102 func performUpdate() {
@@ -178,7 +187,7 @@ extension FirstStepReservationViewController: MapUpdater {
178187 let areBooked = allReservations?.intervals[date] ?? []
179188
180189 let isAdmin = DataStorage.standard.getUserModel()?.isAdmin ?? false
181− let closed = isAdmin || date.isInClosingHours()
190+ let closed = !isAdmin && date.isInClosingHours()
182191
183192 if Set(areBooked).contains(tableId) || closed {
184193 continueButton.availiable = false
Hookah Tau/Models/Reservation.swift+15−1
@@ -51,7 +51,7 @@ struct ReservationData: MyCodable {
5151/// Структура для получения респонса на `GET /admin/reservations/{establishment id}`
5252struct ReservationWithUser: MyCodable {
5353
54− var uuid: String
54+ var uuid: String?
5555 var establishment: Int
5656 var startTime: Date
5757 var endTime: Date
@@ -68,6 +68,20 @@ struct ReservationWithUser: MyCodable {
6868 self.reservedTable = reservation.reservedTable
6969 self.owner = user
7070 }
71+
72+ init(uuid: String?, establishment: Int, startTime: Date, endTime: Date, numberOfGuests: Int, reservedTable: Int, owner: FullUser) {
73+ self.uuid = uuid
74+ self.establishment = establishment
75+ self.startTime = startTime
76+ self.endTime = endTime
77+ self.numberOfGuests = numberOfGuests
78+ self.reservedTable = reservedTable
79+ self.owner = owner
80+ }
7181}
7282
83+struct AdminCreateReservation: MyCodable {
84+ var reservation: ReservationData
85+ var user: String
86+}
7387
Hookah Tau/Models/User.swift+1−1
@@ -17,7 +17,7 @@ struct User: MyCodable {
1717
1818/// При запросах на список пользователей в аккаунте администратора.
1919struct FullUser: MyCodable {
20− var uuid: String
20+ var uuid: String?
2121 var name: String?
2222 var phoneNumber: String
2323 var isAdmin: Bool