git.iko.soy/dashared/hookah-tau
on develop help sign in
Добавила функционал добавления/удаления админов в список клиентов
commit1cb9a688837cb20f5d75312811c92283c88191e6 authorDarya Rednikina <rednikina.com@yandex.ru> dateSat 11 Jan 2020, 16:52 (7 years ago) parent82894e9
12 files changed+143−93
Hookah Tau.xcodeproj/project.pbxproj+5−21 Hookah Tau/API/ClientsService/ClientsService.swift+23 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/Settings/SettingsService.swift−34 Hookah Tau/Controllers/Admin/Clients/Cells/ClientTableViewCell.swift+7−5 Hookah Tau/Controllers/Admin/Clients/ClientList.storyboard+25−26 Hookah Tau/Controllers/Admin/Clients/ClientsViewController.swift+42−1 Hookah Tau/Controllers/Admin/Clients/Profile/ProfileTableViewController.swift+1−1 Hookah Tau/Controllers/Admin/Reservations/List of reservations/AdminReservationsController.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.xcodeproj/project.pbxproj+5−21
@@ -69,7 +69,6 @@
6969 12B3A7AF23AC1872009E2FA6 /* AdminNoReservationsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 12B3A7AE23AC1872009E2FA6 /* AdminNoReservationsView.swift */; };
7070 12B3A7B123AC1885009E2FA6 /* AdminNoReservationsView.xib in Resources */ = {isa = PBXBuildFile; fileRef = 12B3A7B023AC1885009E2FA6 /* AdminNoReservationsView.xib */; };
7171 12B3A7B423AC1D09009E2FA6 /* AdminReservationCellView.xib in Resources */ = {isa = PBXBuildFile; fileRef = 12B3A7B323AC1D09009E2FA6 /* AdminReservationCellView.xib */; };
72− 12B3A7B723ACCD07009E2FA6 /* SettingsService.swift in Sources */ = {isa = PBXBuildFile; fileRef = 12B3A7B623ACCD07009E2FA6 /* SettingsService.swift */; };
7372 12B3A7B923ACCD83009E2FA6 /* AddOtherAdminResolver.swift in Sources */ = {isa = PBXBuildFile; fileRef = 12B3A7B823ACCD83009E2FA6 /* AddOtherAdminResolver.swift */; };
7473 12B3A7BC23ACFD75009E2FA6 /* ReservationsAroundResolver.swift in Sources */ = {isa = PBXBuildFile; fileRef = 12B3A7BB23ACFD75009E2FA6 /* ReservationsAroundResolver.swift */; };
7574 12B3A7BE23AD0049009E2FA6 /* AdminReservationEditingViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 12B3A7BD23AD0048009E2FA6 /* AdminReservationEditingViewController.swift */; };
@@ -115,6 +114,7 @@
115114 12F9652A23868E6000FCA696 /* SecondStepView.xib in Resources */ = {isa = PBXBuildFile; fileRef = 12F9652923868E6000FCA696 /* SecondStepView.xib */; };
116115 12F9652C23868E7200FCA696 /* SecondStepView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 12F9652B23868E7200FCA696 /* SecondStepView.swift */; };
117116 12F9652E23869F3100FCA696 /* SecondStepReservationCoordinator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 12F9652D23869F3100FCA696 /* SecondStepReservationCoordinator.swift */; };
117+ 12FC07B923C8D17600EDC55B /* DeleteOtherAdminResolver.swift in Sources */ = {isa = PBXBuildFile; fileRef = 12FC07B823C8D17600EDC55B /* DeleteOtherAdminResolver.swift */; };
118118 12FC40382382C93D00AB593B /* TableButtonStyle.swift in Sources */ = {isa = PBXBuildFile; fileRef = 12FC40372382C93C00AB593B /* TableButtonStyle.swift */; };
119119 12FC403A2382CB6F00AB593B /* TableButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = 12FC40392382CB6F00AB593B /* TableButton.swift */; };
120120 F30369B5233679EA00A8EA84 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = F30369B4233679EA00A8EA84 /* LaunchScreen.storyboard */; };
@@ -226,7 +226,6 @@
226226 12B3A7AE23AC1872009E2FA6 /* AdminNoReservationsView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AdminNoReservationsView.swift; sourceTree = "<group>"; };
227227 12B3A7B023AC1885009E2FA6 /* AdminNoReservationsView.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = AdminNoReservationsView.xib; sourceTree = "<group>"; };
228228 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>"; };
230229 12B3A7B823ACCD83009E2FA6 /* AddOtherAdminResolver.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AddOtherAdminResolver.swift; sourceTree = "<group>"; };
231230 12B3A7BB23ACFD75009E2FA6 /* ReservationsAroundResolver.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ReservationsAroundResolver.swift; sourceTree = "<group>"; };
232231 12B3A7BD23AD0048009E2FA6 /* AdminReservationEditingViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AdminReservationEditingViewController.swift; sourceTree = "<group>"; };
@@ -272,6 +271,7 @@
272271 12F9652923868E6000FCA696 /* SecondStepView.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = SecondStepView.xib; sourceTree = "<group>"; };
273272 12F9652B23868E7200FCA696 /* SecondStepView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SecondStepView.swift; sourceTree = "<group>"; };
274273 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>"; };
275275 12FC40372382C93C00AB593B /* TableButtonStyle.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TableButtonStyle.swift; sourceTree = "<group>"; };
276276 12FC40392382CB6F00AB593B /* TableButton.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TableButton.swift; sourceTree = "<group>"; };
277277 F30369B4233679EA00A8EA84 /* LaunchScreen.storyboard */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; path = LaunchScreen.storyboard; sourceTree = "<group>"; };
@@ -549,7 +549,6 @@
549549 12838EB923679AEB00CEF108 /* API */ = {
550550 isa = PBXGroup;
551551 children = (
552− 12B3A7B523ACCCD0009E2FA6 /* Settings */,
553552 12838EA8236764A600CEF108 /* APIClient.swift */,
554553 12838EB3236779C700CEF108 /* ApiResolver.swift */,
555554 12838EAF236777D400CEF108 /* ServerError.swift */,
@@ -610,23 +609,6 @@
610609 path = "No reserv";
611610 sourceTree = "<group>";
612611 };
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− };
630612 12B3A7C123AD0751009E2FA6 /* Editing */ = {
631613 isa = PBXGroup;
632614 children = (
@@ -711,6 +693,8 @@
711693 12E35075239FAF8F004BB188 /* Resolvers */ = {
712694 isa = PBXGroup;
713695 children = (
696+ 12FC07B823C8D17600EDC55B /* DeleteOtherAdminResolver.swift */,
697+ 12B3A7B823ACCD83009E2FA6 /* AddOtherAdminResolver.swift */,
714698 12E35077239FAFA4004BB188 /* ClientsListResolver.swift */,
715699 12E3507C239FD1F3004BB188 /* ClientReservationsResolver.swift */,
716700 12D928B223C7464B0051724D /* BlocklistPutResolver.swift */,
@@ -1215,6 +1199,7 @@
12151199 F30369BE2336924D00A8EA84 /* ClientTabbarCoordinator.swift in Sources */,
12161200 F3FC7DFD2315C4710080D851 /* BaseCoordinator.swift in Sources */,
12171201 12E35071239FA8CA004BB188 /* Extensions+String.swift in Sources */,
1202+ 12FC07B923C8D17600EDC55B /* DeleteOtherAdminResolver.swift in Sources */,
12181203 F3DC59FF233E893400B5E751 /* Extensions+UIFont.swift in Sources */,
12191204 F3895F53233D5EEB00FA6A37 /* BlackButtonStyle.swift in Sources */,
12201205 12F9652C23868E7200FCA696 /* SecondStepView.swift in Sources */,
@@ -1228,7 +1213,6 @@
12281213 F3851B302340A513009EE0B6 /* RegistationViewModel.swift in Sources */,
12291214 12B3A7AF23AC1872009E2FA6 /* AdminNoReservationsView.swift in Sources */,
12301215 12838EAE2367701300CEF108 /* AuthorizationService.swift in Sources */,
1231− 12B3A7B723ACCD07009E2FA6 /* SettingsService.swift in Sources */,
12321216 12C72EDF23537D1B00AD7004 /* ProfileCoordinator.swift in Sources */,
12331217 12E3507D239FD1F3004BB188 /* ClientReservationsResolver.swift in Sources */,
12341218 12EA994E2362FCE8005D9FE9 /* AddressView.swift in Sources */,
Hookah Tau/API/ClientsService/ClientsService.swift+23
@@ -80,4 +80,27 @@ 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+ }
83106}
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 {
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/ClientsViewController.swift+42−1
@@ -140,6 +140,35 @@ class ClientsViewController: BaseTableViewController {
140140 }
141141 })
142142 }
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+ }
143172}
144173
145174// MARK: - Tableview
@@ -174,7 +203,7 @@ extension ClientsViewController {
174203 override func tableView(_ tableView: UITableView, editActionsForRowAt indexPath: IndexPath) -> [UITableViewRowAction]? {
175204
176205 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
178207
179208 self.updateUserBlockStatus(wasBlocked: user.isBlocked, phone: user.phoneNumber, indexPath: indexPath)
180209 }
@@ -183,6 +212,18 @@ extension ClientsViewController {
183212
184213 return [blockButton]
185214 }
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+ }
186227}
187228
188229extension ClientsViewController: UISearchResultsUpdating {
Hookah Tau/Controllers/Admin/Clients/Profile/ProfileTableViewController.swift+1−1
@@ -220,7 +220,7 @@ extension ProfileTableViewController: UITableViewDelegate, UITableViewDataSource
220220 func tableView(_ tableView: UITableView, editActionsForRowAt indexPath: IndexPath) -> [UITableViewRowAction]? {
221221
222222 let uuid = dataSource[indexPath.row].uuid
223− let cancelButton = UITableViewRowAction(style: .normal, title: "❌") { _,_ in
223+ let cancelButton = UITableViewRowAction(style: .normal, title: "отменить бронь") { _,_ in
224224
225225 self.deleteReservation(uuid: uuid) { optionalNewVal in
226226 if let newval = optionalNewVal {
Hookah Tau/Controllers/Admin/Reservations/List of reservations/AdminReservationsController.swift+1−1
@@ -196,7 +196,7 @@ extension AdminReservationsController: UITableViewDelegate, UITableViewDataSourc
196196 func tableView(_ tableView: UITableView, editActionsForRowAt indexPath: IndexPath) -> [UITableViewRowAction]? {
197197
198198 let uuid = activeReservations[indexPath.row].uuid
199− let cancelButton = UITableViewRowAction(style: .normal, title: "❌") { _,_ in
199+ let cancelButton = UITableViewRowAction(style: .normal, title: "отменить бронь") { _,_ in
200200
201201 self.deleteReservation(uuid: uuid) { optionalNewVal in
202202 if let newval = optionalNewVal {
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 {