Skip to content

Commit

Permalink
Merge pull request #74 from APPSCHOOL1-REPO/server/230103-CustomerSer…
Browse files Browse the repository at this point in the history
…vice-Dahae

Server/230103 customer service dahae #4
  • Loading branch information
jeonghoonji authored Jan 3, 2023
2 parents b5d65d7 + f6754ee commit 8e56c6e
Show file tree
Hide file tree
Showing 10 changed files with 240 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@
6713F70F295B2386009ABA8C /* SignUpViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6713F70E295B2386009ABA8C /* SignUpViewModel.swift */; };
67C798B5295BD09100E13A16 /* PopupView in Frameworks */ = {isa = PBXBuildFile; productRef = 67C798B4295BD09100E13A16 /* PopupView */; };
67C798B7295C0F8000E13A16 /* SafariView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 67C798B6295C0F8000E13A16 /* SafariView.swift */; };
68127C612963E0FE003948B4 /* CustomerServiceInfo.swift in Sources */ = {isa = PBXBuildFile; fileRef = 68127C602963E0FE003948B4 /* CustomerServiceInfo.swift */; };
68127C632963E4CC003948B4 /* CustomerServiceStore.swift in Sources */ = {isa = PBXBuildFile; fileRef = 68127C622963E4CC003948B4 /* CustomerServiceStore.swift */; };
68127C662963F355003948B4 /* Timestamp+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 68127C652963F355003948B4 /* Timestamp+Extension.swift */; };
68127C682964004E003948B4 /* OrderInfo.swift in Sources */ = {isa = PBXBuildFile; fileRef = 68127C672964004E003948B4 /* OrderInfo.swift */; };
68C75ADF295C1DDF00ABC20A /* GoogleService-Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = 68C75ADE295C1DDF00ABC20A /* GoogleService-Info.plist */; };
68C75AE3295C2DB500ABC20A /* CustomerInfo.swift in Sources */ = {isa = PBXBuildFile; fileRef = 68C75AE2295C2DB500ABC20A /* CustomerInfo.swift */; };
702BCF88295C601800955AA2 /* ProductDetailModifiers.swift in Sources */ = {isa = PBXBuildFile; fileRef = 702BCF87295C601800955AA2 /* ProductDetailModifiers.swift */; };
Expand Down Expand Up @@ -88,6 +92,10 @@
287EA667296272B90018C42B /* ManageAddressView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ManageAddressView.swift; sourceTree = "<group>"; };
6713F70E295B2386009ABA8C /* SignUpViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SignUpViewModel.swift; sourceTree = "<group>"; };
67C798B6295C0F8000E13A16 /* SafariView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SafariView.swift; sourceTree = "<group>"; };
68127C602963E0FE003948B4 /* CustomerServiceInfo.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CustomerServiceInfo.swift; sourceTree = "<group>"; };
68127C622963E4CC003948B4 /* CustomerServiceStore.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CustomerServiceStore.swift; sourceTree = "<group>"; };
68127C652963F355003948B4 /* Timestamp+Extension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Timestamp+Extension.swift"; sourceTree = "<group>"; };
68127C672964004E003948B4 /* OrderInfo.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OrderInfo.swift; sourceTree = "<group>"; };
68C75ADE295C1DDF00ABC20A /* GoogleService-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "GoogleService-Info.plist"; sourceTree = "<group>"; };
68C75AE2295C2DB500ABC20A /* CustomerInfo.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CustomerInfo.swift; sourceTree = "<group>"; };
702BCF87295C601800955AA2 /* ProductDetailModifiers.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ProductDetailModifiers.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -187,10 +195,19 @@
path = ShoppingBack;
sourceTree = "<group>";
};
68127C642963F33E003948B4 /* Extension */ = {
isa = PBXGroup;
children = (
68127C652963F355003948B4 /* Timestamp+Extension.swift */,
);
path = Extension;
sourceTree = "<group>";
};
68C75AE0295C1E3800ABC20A /* Store */ = {
isa = PBXGroup;
children = (
6713F70E295B2386009ABA8C /* SignUpViewModel.swift */,
68127C622963E4CC003948B4 /* CustomerServiceStore.swift */,
);
path = Store;
sourceTree = "<group>";
Expand All @@ -199,7 +216,9 @@
isa = PBXGroup;
children = (
68C75AE2295C2DB500ABC20A /* CustomerInfo.swift */,
68127C602963E0FE003948B4 /* CustomerServiceInfo.swift */,
04E6F06329626BEF00AD8A44 /* Fundamentals.swift */,
68127C672964004E003948B4 /* OrderInfo.swift */,
);
path = Model;
sourceTree = "<group>";
Expand Down Expand Up @@ -249,6 +268,7 @@
A77EE65F295A9A5100B6AA64 /* big-project-a-customer-ios */ = {
isa = PBXGroup;
children = (
68127C642963F33E003948B4 /* Extension */,
68C75ADE295C1DDF00ABC20A /* GoogleService-Info.plist */,
A7A0BBE42963E39F00C4CB00 /* Modifiers */,
A78DA20D295C4F880047C5AE /* Payment */,
Expand Down Expand Up @@ -512,6 +532,7 @@
6713F70F295B2386009ABA8C /* SignUpViewModel.swift in Sources */,
22CC75F2296272C000899147 /* ProductDetailTotalReview.swift in Sources */,
A78DA21C295C4F9C0047C5AE /* PaymentView.swift in Sources */,
68127C612963E0FE003948B4 /* CustomerServiceInfo.swift in Sources */,
A78DA18C295C1E590047C5AE /* QuestionDetailView.swift in Sources */,
A7A0BBE62963E3AE00C4CB00 /* Modifiers.swift in Sources */,
A78DA211295C4F940047C5AE /* PurchaseInfo.swift in Sources */,
Expand All @@ -523,10 +544,13 @@
A78DA21B295C4F9C0047C5AE /* ToSView.swift in Sources */,
A78DA178295C1CC80047C5AE /* ShoppingBackView.swift in Sources */,
C4961A61295AAF25009CB1EC /* SignUpView.swift in Sources */,
68127C682964004E003948B4 /* OrderInfo.swift in Sources */,
68127C662963F355003948B4 /* Timestamp+Extension.swift in Sources */,
A78DA21A295C4F9C0047C5AE /* CashRecieptView.swift in Sources */,
A78DA1F7295C44FF0047C5AE /* MyPageInfo+ViewModifiers.swift in Sources */,
22CC75EF2962654300899147 /* ProductDetailReviewSection.swift in Sources */,
C4961A5F295AAEF4009CB1EC /* LoginView.swift in Sources */,
68127C632963E4CC003948B4 /* CustomerServiceStore.swift in Sources */,
A78DA1FB295C450F0047C5AE /* MyPageInfoView.swift in Sources */,
A78DA186295C1E590047C5AE /* CardView.swift in Sources */,
C08D4953296275C00035A01D /* QnARegistView.swift in Sources */,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
//
// Timestamp+Extension.swift
// big-project-a-customer-ios
//
// Created by Da Hae Lee on 2023/01/03.
//

import Foundation
import Firebase

extension Timestamp {
/// Timestamp로 날짜를 받아올 때, 날짜를 한국식 날짜로 받아오는 함수 입니다.
/// 타임스탬프의 인스턴스(fetch된 데이터)에서 호출합니다.
/// 리턴할 때는 String 타입으로 리턴합니다.
public func formattedKoreanTime() -> String {
let date = self.dateValue()
let dateFormatter = DateFormatter()
dateFormatter.locale = Locale(identifier: "ko-KR")
dateFormatter.dateFormat = "yyyy-MM-dd HH:mm"
return dateFormatter.string(from: date)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ struct PurchaseDetail: View {

ForEach(0..<3){ _ in
VStack {
PurchaseListCell(orderStore: orderStore, order: OrderInfo(orderDate: "2022. 12. 27", itemAmount: 1, price: 24900, deliveryStatusText: "배송중", itemName: "유그린 메탈쉘 외장하드 케이스 C to USB3.0", itemImage: "itemImage"), index: 1, isDeliveryCompleted: $check)
PurchaseListCell(orderStore: orderStore, order: DummyOrderInfo(orderDate: "2022. 12. 27", itemAmount: 1, price: 24900, deliveryStatusText: "배송중", itemName: "유그린 메탈쉘 외장하드 케이스 C to USB3.0", itemImage: "itemImage"), index: 1, isDeliveryCompleted: $check)
}
}
Button {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import SwiftUI
import PopupView

enum DeliveryStatusEnum: String {
enum DummyDeliveryStatusEnum: String {
// 배송중
// 배송완료
// 배송준비중
Expand All @@ -19,25 +19,25 @@ enum DeliveryStatusEnum: String {
case createReview
}

struct OrderInfo: Identifiable {
struct DummyOrderInfo: Identifiable {
var id = UUID().uuidString
var orderDate: String
var itemAmount: Int
var price: Int
var deliveryStatusText: String
var itemName: String
var itemImage: String
var deliveryStatus: DeliveryStatusEnum = .pending
var deliveryStatus: DummyDeliveryStatusEnum = .pending
}

class OrderInfoViewModel: ObservableObject {
// ShoppingCartItems 약자
@Published var orders: [OrderInfo] = [
OrderInfo(orderDate: "2022. 12. 27", itemAmount: 1, price: 24900, deliveryStatusText: "배송중", itemName: "유그린 메탈쉘 외장하드 케이스 C to USB3.0", itemImage: "itemImage"),
OrderInfo(orderDate: "2022. 11. 30", itemAmount: 1, price: 24900, deliveryStatusText: "배송완료", itemName: "벨킨 부스트업 24W 듀얼 A타입 가정용 충전기 WCB002krWH, 화이트", itemImage: "itemImage", deliveryStatus: .deliveryCompleted),
OrderInfo(orderDate: "2022. 11. 28", itemAmount: 1, price: 66400, deliveryStatusText: "배송완료", itemName: "벨킨 7in1 USB C타입 멀티 허브 AVC009btSGY, 그레이", itemImage: "itemImage", deliveryStatus: .createReview),
OrderInfo(orderDate: "2022. 09. 30", itemAmount: 1, price: 34900, deliveryStatusText: "배송완료", itemName: "트리플블랙 RX 4in1 충전 스테이션, 블랙", itemImage: "itemImage", deliveryStatus: .deliveryCompleted),
OrderInfo(orderDate: "2022. 09.30", itemAmount: 1, price: 20800, deliveryStatusText: "배송완료", itemName: "벨킨 부스트업 USB C to 라이트닝 아이폰 고속 충전케이블 CAA003bt1MBK, 1m, 블랙", itemImage: "itemImage", deliveryStatus: .deliveryCompleted)
@Published var orders: [DummyOrderInfo] = [
DummyOrderInfo(orderDate: "2022. 12. 27", itemAmount: 1, price: 24900, deliveryStatusText: "배송중", itemName: "유그린 메탈쉘 외장하드 케이스 C to USB3.0", itemImage: "itemImage"),
DummyOrderInfo(orderDate: "2022. 11. 30", itemAmount: 1, price: 24900, deliveryStatusText: "배송완료", itemName: "벨킨 부스트업 24W 듀얼 A타입 가정용 충전기 WCB002krWH, 화이트", itemImage: "itemImage", deliveryStatus: .deliveryCompleted),
DummyOrderInfo(orderDate: "2022. 11. 28", itemAmount: 1, price: 66400, deliveryStatusText: "배송완료", itemName: "벨킨 7in1 USB C타입 멀티 허브 AVC009btSGY, 그레이", itemImage: "itemImage", deliveryStatus: .createReview),
DummyOrderInfo(orderDate: "2022. 09. 30", itemAmount: 1, price: 34900, deliveryStatusText: "배송완료", itemName: "트리플블랙 RX 4in1 충전 스테이션, 블랙", itemImage: "itemImage", deliveryStatus: .deliveryCompleted),
DummyOrderInfo(orderDate: "2022. 09.30", itemAmount: 1, price: 20800, deliveryStatusText: "배송완료", itemName: "벨킨 부스트업 USB C to 라이트닝 아이폰 고속 충전케이블 CAA003bt1MBK, 1m, 블랙", itemImage: "itemImage", deliveryStatus: .deliveryCompleted)
]
}

Expand Down Expand Up @@ -101,7 +101,7 @@ struct PurchaseHistoryView: View {
// MARK: 재사용하기 위한 구매목록 cell
struct PurchaseListCell: View {
@ObservedObject var orderStore: OrderInfoViewModel
var order: OrderInfo
var order: DummyOrderInfo
let index: Int
@Binding var isDeliveryCompleted: Bool

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ struct QnA: Identifiable {

struct QnAListView: View {
@ObservedObject var questionViewModel: QuestionViewModel = QuestionViewModel()
@ObservedObject var customerServiceStore: CustomerServiceStore = CustomerServiceStore()
let tempItemId: String = "watch1"

var body: some View {
if items.isEmpty {
Expand Down Expand Up @@ -42,17 +44,26 @@ struct QnAListView: View {
}
}

AddQnAButton()
AddQnAButton(csStore: customerServiceStore)
}

.navigationTitle("상품 문의")
.onAppear {
Task {

await customerServiceStore.requestCustomerServiceList(itemId: tempItemId)
}
}
}

}
}

struct AddQnAButton: View {
@ObservedObject var csStore: CustomerServiceStore

var body: some View {
NavigationLink(destination: QnARegistView()) {
NavigationLink(destination: QnARegistView(customerServiceStore: csStore)) {
Image(systemName: "plus.circle.fill")
.font(.system(size: 48))
.foregroundColor(.accentColor)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import SwiftUI

struct QnARegistView: View {
@Environment(\.presentationMode) var presentationMode: Binding<PresentationMode>
@EnvironmentObject var signupViewModel: SignUpViewModel
@ObservedObject var customerServiceStore: CustomerServiceStore
@State private var text: String = ""

var body: some View {
Expand All @@ -25,6 +27,9 @@ struct QnARegistView: View {
.padding(.bottom, 16)

Button(action: {
Task {
await customerServiceStore.createCustomerService(title: "test title", description: text, userId: signupViewModel.currentUser?.id ?? "")
}
presentationMode.wrappedValue.dismiss()
}) {
HStack {
Expand All @@ -48,7 +53,9 @@ struct QnARegistView: View {
}

struct QnARegistView_Previews: PreviewProvider {
@ObservedObject static var customerServiceStore: CustomerServiceStore = CustomerServiceStore.shared

static var previews: some View {
QnARegistView()
QnARegistView(customerServiceStore: customerServiceStore)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
//
// CustomerServiceInfo.swift
// big-project-a-customer-ios
//
// Created by Da Hae Lee on 2023/01/03.
//

import Foundation
import Firebase

typealias ItemAllOption = [String:[String]]?

// MARK: - 고객 서비스를 위한 모델
/// 제품 문의 기능에서 사용하는 데이터 모델입니다.
struct CustomerServiceInfo: Identifiable {
var id: String
var title: String // 문의 제목
var description: String // 문의 내역
var itemId: String // 문의를 하려는 제품 id
var itemName: String // 문의를 하려는 제품명
var itemImage: [String] // 문의를 하려는 제품의 이미지(배열)
var serviceDate: Timestamp // 문의 날짜
var customerId: String // 작성자
var orderId: String // 주문번호
var itemAllOption: ItemAllOption? // 선택한 제품 옵션
var isAnswered: Bool = false // 판매자 답글 여부

var formattedServiceDate: String {
get {
serviceDate.formattedKoreanTime()
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@ let appCategory: AppCategoryEnum = .customer
/// - 현재 앱에서는 판매자용 iPad 앱임을 나타내기 위해 전역 상수로 .store 가 할당되어 있습니다.
/// - 해당 열거형의 원시값을 활용하여 Firebase의 콜렉션에 접근합니다.
enum AppCategoryEnum: String, Codable {
case customer = "CustomerInfo", store = "StoreInfo", backoffice = "AdminInfo"
case customer = "CustomerInfo", store = "StoreInfo", backoffice = "AdminInfo", cs = "CustomerServiceInfo"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
//
// OrderInfo.swift
// big-project-a-customer-ios
//
// Created by Da Hae Lee on 2023/01/03.
//

import Foundation

struct ItemOptions: Codable {
var itemOptions: [String: [String]]
}

struct OrderInfo: Codable {
var orderId: String = UUID().uuidString
var orderedUserInfo: String
var orderTime: Double
var orderedItems: [OrderedItemInfo]
var orderAddress: String
var orderMessage: String?
var payment: PaymentEnum = .byCreditCard
}

struct OrderedItemInfo: Codable {
var itemUid: String
var itemName: String
var itemImage: [String]
var price: Double
var option: ItemOptions
var deliveryStatus: DeliveryStatusEnum = .pending
}

enum DeliveryStatusEnum: String, Codable {
case beforePurchase = "구매전"
case pending = "배송준비중"
case onDeliverying = "배송중"
case didDelivered = "배송완료"
case reviewable = "리뷰작성 가능"
case reviewed = "리뷰작성 완료"
}

enum PaymentEnum: String, Codable {
case byCreditCard = "카드결제", byAccount = "무통장입금", byMobile = "핸드폰결제"
}
Loading

0 comments on commit 8e56c6e

Please sign in to comment.