git.iko.soy/dashared/hookah-tau
on develop help sign in
Добавила функционал добавления/удаления админов в список клиентов
1cb9a68Darya Rednikina
Hookah Tau.xcodeproj/project.pbxproj+5−21
@@ -69,7 +69,6 @@
69 12B3A7AF23AC1872009E2FA6 /* AdminNoReservationsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 12B3A7AE23AC1872009E2FA6 /* AdminNoReservationsView.swift */; };
69 12B3A7AF23AC1872009E2FA6 /* AdminNoReservationsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 12B3A7AE23AC1872009E2FA6 /* AdminNoReservationsView.swift */; };
70 12B3A7B123AC1885009E2FA6 /* AdminNoReservationsView.xib in Resources */ = {isa = PBXBuildFile; fileRef = 12B3A7B023AC1885009E2FA6 /* AdminNoReservationsView.xib */; };
70 12B3A7B123AC1885009E2FA6 /* AdminNoReservationsView.xib in Resources */ = {isa = PBXBuildFile; fileRef = 12B3A7B023AC1885009E2FA6 /* AdminNoReservationsView.xib */; };
71 12B3A7B423AC1D09009E2FA6 /* AdminReservationCellView.xib in Resources */ = {isa = PBXBuildFile; fileRef = 12B3A7B323AC1D09009E2FA6 /* AdminReservationCellView.xib */; };
71 12B3A7B423AC1D09009E2FA6 /* AdminReservationCellView.xib in Resources */ = {isa = PBXBuildFile; fileRef = 12B3A7B323AC1D09009E2FA6 /* AdminReservationCellView.xib */; };
72− 12B3A7B723ACCD07009E2FA6 /* SettingsService.swift in Sources */ = {isa = PBXBuildFile; fileRef = 12B3A7B623ACCD07009E2FA6 /* SettingsService.swift */; };
73 12B3A7B923ACCD83009E2FA6 /* AddOtherAdminResolver.swift in Sources */ = {isa = PBXBuildFile; fileRef = 12B3A7B823ACCD83009E2FA6 /* AddOtherAdminResolver.swift */; };
72 12B3A7B923ACCD83009E2FA6 /* AddOtherAdminResolver.swift in Sources */ = {isa = PBXBuildFile; fileRef = 12B3A7B823ACCD83009E2FA6 /* AddOtherAdminResolver.swift */; };
74 12B3A7BC23ACFD75009E2FA6 /* ReservationsAroundResolver.swift in Sources */ = {isa = PBXBuildFile; fileRef = 12B3A7BB23ACFD75009E2FA6 /* ReservationsAroundResolver.swift */; };
73 12B3A7BC23ACFD75009E2FA6 /* ReservationsAroundResolver.swift in Sources */ = {isa = PBXBuildFile; fileRef = 12B3A7BB23ACFD75009E2FA6 /* ReservationsAroundResolver.swift */; };
75 12B3A7BE23AD0049009E2FA6 /* AdminReservationEditingViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 12B3A7BD23AD0048009E2FA6 /* AdminReservationEditingViewController.swift */; };
74 12B3A7BE23AD0049009E2FA6 /* AdminReservationEditingViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 12B3A7BD23AD0048009E2FA6 /* AdminReservationEditingViewController.swift */; };
@@ -115,6 +114,7 @@
115 12F9652A23868E6000FCA696 /* SecondStepView.xib in Resources */ = {isa = PBXBuildFile; fileRef = 12F9652923868E6000FCA696 /* SecondStepView.xib */; };
114 12F9652A23868E6000FCA696 /* SecondStepView.xib in Resources */ = {isa = PBXBuildFile; fileRef = 12F9652923868E6000FCA696 /* SecondStepView.xib */; };
116 12F9652C23868E7200FCA696 /* SecondStepView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 12F9652B23868E7200FCA696 /* SecondStepView.swift */; };
115 12F9652C23868E7200FCA696 /* SecondStepView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 12F9652B23868E7200FCA696 /* SecondStepView.swift */; };
117 12F9652E23869F3100FCA696 /* SecondStepReservationCoordinator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 12F9652D23869F3100FCA696 /* SecondStepReservationCoordinator.swift */; };
116 12F9652E23869F3100FCA696 /* SecondStepReservationCoordinator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 12F9652D23869F3100FCA696 /* SecondStepReservationCoordinator.swift */; };
117+ 12FC07B923C8D17600EDC55B /* DeleteOtherAdminResolver.swift in Sources */ = {isa = PBXBuildFile; fileRef = 12FC07B823C8D17600EDC55B /* DeleteOtherAdminResolver.swift */; };
118 12FC40382382C93D00AB593B /* TableButtonStyle.swift in Sources */ = {isa = PBXBuildFile; fileRef = 12FC40372382C93C00AB593B /* TableButtonStyle.swift */; };
118 12FC40382382C93D00AB593B /* TableButtonStyle.swift in Sources */ = {isa = PBXBuildFile; fileRef = 12FC40372382C93C00AB593B /* TableButtonStyle.swift */; };
119 12FC403A2382CB6F00AB593B /* TableButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = 12FC40392382CB6F00AB593B /* TableButton.swift */; };
119 12FC403A2382CB6F00AB593B /* TableButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = 12FC40392382CB6F00AB593B /* TableButton.swift */; };
120 F30369B5233679EA00A8EA84 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = F30369B4233679EA00A8EA84 /* LaunchScreen.storyboard */; };
120 F30369B5233679EA00A8EA84 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = F30369B4233679EA00A8EA84 /* LaunchScreen.storyboard */; };
@@ -226,7 +226,6 @@
226 12B3A7AE23AC1872009E2FA6 /* AdminNoReservationsView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AdminNoReservationsView.swift; sourceTree = "<group>"; };
226 12B3A7AE23AC1872009E2FA6 /* AdminNoReservationsView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AdminNoReservationsView.swift; sourceTree = "<group>"; };
227 12B3A7B023AC1885009E2FA6 /* AdminNoReservationsView.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = AdminNoReservationsView.xib; sourceTree = "<group>"; };
227 12B3A7B023AC1885009E2FA6 /* AdminNoReservationsView.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = AdminNoReservationsView.xib; sourceTree = "<group>"; };
228 12B3A7B323AC1D09009E2FA6 /* AdminReservationCellView.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = AdminReservationCellView.xib; sourceTree = "<group>"; };
228 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>"; };
230 12B3A7B823ACCD83009E2FA6 /* AddOtherAdminResolver.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AddOtherAdminResolver.swift; sourceTree = "<group>"; };
229 12B3A7B823ACCD83009E2FA6 /* AddOtherAdminResolver.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AddOtherAdminResolver.swift; sourceTree = "<group>"; };
231 12B3A7BB23ACFD75009E2FA6 /* ReservationsAroundResolver.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ReservationsAroundResolver.swift; sourceTree = "<group>"; };
230 12B3A7BB23ACFD75009E2FA6 /* ReservationsAroundResolver.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ReservationsAroundResolver.swift; sourceTree = "<group>"; };
232 12B3A7BD23AD0048009E2FA6 /* AdminReservationEditingViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AdminReservationEditingViewController.swift; sourceTree = "<group>"; };
231 12B3A7BD23AD0048009E2FA6 /* AdminReservationEditingViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AdminReservationEditingViewController.swift; sourceTree = "<group>"; };
@@ -272,6 +271,7 @@
272 12F9652923868E6000FCA696 /* SecondStepView.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = SecondStepView.xib; sourceTree = "<group>"; };
271 12F9652923868E6000FCA696 /* SecondStepView.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = SecondStepView.xib; sourceTree = "<group>"; };
273 12F9652B23868E7200FCA696 /* SecondStepView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SecondStepView.swift; sourceTree = "<group>"; };
272 12F9652B23868E7200FCA696 /* SecondStepView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SecondStepView.swift; sourceTree = "<group>"; };
274 12F9652D23869F3100FCA696 /* SecondStepReservationCoordinator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SecondStepReservationCoordinator.swift; sourceTree = "<group>"; };
273 12F9652D23869F3100FCA696 /* SecondStepReservationCoordinator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SecondStepReservationCoordinator.swift; sourceTree = "<group>"; };
274+ 12FC07B823C8D17600EDC55B /* DeleteOtherAdminResolver.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DeleteOtherAdminResolver.swift; sourceTree = "<group>"; };
275 12FC40372382C93C00AB593B /* TableButtonStyle.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TableButtonStyle.swift; sourceTree = "<group>"; };
275 12FC40372382C93C00AB593B /* TableButtonStyle.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TableButtonStyle.swift; sourceTree = "<group>"; };
276 12FC40392382CB6F00AB593B /* TableButton.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TableButton.swift; sourceTree = "<group>"; };
276 12FC40392382CB6F00AB593B /* TableButton.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TableButton.swift; sourceTree = "<group>"; };
277 F30369B4233679EA00A8EA84 /* LaunchScreen.storyboard */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; path = LaunchScreen.storyboard; sourceTree = "<group>"; };
277 F30369B4233679EA00A8EA84 /* LaunchScreen.storyboard */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; path = LaunchScreen.storyboard; sourceTree = "<group>"; };
@@ -549,7 +549,6 @@
549 12838EB923679AEB00CEF108 /* API */ = {
549 12838EB923679AEB00CEF108 /* API */ = {
550 isa = PBXGroup;
550 isa = PBXGroup;
551 children = (
551 children = (
552− 12B3A7B523ACCCD0009E2FA6 /* Settings */,
553 12838EA8236764A600CEF108 /* APIClient.swift */,
552 12838EA8236764A600CEF108 /* APIClient.swift */,
554 12838EB3236779C700CEF108 /* ApiResolver.swift */,
553 12838EB3236779C700CEF108 /* ApiResolver.swift */,
555 12838EAF236777D400CEF108 /* ServerError.swift */,
554 12838EAF236777D400CEF108 /* ServerError.swift */,
@@ -610,23 +609,6 @@
610 path = "No reserv";
609 path = "No reserv";
611 sourceTree = "<group>";
610 sourceTree = "<group>";
612 };
611 };
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− };
630 12B3A7C123AD0751009E2FA6 /* Editing */ = {
612 12B3A7C123AD0751009E2FA6 /* Editing */ = {
631 isa = PBXGroup;
613 isa = PBXGroup;
632 children = (
614 children = (
@@ -711,6 +693,8 @@
711 12E35075239FAF8F004BB188 /* Resolvers */ = {
693 12E35075239FAF8F004BB188 /* Resolvers */ = {
712 isa = PBXGroup;
694 isa = PBXGroup;
713 children = (
695 children = (
696+ 12FC07B823C8D17600EDC55B /* DeleteOtherAdminResolver.swift */,
697+ 12B3A7B823ACCD83009E2FA6 /* AddOtherAdminResolver.swift */,
714 12E35077239FAFA4004BB188 /* ClientsListResolver.swift */,
698 12E35077239FAFA4004BB188 /* ClientsListResolver.swift */,
715 12E3507C239FD1F3004BB188 /* ClientReservationsResolver.swift */,
699 12E3507C239FD1F3004BB188 /* ClientReservationsResolver.swift */,
716 12D928B223C7464B0051724D /* BlocklistPutResolver.swift */,
700 12D928B223C7464B0051724D /* BlocklistPutResolver.swift */,
@@ -1215,6 +1199,7 @@
1215 F30369BE2336924D00A8EA84 /* ClientTabbarCoordinator.swift in Sources */,
1199 F30369BE2336924D00A8EA84 /* ClientTabbarCoordinator.swift in Sources */,
1216 F3FC7DFD2315C4710080D851 /* BaseCoordinator.swift in Sources */,
1200 F3FC7DFD2315C4710080D851 /* BaseCoordinator.swift in Sources */,
1217 12E35071239FA8CA004BB188 /* Extensions+String.swift in Sources */,
1201 12E35071239FA8CA004BB188 /* Extensions+String.swift in Sources */,
1202+ 12FC07B923C8D17600EDC55B /* DeleteOtherAdminResolver.swift in Sources */,
1218 F3DC59FF233E893400B5E751 /* Extensions+UIFont.swift in Sources */,
1203 F3DC59FF233E893400B5E751 /* Extensions+UIFont.swift in Sources */,
1219 F3895F53233D5EEB00FA6A37 /* BlackButtonStyle.swift in Sources */,
1204 F3895F53233D5EEB00FA6A37 /* BlackButtonStyle.swift in Sources */,
1220 12F9652C23868E7200FCA696 /* SecondStepView.swift in Sources */,
1205 12F9652C23868E7200FCA696 /* SecondStepView.swift in Sources */,
@@ -1228,7 +1213,6 @@
1228 F3851B302340A513009EE0B6 /* RegistationViewModel.swift in Sources */,
1213 F3851B302340A513009EE0B6 /* RegistationViewModel.swift in Sources */,
1229 12B3A7AF23AC1872009E2FA6 /* AdminNoReservationsView.swift in Sources */,
1214 12B3A7AF23AC1872009E2FA6 /* AdminNoReservationsView.swift in Sources */,
1230 12838EAE2367701300CEF108 /* AuthorizationService.swift in Sources */,
1215 12838EAE2367701300CEF108 /* AuthorizationService.swift in Sources */,
1231− 12B3A7B723ACCD07009E2FA6 /* SettingsService.swift in Sources */,
1232 12C72EDF23537D1B00AD7004 /* ProfileCoordinator.swift in Sources */,
1216 12C72EDF23537D1B00AD7004 /* ProfileCoordinator.swift in Sources */,
1233 12E3507D239FD1F3004BB188 /* ClientReservationsResolver.swift in Sources */,
1217 12E3507D239FD1F3004BB188 /* ClientReservationsResolver.swift in Sources */,
1234 12EA994E2362FCE8005D9FE9 /* AddressView.swift in Sources */,
1218 12EA994E2362FCE8005D9FE9 /* AddressView.swift in Sources */,
Hookah Tau/API/ClientsService/ClientsService.swift+23
@@ -80,4 +80,27 @@ class ClientsService {
80 }
80 }
81 }
81 }
82 }
82 }
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+ }
83}
106}
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/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/Controllers/Admin/Clients/Cells/ClientTableViewCell.swift+7−5
@@ -20,9 +20,11 @@ class ClientTableViewCell: UITableViewCell {
20
20
21 @IBOutlet weak var numberOfReservationsLabel: UILabel!
21 @IBOutlet weak var numberOfReservationsLabel: UILabel!
22
22
23− @IBOutlet weak var blockListImage: UIImageView!
24
23
25− @IBOutlet weak var isAdminImage: UIImageView!
24+ @IBOutlet weak var blockListLabel: UILabel!
25+
26+ @IBOutlet weak var isAdminLabel: UILabel!
27+
26
28
27
29
28 // MARK: - Lifecycle
30 // MARK: - Lifecycle
@@ -41,11 +43,11 @@ class ClientTableViewCell: UITableViewCell {
41 // MARK: - Bind
43 // MARK: - Bind
42
44
43 func bind(withModel model: Client) {
45 func bind(withModel model: Client) {
44− blockListImage.isHidden = !model.isBlocked
46+ blockListLabel.isHidden = !model.isBlocked
45− isAdminImage.isHidden = !model.isAdmin
47+ isAdminLabel.isHidden = !model.isAdmin
46 nameLabel.text = model.name ?? "❔"
48 nameLabel.text = model.name ?? "❔"
47 phoneNumberLabel.text = model.phoneNumber.formattedNumber()
49 phoneNumberLabel.text = model.phoneNumber.formattedNumber()
48− numberOfReservationsLabel.text = "\(model.reservationCount)"
50+ numberOfReservationsLabel.text = model.reservationCount > 99 ? "99+" : "\(model.reservationCount)"
49 }
51 }
50
52
51}
53}
Hookah Tau/Controllers/Admin/Clients/ClientList.storyboard+25−26
@@ -34,7 +34,7 @@
34 <stackView opaque="NO" contentMode="scaleToFill" distribution="equalSpacing" alignment="center" spacingType="standard" translatesAutoresizingMaskIntoConstraints="NO" id="uoO-w2-5yG">
34 <stackView opaque="NO" contentMode="scaleToFill" distribution="equalSpacing" alignment="center" spacingType="standard" translatesAutoresizingMaskIntoConstraints="NO" id="uoO-w2-5yG">
35 <rect key="frame" x="0.0" y="0.0" width="78.5" height="26.5"/>
35 <rect key="frame" x="0.0" y="0.0" width="78.5" height="26.5"/>
36 <subviews>
36 <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">
38 <rect key="frame" x="0.0" y="0.0" width="78.5" height="26.5"/>
38 <rect key="frame" x="0.0" y="0.0" width="78.5" height="26.5"/>
39 <fontDescription key="fontDescription" type="boldSystem" pointSize="22"/>
39 <fontDescription key="fontDescription" type="boldSystem" pointSize="22"/>
40 <color key="textColor" white="0.0" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
40 <color key="textColor" white="0.0" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
@@ -51,32 +51,30 @@
51 </subviews>
51 </subviews>
52 </stackView>
52 </stackView>
53 <stackView opaque="NO" contentMode="scaleToFill" alignment="center" spacingType="standard" translatesAutoresizingMaskIntoConstraints="NO" id="tJg-ju-bFY">
53 <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"/>
55 <subviews>
55 <subviews>
56− <stackView opaque="NO" contentMode="scaleToFill" spacing="40" translatesAutoresizingMaskIntoConstraints="NO" id="4et-BC-7iY">
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" width="107.5" height="25"/>
57+ <rect key="frame" x="0.0" y="14.5" width="103.5" height="24"/>
58 <subviews>
58 <subviews>
59 <stackView opaque="NO" contentMode="scaleToFill" spacing="5" translatesAutoresizingMaskIntoConstraints="NO" id="BHD-cD-L1c">
59 <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"/>
61 <subviews>
61 <subviews>
62− <imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="blacklist" translatesAutoresizingMaskIntoConstraints="NO" id="yw1-jl-Iil">
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="25" height="25"/>
63+ <rect key="frame" x="0.0" y="0.0" width="23" height="24"/>
64− <constraints>
64+ <fontDescription key="fontDescription" type="system" pointSize="17"/>
65− <constraint firstAttribute="width" constant="25" id="k7r-sC-Yro"/>
65+ <nil key="textColor"/>
66− <constraint firstAttribute="height" constant="25" id="kjF-aV-kTo"/>
66+ <nil key="highlightedColor"/>
67− </constraints>
67+ </label>
68− </imageView>
69− <imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="admin" translatesAutoresizingMaskIntoConstraints="NO" id="Tlq-hK-YHS">
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">
70− <rect key="frame" x="30" y="0.0" width="25" height="25"/>
69+ <rect key="frame" x="28" y="0.0" width="23" height="24"/>
71− <constraints>
70+ <fontDescription key="fontDescription" type="system" pointSize="17"/>
72− <constraint firstAttribute="width" constant="25" id="NSy-Ih-fCV"/>
71+ <nil key="textColor"/>
73− <constraint firstAttribute="height" constant="25" id="nOu-SF-8Yd"/>
72+ <nil key="highlightedColor"/>
74− </constraints>
73+ </label>
75− </imageView>
76 </subviews>
74 </subviews>
77 </stackView>
75 </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">
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">
79− <rect key="frame" x="95" y="0.0" width="12.5" height="25"/>
77+ <rect key="frame" x="66" y="0.0" width="37.5" height="24"/>
80 <fontDescription key="fontDescription" type="system" pointSize="20"/>
78 <fontDescription key="fontDescription" type="system" pointSize="20"/>
81 <nil key="textColor"/>
79 <nil key="textColor"/>
82 <nil key="highlightedColor"/>
80 <nil key="highlightedColor"/>
@@ -84,9 +82,12 @@
84 </subviews>
82 </subviews>
85 </stackView>
83 </stackView>
86 <imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="arrow" translatesAutoresizingMaskIntoConstraints="NO" id="DrQ-Ss-gIT">
84 <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"/>
88 </imageView>
86 </imageView>
89 </subviews>
87 </subviews>
88+ <constraints>
89+ <constraint firstAttribute="width" constant="123.5" id="eeb-nt-pTB"/>
90+ </constraints>
90 </stackView>
91 </stackView>
91 </subviews>
92 </subviews>
92 </stackView>
93 </stackView>
@@ -99,8 +100,8 @@
99 </constraints>
100 </constraints>
100 </tableViewCellContentView>
101 </tableViewCellContentView>
101 <connections>
102 <connections>
102− <outlet property="blockListImage" destination="yw1-jl-Iil" id="p09-KQ-ayQ"/>
103+ <outlet property="blockListLabel" destination="MaQ-TW-666" id="Us0-tw-9tj"/>
103− <outlet property="isAdminImage" destination="Tlq-hK-YHS" id="KZP-yS-8YQ"/>
104+ <outlet property="isAdminLabel" destination="0Xa-FL-GVr" id="fzz-2t-Lda"/>
104 <outlet property="nameLabel" destination="4Cp-jh-0Gq" id="g6e-c0-x0u"/>
105 <outlet property="nameLabel" destination="4Cp-jh-0Gq" id="g6e-c0-x0u"/>
105 <outlet property="numberOfReservationsLabel" destination="Gzo-kW-60Z" id="9J2-S4-fKq"/>
106 <outlet property="numberOfReservationsLabel" destination="Gzo-kW-60Z" id="9J2-S4-fKq"/>
106 <outlet property="phoneNumberLabel" destination="0gY-h5-AV2" id="rdb-GS-ceF"/>
107 <outlet property="phoneNumberLabel" destination="0gY-h5-AV2" id="rdb-GS-ceF"/>
@@ -190,8 +191,6 @@
190 </scene>
191 </scene>
191 </scenes>
192 </scenes>
192 <resources>
193 <resources>
193− <image name="admin" width="26" height="25"/>
194 <image name="arrow" width="12" height="20"/>
194 <image name="arrow" width="12" height="20"/>
195− <image name="blacklist" width="25" height="25"/>
196 </resources>
195 </resources>
197</document>
196</document>
Hookah Tau/Controllers/Admin/Clients/ClientsViewController.swift+42−1
@@ -140,6 +140,35 @@ class ClientsViewController: BaseTableViewController {
140 }
140 }
141 })
141 })
142 }
142 }
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+ }
143}
172}
144
173
145// MARK: - Tableview
174// MARK: - Tableview
@@ -174,7 +203,7 @@ extension ClientsViewController {
174 override func tableView(_ tableView: UITableView, editActionsForRowAt indexPath: IndexPath) -> [UITableViewRowAction]? {
203 override func tableView(_ tableView: UITableView, editActionsForRowAt indexPath: IndexPath) -> [UITableViewRowAction]? {
175
204
176 let user = isFiltering ? filteredDataSource[indexPath.row] : dataSource[indexPath.row]
205 let user = isFiltering ? filteredDataSource[indexPath.row] : dataSource[indexPath.row]
177− let blockButton = UITableViewRowAction(style: .normal, title: "\(!user.isBlocked ? "🙅🏻‍♀️" : "👍🏻")") { _,_ in
206+ let blockButton = UITableViewRowAction(style: .normal, title: "\(!user.isBlocked ? "в чс" : "убрать из чс")") { _,_ in
178
207
179 self.updateUserBlockStatus(wasBlocked: user.isBlocked, phone: user.phoneNumber, indexPath: indexPath)
208 self.updateUserBlockStatus(wasBlocked: user.isBlocked, phone: user.phoneNumber, indexPath: indexPath)
180 }
209 }
@@ -183,6 +212,18 @@ extension ClientsViewController {
183
212
184 return [blockButton]
213 return [blockButton]
185 }
214 }
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+ }
186}
227}
187
228
188extension ClientsViewController: UISearchResultsUpdating {
229extension ClientsViewController: UISearchResultsUpdating {
Hookah Tau/Controllers/Admin/Clients/Profile/ProfileTableViewController.swift+1−1
@@ -220,7 +220,7 @@ extension ProfileTableViewController: UITableViewDelegate, UITableViewDataSource
220 func tableView(_ tableView: UITableView, editActionsForRowAt indexPath: IndexPath) -> [UITableViewRowAction]? {
220 func tableView(_ tableView: UITableView, editActionsForRowAt indexPath: IndexPath) -> [UITableViewRowAction]? {
221
221
222 let uuid = dataSource[indexPath.row].uuid
222 let uuid = dataSource[indexPath.row].uuid
223− let cancelButton = UITableViewRowAction(style: .normal, title: "❌") { _,_ in
223+ let cancelButton = UITableViewRowAction(style: .normal, title: "отменить бронь") { _,_ in
224
224
225 self.deleteReservation(uuid: uuid) { optionalNewVal in
225 self.deleteReservation(uuid: uuid) { optionalNewVal in
226 if let newval = optionalNewVal {
226 if let newval = optionalNewVal {
Hookah Tau/Controllers/Admin/Reservations/List of reservations/AdminReservationsController.swift+1−1
@@ -196,7 +196,7 @@ extension AdminReservationsController: UITableViewDelegate, UITableViewDataSourc
196 func tableView(_ tableView: UITableView, editActionsForRowAt indexPath: IndexPath) -> [UITableViewRowAction]? {
196 func tableView(_ tableView: UITableView, editActionsForRowAt indexPath: IndexPath) -> [UITableViewRowAction]? {
197
197
198 let uuid = activeReservations[indexPath.row].uuid
198 let uuid = activeReservations[indexPath.row].uuid
199− let cancelButton = UITableViewRowAction(style: .normal, title: "❌") { _,_ in
199+ let cancelButton = UITableViewRowAction(style: .normal, title: "отменить бронь") { _,_ in
200
200
201 self.deleteReservation(uuid: uuid) { optionalNewVal in
201 self.deleteReservation(uuid: uuid) { optionalNewVal in
202 if let newval = optionalNewVal {
202 if let newval = optionalNewVal {
Hookah Tau/Controllers/Client/Profile/ProfileChangeViewController.swift+3−3
@@ -23,7 +23,7 @@ class ProfileChangeViewController: BaseViewController {
23
23
24 var changeView: ChangeView?
24 var changeView: ChangeView?
25
25
26− var settingsService: SettingsService?
26+ var settingsService: ClientsService?
27
27
28 var contentView: UIView = {
28 var contentView: UIView = {
29 let view = UIView()
29 let view = UIView()
@@ -60,7 +60,7 @@ class ProfileChangeViewController: BaseViewController {
60 setUpView()
60 setUpView()
61 setUpKeyboard()
61 setUpKeyboard()
62
62
63− settingsService = SettingsService(apiClient: APIClient.shared)
63+ settingsService = ClientsService(apiClient: APIClient.shared)
64 }
64 }
65
65
66 func setUpView() {
66 func setUpView() {
@@ -106,7 +106,7 @@ class ProfileChangeViewController: BaseViewController {
106 func addNewAdmin(phone: String) {
106 func addNewAdmin(phone: String) {
107 doneButton.loading = true
107 doneButton.loading = true
108
108
109− settingsService?.addOtherAdmin(phone: phone) { [weak self] res in
109+ settingsService?.changeAdmin(crud: CrudMethod.put, data: phone) { [weak self] res in
110 if res {
110 if res {
111 self?.coordinator?.update(withModel: nil)
111 self?.coordinator?.update(withModel: nil)
112 } else {
112 } else {
Hookah Tau/Controllers/Client/Reservations/Active Reservations/ReservationsViewController.swift+1−1
@@ -192,7 +192,7 @@ extension ReservationsViewController: UITableViewDelegate, UITableViewDataSource
192 func tableView(_ tableView: UITableView, editActionsForRowAt indexPath: IndexPath) -> [UITableViewRowAction]? {
192 func tableView(_ tableView: UITableView, editActionsForRowAt indexPath: IndexPath) -> [UITableViewRowAction]? {
193
193
194 let uuid = activeReservations[indexPath.row].uuid
194 let uuid = activeReservations[indexPath.row].uuid
195− let cancelButton = UITableViewRowAction(style: .normal, title: "❌") { _,_ in
195+ let cancelButton = UITableViewRowAction(style: .normal, title: "отменить бронь") { _,_ in
196
196
197 self.deleteReservation(uuid: uuid) { optionalNewVal in
197 self.deleteReservation(uuid: uuid) { optionalNewVal in
198 if let newval = optionalNewVal {
198 if let newval = optionalNewVal {