Skip to content

Commit

Permalink
Merge pull request #84 from APPSCHOOL1-REPO/origin/server/230104-Shop…
Browse files Browse the repository at this point in the history
…pingBag-Hakjin

[Feat] OrderItemStore 연결 작업
  • Loading branch information
jeonghoonji authored Jan 4, 2023
2 parents ab6d6a8 + 92e2fb1 commit aa905f9
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ struct ProductDetailModalView: View {
@State var count: Int = 1 // 수량
@Binding var isActive: Bool
@State private var isShowingPopup = false

@Environment var orderItemStore: OrderItemStore
@Environment var signUpViewModel: SignUpViewModel

var optionsArray: [String] {
Array(tempVM.options.keys).sorted()
Expand Down Expand Up @@ -91,7 +94,7 @@ struct ProductDetailModalView: View {

HStack {
Button {

// orderItemStore.createShoppingItem(uid: signUpViewModel.currentUser?.id ?? "", item: <#T##OrderItemInfo#>)
dismiss()
} label: {
HStack {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ struct ShoppingBackView: View {
@State var isShowingLoginSheet = false
@EnvironmentObject var signUpViewModel: SignUpViewModel

@State var checkDict: [String:Bool] = [:]

// 결제할 총 금액
var totalPrice: Int {
return vm.sCItems
Expand Down Expand Up @@ -244,8 +246,9 @@ struct ShoppingBackView: View {
LoginView()
.onDisappear {
Task {
await shoppingStores.requestShoppingList(uid: signUpViewModel.currentUser?.id ?? "")
shoppingStores.updateShoppingItem(uid: signUpViewModel.currentUser?.id ?? "", itemUID: "7fEFIEBtfZxUGuskuLwg", newAmount: 2)
await fetchData()

// shoppingStores.updateShoppingItem(uid: signUpViewModel.currentUser?.id ?? "", itemUID: "7fEFIEBtfZxUGuskuLwg", newAmount: 2)
}
}
}
Expand All @@ -258,20 +261,38 @@ struct ShoppingBackView: View {
return
}
Task {
await shoppingStores.requestShoppingList(uid: signUpViewModel.currentUser?.id ?? "")
await fetchData()
}
}
}
}

func fetchData() async {
await shoppingStores.requestShoppingList(uid: signUpViewModel.currentUser?.id ?? "")

for item in shoppingStores.items {
checkDict[item.itemuid] = false
}
}

func checkBoxAll() {
// if isCheckedAll {
// for index in vm.sCItems.indices {
// vm.sCItems[index].isChecked = true
// }
// } else {
// for index in vm.sCItems.indices {
// vm.sCItems[index].isChecked = false
// }
// }

if isCheckedAll {
for index in vm.sCItems.indices {
vm.sCItems[index].isChecked = true
for (key, _) in checkDict {
checkDict[key] = true
}
} else {
for index in vm.sCItems.indices {
vm.sCItems[index].isChecked = false
for (key, _) in checkDict {
checkDict[key] = false
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class OrderItemStore: ObservableObject {
let newOptions: [String: String] = changeOptionsLocalToServer(item.option)

// Document의 id(name)는 상품의 id여야 한다.
firebasePath.document(uid).collection("MyCart").document(uid).setData([
firebasePath.document(uid).collection("MyCart").document(item.itemuid).setData([
"itemuid": item.itemuid,
"storeId": item.storeId,
"itemName": item.itemName,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ struct big_project_a_customer_iosApp: App {
ContentView()
.environmentObject(MyReviewViewModel())
.environmentObject(SignUpViewModel())
.environmentObject(OrderItemStore())
}
}
}

0 comments on commit aa905f9

Please sign in to comment.