Skip to content

Commit

Permalink
🪛[chore] : bake model 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
Roy-wonji committed Nov 4, 2023
1 parent 3168c0e commit 891b885
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ public class AuthorizationViewModel: ObservableObject {
print("네트 워크 에러", error.localizedDescription)
}
}, receiveValue: { [weak self] model in
if model.status == 200 {
if model.status == NetworkCode.success.status {
self?.signupToViewModel(model)
self?.userid = model.data?.id ?? .zero
print("회원가입 성공", model)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public struct BakeModel: Codable {
}

// MARK: - DataClass
struct BakeResponseModel: Codable {
public struct BakeResponseModel: Codable {
public let regDttm, modDttm, regrID: String?
public let regrNm: String?
public let modrID: String
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ public struct ChoiceBreadView: View {
.resizable()
.frame(width:56, height: 56)
)
Text(source.type.korean)
Text(source.type.bread.korean)
.pretendardFont(family: .SemiBold, size: 14)
}
.onTapGesture {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ struct FamousSayingBakeCardView: View {
.frame(height: 17)

// FIXME: Swagger 수정 후 추천 받은 명언으로 카드를 바꿔야합니다 :)
if let card = viewModel.cards.last {
if let card = bakeViewModel.bakeCard {
bakeCardView(card: card)
}

Expand All @@ -58,13 +58,11 @@ struct FamousSayingBakeCardView: View {
self.viewModel.tmpChoicedTopping = nil
}
.task {
bakeViewModel.bakeQuoteRequest(userId: "423",
await bakeViewModel.bakeQuoteRequest(userId: "423",
flavor: (viewModel.selectFlavor?.type.english) ?? "",
source: (viewModel.selectSource?.type.english) ?? "",
mood: (viewModel.selectMood?.type.english) ?? "", completion: {

})
authViewModel.searchUserIdRequest(uid: "423")
mood: (viewModel.selectMood?.type.english) ?? "")
// authViewModel.searchUserIdRequest(uid: "423")
}
.onDisappear {
self.viewModel.choicedBread = nil
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,9 @@ struct FamousSayingBakeView: View {
DispatchQueue.main.asyncAfter(deadline: .now() + 4) {
appState.isCompleteBake.toggle()

bakeViewModel.bakeQuoteRequest(userId: "423", flavor: viewModel.selectFlavor?.type.english ?? "", source: viewModel.selectSource?.type.english ?? "", mood: viewModel.selectMood?.type.english ?? "")
Task {
await bakeViewModel.bakeQuoteRequest(userId: "423", flavor: viewModel.selectFlavor?.type.english ?? "", source: viewModel.selectSource?.type.english ?? "", mood: viewModel.selectMood?.type.english ?? "")
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public class BakeViewModel: ObservableObject {

@Published public var bakeQuoteModel: BakeModel?
var bakeQuoteCancellable: AnyCancellable?

@Published public var bakeCard: CardInfomation?

public init() {

Expand Down Expand Up @@ -74,9 +74,8 @@ public class BakeViewModel: ObservableObject {
userId: String,
flavor: String,
source: String,
mood: String,
completion: @escaping () -> Void
) {
mood: String
) async {
if let cancellable = bakeQuoteCancellable {
cancellable.cancel()
}
Expand All @@ -98,11 +97,24 @@ public class BakeViewModel: ObservableObject {
if status == NetworkCode.success.status {
self?.bakequoteCodeToViewModel(model)
print("홈화면 랜덤 명언 굽기", model)
completion()
if let hashtags = self?.getHashtags(post: model) {
self?.bakeCard = CardInfomation(qouteId: model.data?.quoteID ?? .zero, hashtags: hashtags, image: "", title: model.data?.content ?? "", sources: model.data?.author ?? "", isBookrmark: false)
} else {

}

}
}
})
}

public func getHashtags(post: BakeModel) -> Hashtags {
let flavor = Flavor(rawValue: post.data?.flavor ?? "")!
let source = Source(rawValue: post.data?.source ?? "")!
let mood = Mood(rawValue: post.data?.mood ?? "")!

return Hashtags(flavor: flavor, source: source, mood: mood)
}
}


0 comments on commit 891b885

Please sign in to comment.