Skip to content

Commit b51112a

Browse files
committed
Show store country question after the selling status question.
1 parent eae9a5b commit b51112a

File tree

2 files changed

+71
-13
lines changed

2 files changed

+71
-13
lines changed

WooCommerce/Classes/Authentication/Store Creation/StoreCreationCoordinator.swift

Lines changed: 40 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,7 @@ private extension StoreCreationCoordinator {
143143
self?.showDomainSelector(from: navigationController,
144144
storeName: storeName,
145145
categoryName: nil,
146+
countryCode: nil,
146147
planToPurchase: planToPurchase)
147148
}
148149
} onClose: { [weak self] in
@@ -325,27 +326,53 @@ private extension StoreCreationCoordinator {
325326
planToPurchase: WPComPlanProduct) {
326327
let questionController = StoreCreationSellingStatusQuestionHostingController(storeName: storeName) { [weak self] in
327328
guard let self else { return }
328-
self.showDomainSelector(from: navigationController, storeName: storeName, categoryName: categoryName, planToPurchase: planToPurchase)
329+
self.showStoreCountryQuestion(from: navigationController,
330+
storeName: storeName,
331+
categoryName: categoryName,
332+
planToPurchase: planToPurchase)
329333
} onSkip: { [weak self] in
330334
// TODO: analytics
331335
guard let self else { return }
332-
self.showDomainSelector(from: navigationController, storeName: storeName, categoryName: nil, planToPurchase: planToPurchase)
336+
self.showStoreCountryQuestion(from: navigationController,
337+
storeName: storeName,
338+
categoryName: categoryName,
339+
planToPurchase: planToPurchase)
333340
}
334341
navigationController.pushViewController(questionController, animated: true)
335342
// TODO: analytics
336343
}
337344

345+
@MainActor
346+
func showStoreCountryQuestion(from navigationController: UINavigationController,
347+
storeName: String,
348+
categoryName: String?,
349+
planToPurchase: WPComPlanProduct) {
350+
let questionController = StoreCreationCountryQuestionHostingController(viewModel:
351+
.init(storeName: storeName) { [weak self] countryCode in
352+
guard let self else { return }
353+
self.showDomainSelector(from: navigationController,
354+
storeName: storeName,
355+
categoryName: categoryName,
356+
countryCode: countryCode,
357+
planToPurchase: planToPurchase)
358+
})
359+
navigationController.pushViewController(questionController, animated: true)
360+
// TODO: analytics
361+
}
362+
338363
@MainActor
339364
func showDomainSelector(from navigationController: UINavigationController,
340365
storeName: String,
341366
categoryName: String?,
367+
countryCode: SiteAddress.CountryCode?,
342368
planToPurchase: WPComPlanProduct) {
343369
let domainSelector = DomainSelectorHostingController(viewModel: .init(initialSearchTerm: storeName),
344370
onDomainSelection: { [weak self] domain in
345371
guard let self else { return }
346372
await self.createStoreAndContinueToStoreSummary(from: navigationController,
347373
name: storeName,
348374
categoryName: categoryName,
375+
countryCode: countryCode,
349376
domain: domain,
350377
planToPurchase: planToPurchase)
351378
})
@@ -357,12 +384,17 @@ private extension StoreCreationCoordinator {
357384
func createStoreAndContinueToStoreSummary(from navigationController: UINavigationController,
358385
name: String,
359386
categoryName: String?,
387+
countryCode: SiteAddress.CountryCode?,
360388
domain: String,
361389
planToPurchase: WPComPlanProduct) async {
362390
let result = await createStore(name: name, domain: domain)
363391
switch result {
364392
case .success(let siteResult):
365-
showStoreSummary(from: navigationController, result: siteResult, categoryName: categoryName, planToPurchase: planToPurchase)
393+
showStoreSummary(from: navigationController,
394+
result: siteResult,
395+
categoryName: categoryName,
396+
countryCode: countryCode,
397+
planToPurchase: planToPurchase)
366398
case .failure(let error):
367399
analytics.track(event: .StoreCreation.siteCreationFailed(source: source.analyticsValue, error: error, flow: .native))
368400
showStoreCreationErrorAlert(from: navigationController, error: error)
@@ -382,8 +414,12 @@ private extension StoreCreationCoordinator {
382414
func showStoreSummary(from navigationController: UINavigationController,
383415
result: SiteCreationResult,
384416
categoryName: String?,
417+
countryCode: SiteAddress.CountryCode?,
385418
planToPurchase: WPComPlanProduct) {
386-
let viewModel = StoreCreationSummaryViewModel(storeName: result.name, storeSlug: result.siteSlug, categoryName: categoryName)
419+
let viewModel = StoreCreationSummaryViewModel(storeName: result.name,
420+
storeSlug: result.siteSlug,
421+
categoryName: categoryName,
422+
countryCode: countryCode)
387423
let storeSummary = StoreCreationSummaryHostingController(viewModel: viewModel) { [weak self] in
388424
guard let self else { return }
389425
self.showWPCOMPlan(from: navigationController,

WooCommerce/Classes/Authentication/Store Creation/StoreCreationSummaryView.swift

Lines changed: 31 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@ struct StoreCreationSummaryViewModel {
4545
let storeSlug: String
4646
/// Optional category name from the previous profiler question.
4747
let categoryName: String?
48+
/// Country code for the store location.
49+
/// `nil` only when the `storeCreationM3Profiler` feature flag is disabled.
50+
let countryCode: SiteAddress.CountryCode?
4851
}
4952

5053
/// Displays a summary of the store creation flow with the store information (e.g. store name, store slug).
@@ -77,7 +80,7 @@ struct StoreCreationSummaryView: View {
7780
}
7881
.background(Color(.systemColor(.systemGray6)))
7982

80-
VStack {
83+
VStack(alignment: .leading, spacing: 16) {
8184
VStack(alignment: .leading, spacing: Layout.spacingBetweenStoreNameAndDomain) {
8285
// Store name.
8386
Text(viewModel.storeName)
@@ -86,12 +89,18 @@ struct StoreCreationSummaryView: View {
8689
Text(viewModel.storeSlug)
8790
.foregroundColor(Color(.secondaryLabel))
8891
.bodyStyle()
89-
// Store category (optional).
90-
if let categoryName = viewModel.categoryName {
91-
Text(categoryName)
92-
.foregroundColor(Color(.label))
93-
.bodyStyle()
94-
}
92+
}
93+
// Store country.
94+
if let country = viewModel.country {
95+
Text(country)
96+
.foregroundColor(Color(.label))
97+
.bodyStyle()
98+
}
99+
// Store category (optional).
100+
if let categoryName = viewModel.categoryName {
101+
Text(categoryName)
102+
.foregroundColor(Color(.label))
103+
.bodyStyle()
95104
}
96105
}
97106
.padding(Layout.storeInfoPadding)
@@ -146,12 +155,25 @@ private extension StoreCreationSummaryView {
146155
}
147156
}
148157

158+
private extension StoreCreationSummaryViewModel {
159+
/// Text for the store country label.
160+
var country: String? {
161+
countryCode.map { [$0.readableCountry, $0.flagEmoji].compactMap { $0 }.joined(separator: " ") }
162+
}
163+
}
164+
149165
struct StoreCreationSummaryView_Previews: PreviewProvider {
150166
static var previews: some View {
151167
StoreCreationSummaryView(viewModel:
152-
.init(storeName: "Fruity shop", storeSlug: "fruityshop.com", categoryName: "Arts and Crafts"))
168+
.init(storeName: "Fruity shop",
169+
storeSlug: "fruityshop.com",
170+
categoryName: "Arts and Crafts",
171+
countryCode: .UG))
153172
StoreCreationSummaryView(viewModel:
154-
.init(storeName: "Fruity shop", storeSlug: "fruityshop.com", categoryName: "Arts and Crafts"))
173+
.init(storeName: "Fruity shop",
174+
storeSlug: "fruityshop.com",
175+
categoryName: "Arts and Crafts",
176+
countryCode: nil))
155177
.preferredColorScheme(.dark)
156178
}
157179
}

0 commit comments

Comments
 (0)