feat: enhance opportunity detail and sales flow

This commit is contained in:
2026-03-03 19:46:12 -06:00
parent 9145ea5ba4
commit c628a78b27
13 changed files with 1030 additions and 88 deletions
+45 -2
View File
@@ -43,15 +43,50 @@
type Tab = (typeof tabs)[number];
let activeTab: Tab = "Overview";
// Track whether ProductsTab is in edit mode
let productsEditing = false;
/** Guard: block tab switch if ProductsTab has unsaved edits */
function guardedSetTab(tab: Tab) {
if (activeTab === tab) return;
if (productsEditing) {
if (!confirm('You have unsaved product changes. Discard and switch tabs?')) {
return;
}
productsEditing = false;
}
activeTab = tab;
}
// Product to auto-select when switching to Products tab
let pendingProductId: number | null = null;
function handleSelectProduct(e: CustomEvent<number>) {
pendingProductId = e.detail;
guardedSetTab("Products");
}
// Mobile nav state
let mobileActiveTab: Tab | null = null;
function selectMobileTab(tab: Tab) {
if (productsEditing) {
if (!confirm('You have unsaved product changes. Discard and switch tabs?')) {
return;
}
productsEditing = false;
}
activeTab = tab;
mobileActiveTab = tab;
}
function mobileBack() {
if (productsEditing) {
if (!confirm('You have unsaved product changes. Discard and go back?')) {
return;
}
productsEditing = false;
}
mobileActiveTab = null;
}
</script>
@@ -199,7 +234,7 @@
class:active={activeTab === tab}
role="tab"
aria-selected={activeTab === tab}
on:click={() => (activeTab = tab)}
on:click={() => guardedSetTab(tab)}
>
{tab}
{#if tab === "Products" && products.length > 0}
@@ -216,13 +251,21 @@
</div>
<div class="detail-pane-body">
{#if activeTab === "Overview"}
<OverviewTab {opportunity} {notes} {contacts} {products} />
<OverviewTab
{opportunity}
{notes}
{contacts}
{products}
on:selectProduct={handleSelectProduct}
/>
{:else if activeTab === "Products"}
<ProductsTab
{products}
accessToken={data.accessToken}
{opportunityId}
productSequence={opportunity?.productSequence ?? null}
initialProductId={pendingProductId}
bind:isEditing={productsEditing}
/>
{:else if activeTab === "Notes"}
<NotesTab