-
Notifications
You must be signed in to change notification settings - Fork 0
feat: [마이페이지] - 구매 내역 #30
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
The head ref may contain hidden characters: "feature/-\uB9C8\uC774\uD398\uC774\uC9C0-\uAD6C\uB9E4-\uB0B4\uC5ED-\uCD94\uAC00"
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
0319884
feat: 구매내역 모델 - Receipt.swift 정의
giljihun a38ae9b
style: 뭉치 아이템 구매 버튼, 팝업 하이파이 재적용
giljihun 34e9aa8
feat: ItemPurchaseManager - 구매내역 파베 추가 로직 구현 & 리팩토링
giljihun ac3e3ae
feat: 구매내역 루트 추가, 구매내역 뷰모델 구현
giljihun 2249a6f
feat: MyPageView - 구매내역 버튼 / 뷰 추가
giljihun a0b7a57
chore: Receipt - 아이템 타입 표시, 구매일시 포맷 추가
giljihun 05e714a
feat: PurchaseHistoryView - 구매내역 뷰 구현
giljihun 7b0ce22
feat: 로딩뷰 제거
giljihun c39658b
feat: PurchaseHistoryView - 구매내역 빈 경우 뷰 구현
giljihun File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| // | ||
| // Receipt.swift | ||
| // Keychy | ||
| // | ||
| // Created by 길지훈 on 1/28/26. | ||
| // | ||
|
|
||
| import Foundation | ||
| import FirebaseFirestore | ||
|
|
||
| struct Receipt: Identifiable, Codable { | ||
| @DocumentID var id: String? | ||
| var itemID: String | ||
| var itemName: String | ||
| var itemType: String | ||
| var price: Int | ||
| var purchasedAt: Date | ||
|
|
||
| /// 아이템 타입 표시명 | ||
| var itemTypeDisplayName: String { | ||
| switch itemType { | ||
| case "template": return "템플릿" | ||
| case "background": return "배경" | ||
| case "carabiner": return "카라비너" | ||
| case "particle": return "파티클" | ||
| case "sound": return "사운드" | ||
| default: return itemType | ||
| } | ||
| } | ||
|
|
||
| /// 구매일시 포맷 (2026-01-01 22:22:22) | ||
| var purchasedAtFormatted: String { | ||
| let formatter = DateFormatter() | ||
| formatter.dateFormat = "yyyy-MM-dd HH:mm:ss" | ||
| return formatter.string(from: purchasedAt) | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
Keychy/Keychy/Presentation/Home/ViewModels/PurchaseHistoryVIewModel.swift
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| // | ||
| // PurchaseHistoryVIewModel.swift | ||
| // Keychy | ||
| // | ||
| // Created by 길지훈 on 1/28/26. | ||
| // | ||
|
|
||
| import SwiftUI | ||
| import FirebaseFirestore | ||
|
|
||
| @Observable | ||
| class PurchaseHistoryViewModel { | ||
| var receipts: [Receipt] = [] | ||
|
|
||
| private let db = Firestore.firestore() | ||
|
|
||
| /// 구매내역 가져오기 | ||
| func fetchReceipts(userId: String) async { | ||
| do { | ||
| let snapshot = try await db | ||
| .collection("User") | ||
| .document(userId) | ||
| .collection("Receipts") | ||
| .order(by: "purchasedAt", descending: true) | ||
| .getDocuments() | ||
|
|
||
| receipts = snapshot.documents.compactMap { doc in | ||
| /// 각 Firebase 문서를 Codable 모델로 변환, Receipt 타입으로 변환 | ||
| try? doc.data(as: Receipt.self) | ||
| } | ||
|
|
||
| } catch { | ||
| print("구매내역 로드 실패: \(error.localizedDescription)") | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
오 좀 더 보기 좋게 잘 쪼개졌네요