Эх сурвалжийг харах

Fix CV Maker CTA so Profile navigation always updates the UI.

Force the profiles list when handing off from template selection, alert when Profile is missing or Build CV has no pending template, and keep the bottom CTA above the scroll view on macOS.

Co-authored-by: Cursor <cursoragent@cursor.com>
AhtashamShahzad1 1 сар өмнө
parent
commit
a10585b8e3

+ 2 - 0
App for Indeed/Views/CVMakerPageView.swift

@@ -702,6 +702,8 @@ final class CVMakerPageView: NSView {
         super.layout()
         pageGradientLayer.frame = bounds
         layoutGridCardsIfNeeded()
+        // Keep the bottom CTA above the scroll view so template-grid scrolling cannot steal clicks.
+        addSubview(ctaButton, positioned: .above, relativeTo: nil)
     }
 
     func applyCurrentAppearance() {

+ 51 - 5
App for Indeed/Views/DashboardView.swift

@@ -1752,10 +1752,50 @@ final class DashboardView: NSView, NSTextFieldDelegate, NSSharingServicePickerDe
         }
     }
 
+    /// Sidebar index for **Profile** (`person` icon). Stable across language changes unlike title-only matching.
+    private func profileSidebarIndex() -> Int? {
+        if let index = currentSidebarItems.firstIndex(where: { $0.systemImage == "person" }) {
+            return index
+        }
+        return currentSidebarItems.firstIndex(where: { $0.title == L("Profile") })
+    }
+
     /// Switches the main panel to **Profile** so the user can pick a saved CV profile after choosing a template in CV Maker.
     private func selectProfileSidebarForCVMakerFlow() {
-        guard let index = currentSidebarItems.firstIndex(where: { $0.title == L("Profile") }) else { return }
-        selectSidebarItem(at: index)
+        guard let index = profileSidebarIndex() else {
+            presentDashboardAlert(
+                title: L("Couldn't open Profile"),
+                message: L("The Profile section isn't available right now. Try restarting the app.")
+            )
+            return
+        }
+        applyProfilePageForCVMakerHandoff(selectingSidebarIndex: index)
+    }
+
+    /// Always shows the profiles list for the CV Maker hand-off (avoids `selectSidebarItem` no-op when Profile is already selected).
+    private func applyProfilePageForCVMakerHandoff(selectingSidebarIndex index: Int) {
+        isIndeedSidebarSelected = false
+        dismissIndeedJobBrowserEmbedded()
+        guard index >= 0, index < currentSidebarItems.count else { return }
+
+        isCVDocumentPreviewPresented = false
+        isProfileEditorPresented = false
+        selectedSidebarIndex = index
+        configureSidebar()
+        updateMainContentVisibility()
+    }
+
+    private func presentDashboardAlert(title: String, message: String) {
+        let alert = NSAlert()
+        alert.messageText = title
+        alert.informativeText = message
+        alert.alertStyle = .informational
+        alert.addButton(withTitle: L("OK"))
+        if let window {
+            alert.beginSheetModal(for: window)
+        } else {
+            alert.runModal()
+        }
     }
 
     private func configureProfilePage() {
@@ -1798,9 +1838,15 @@ final class DashboardView: NSView, NSTextFieldDelegate, NSSharingServicePickerDe
             self?.confirmDeleteProfile(id: id)
         }
         profilesListPageView.onBuildCVWithProfile = { [weak self] profileID in
-            guard let self,
-                  let template = self.pendingCVTemplate,
-                  let profile = SavedProfilesStore.profile(id: profileID) else { return }
+            guard let self else { return }
+            guard let template = self.pendingCVTemplate else {
+                self.presentDashboardAlert(
+                    title: L("No template selected"),
+                    message: L("Choose a template in CV Maker, then tap Use Template & Select Profile before Build CV.")
+                )
+                return
+            }
+            guard let profile = SavedProfilesStore.profile(id: profileID) else { return }
             self.presentCVDocumentPreview(profile: profile, template: template)
         }
         cvFilledPreviewPageView.onDismiss = { [weak self] in