Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
L-j-h-c committed Jul 20, 2022
2 parents 2ef7564 + 7879cf0 commit ebbcbbe
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import Foundation

struct ScrapListEntity: Codable {
let _id, name, logo: String
let score: Int
let score: Double
let category: String
let hashtag: [String]
let address: String
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ extension MainDetailVC {
scrapButton.setImage(ImageLiterals.MainDetail.scrapIcon_filled, for: .selected)
scrapButton.addAction(UIAction(handler: { _ in
scrapButton.isSelected.toggle()
self.putScrap(userId: UserManager.shared.getUser?.id ?? "", restaurantId: self.restaurantId)
}), for: .touchUpInside)

reviewWriteCTAButton.layer.cornerRadius = 20
Expand Down Expand Up @@ -517,4 +518,15 @@ extension MainDetailVC {
}
}
}

private func putScrap(userId: String, restaurantId: String) {
UserService.shared.putScrap(userId: userId, restaurantId: restaurantId) { networkResult in
switch networkResult {
case .success(let message):
print(message)
default:
break;
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,7 @@ extension MainMapVC {
private func setDelegate() {
categoryCollectionView.delegate = self
categoryCollectionView.dataSource = self
mapDetailSummaryView.delegate = self
}

private func registerCell() {
Expand Down Expand Up @@ -570,6 +571,12 @@ extension MainMapVC: HamburgerbarVCDelegate {
}
}

extension MainMapVC: MapDetailSummaryViewDelegate {
func MapDetailSummaryViewScarp() {
putScrap(userId: UserManager.shared.getUser?.id ?? "", restaurantId: currentRestaurantId)
}
}

// MARK: - Network

extension MainMapVC {
Expand Down Expand Up @@ -616,4 +623,15 @@ extension MainMapVC {
}
}
}

private func putScrap(userId: String, restaurantId: String) {
UserService.shared.putScrap(userId: userId, restaurantId: restaurantId) { networkResult in
switch networkResult {
case .success(let message):
print(message)
default:
break;
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,16 @@ import UIKit

import SnapKit

protocol MapDetailSummaryViewDelegate: AnyObject {
func MapDetailSummaryViewScarp()
}

final class MapDetailSummaryView: UIView {

// MARK: - Properties

private var tagList = [String]()
weak var delegate: MapDetailSummaryViewDelegate?

// MARK: - UI Components

Expand All @@ -37,6 +42,7 @@ final class MapDetailSummaryView: UIView {
bt.setImage(ImageLiterals.MainDetail.scrapIcon_filled, for: .selected)
bt.addAction(UIAction(handler: { _ in
bt.isSelected.toggle()
self.delegate?.MapDetailSummaryViewScarp()
}), for: .touchUpInside)
return bt
}()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ extension ScrapCVC {
storeImageView.image = UIImage(named: data.logo)
storeNameLabel.text = data.name
locationLabel.text = data.address
restaurantId = data._id
}

private func setUI() {
Expand Down

0 comments on commit ebbcbbe

Please sign in to comment.