Skip to content

Commit 2c6770d

Browse files
authored
✨ Display selected year sponsor (#113)
* Display selected year sponsor * Fix tests include SponsorsTests * Show sponsors section if any plan has data. * [Review] Modify fetch sponsors switch case
1 parent 468d6d2 commit 2c6770d

File tree

16 files changed

+33
-10
lines changed

16 files changed

+33
-10
lines changed

MyLibrary/Sources/DataClient/Client.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ public struct DataClient {
88
public var fetchDay1: @Sendable () throws -> Conference
99
public var fetchDay2: @Sendable () throws -> Conference
1010
public var fetchDay3: @Sendable () throws -> Conference
11-
public var fetchSponsors: @Sendable () throws -> Sponsors
11+
public var fetchSponsors: @Sendable (_ year: ConferenceYear) throws -> Sponsors
1212
public var fetchOrganizers: @Sendable () throws -> [Organizer]
1313
public var fetchSpeakers: @Sendable () throws -> [Speaker]
1414
}
@@ -31,8 +31,8 @@ extension DataClient: DependencyKey {
3131
let response = try jsonDecoder.decode(Conference.self, from: data)
3232
return response
3333
},
34-
fetchSponsors: {
35-
let data = loadDataFromBundle(fileName: "sponsors")
34+
fetchSponsors: { year in
35+
let data = loadDataFromBundle(fileName: "\(year.rawValue)-sponsors")
3636
let response = try jsonDecoder.decode(Sponsors.self, from: data)
3737
return response
3838
},
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"platinum": [],
3+
"gold": [],
4+
"silver": [],
5+
"bronze": [],
6+
"diversity": [],
7+
"student": [],
8+
"community": [],
9+
"individual": []
10+
}
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
enum ConferenceYear: Int, CaseIterable {
1+
public enum ConferenceYear: Int, CaseIterable {
22
case year2025 = 2025
33
case year2026 = 2026
44

5-
static var latest: Self {
5+
public static var latest: Self {
66
Self.allCases.max(by: { $0.rawValue < $1.rawValue })!
77
}
88
}

MyLibrary/Sources/SponsorFeature/Sponsors.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public struct SponsorsList {
4040
Reduce { state, action in
4141
switch action {
4242
case .view(.onAppear):
43-
state.sponsors = try! dataClient.fetchSponsors()
43+
state.sponsors = try! dataClient.fetchSponsors(.year2026)
4444
return .none
4545

4646
case .view(.sponsorTapped(let sponsor)):

MyLibrary/Tests/SponsorFeatureTests/SponsorsTests.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@ final class SponsorsTests: XCTestCase {
1212
let store = TestStore(initialState: SponsorsList.State()) {
1313
SponsorsList()
1414
} withDependencies: {
15-
$0[DataClient.self].fetchSponsors = { @Sendable in .mock }
15+
$0[DataClient.self].fetchSponsors = { @Sendable (_: ConferenceYear) throws -> Sponsors in
16+
.mock
17+
}
1618
}
1719

1820
await store.send(\.view.onAppear) {

Website/Sources/Components/AccessComponent.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import Ignite
2+
import SharedModels
23

34
struct AccessComponent: HTML {
45
let year: ConferenceYear

Website/Sources/Components/MainFooter.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import Foundation
22
import Ignite
3+
import SharedModels
34

45
struct MainFooter: HTML {
56
let year: ConferenceYear

Website/Sources/Components/MainFooterWithBackground.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import Ignite
2+
import SharedModels
23

34
struct MainFooterWithBackground: HTML {
45
let year: ConferenceYear

Website/Sources/Components/MainNavigationBar.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import Ignite
2+
import SharedModels
23

34
struct MainNavigationBar: HTML {
45
let path: (ConferenceYear, SupportedLanguage) -> String

0 commit comments

Comments
 (0)