From 987c778ae2369e05205305fd151ec817dd658867 Mon Sep 17 00:00:00 2001 From: Peter Date: Thu, 16 Apr 2026 01:52:31 +0100 Subject: [PATCH] feat: add State C success panel, expand SavedListingsService.Save with draft fields --- .../Services/SavedListingsService.cs | 12 ++++- EbayListingTool/Views/NewListingView.xaml | 48 +++++++++++++++++-- EbayListingTool/Views/NewListingView.xaml.cs | 25 ++++++++-- 3 files changed, 76 insertions(+), 9 deletions(-) diff --git a/EbayListingTool/Services/SavedListingsService.cs b/EbayListingTool/Services/SavedListingsService.cs index dedb37f..8507940 100644 --- a/EbayListingTool/Services/SavedListingsService.cs +++ b/EbayListingTool/Services/SavedListingsService.cs @@ -1,4 +1,4 @@ -using EbayListingTool.Models; +using EbayListingTool.Models; using Newtonsoft.Json; namespace EbayListingTool.Services; @@ -35,7 +35,11 @@ public class SavedListingsService public (SavedListing Listing, int SkippedPhotos) Save( string title, string description, decimal price, string category, string conditionNotes, - IEnumerable sourcePaths) + IEnumerable sourcePaths, + string categoryId = "", + ItemCondition condition = ItemCondition.Used, + ListingFormat format = ListingFormat.FixedPrice, + string postcode = "") { var safeName = MakeSafeFilename(title); var exportDir = UniqueDir(Path.Combine(ExportsDir, safeName)); @@ -68,6 +72,10 @@ public class SavedListingsService Description = description, Price = price, Category = category, + CategoryId = categoryId, + Condition = condition, + Format = format, + Postcode = postcode, ConditionNotes = conditionNotes, ExportFolder = exportDir, PhotoPaths = photoPaths diff --git a/EbayListingTool/Views/NewListingView.xaml b/EbayListingTool/Views/NewListingView.xaml index 2610f01..2a17b31 100644 --- a/EbayListingTool/Views/NewListingView.xaml +++ b/EbayListingTool/Views/NewListingView.xaml @@ -1,4 +1,4 @@ - - - + + + + + + + + + + + + + + + + + + diff --git a/EbayListingTool/Views/NewListingView.xaml.cs b/EbayListingTool/Views/NewListingView.xaml.cs index 59fceb4..f223568 100644 --- a/EbayListingTool/Views/NewListingView.xaml.cs +++ b/EbayListingTool/Views/NewListingView.xaml.cs @@ -1,4 +1,4 @@ -using System.Windows; +using System.Windows; using System.Windows.Controls; using System.Windows.Input; using System.Windows.Media.Imaging; @@ -633,7 +633,9 @@ public partial class NewListingView : UserControl _savedService.Save( _draft.Title, _draft.Description, _draft.Price, _draft.CategoryName, GetSelectedCondition().ToString(), - _draft.PhotoPaths); + _draft.PhotoPaths, + _draft.CategoryId, _draft.Condition, _draft.Format, + BPostcodeBox.Text); GetWindow()?.RefreshSavedListings(); GetWindow()?.SetStatus($"Draft saved: {_draft.Title}"); SaveDraftBtn.IsEnabled = false; @@ -654,8 +656,7 @@ public partial class NewListingView : UserControl { var url = await _listingService.PostListingAsync(_draft); _draft.EbayListingUrl = url; - var urlBox = FindName("BSuccessUrl") as TextBlock; - if (urlBox != null) urlBox.Text = url; + BSuccessUrl.Text = url; SetState(ListingState.Success); GetWindow()?.SetStatus($"Listed: {_draft.Title}"); } @@ -698,6 +699,22 @@ public partial class NewListingView : UserControl private void ShowError(string title, string msg) => MessageBox.Show(msg, title, MessageBoxButton.OK, MessageBoxImage.Warning); + // ---- State C handlers ---- + + private void SuccessUrl_Click(object sender, MouseButtonEventArgs e) + { + var url = BSuccessUrl.Text; + if (!string.IsNullOrEmpty(url)) + System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo(url) + { UseShellExecute = true }); + } + + private void CopyUrl_Click(object sender, RoutedEventArgs e) + => System.Windows.Clipboard.SetText(BSuccessUrl.Text); + + private void ListAnother_Click(object sender, RoutedEventArgs e) + => ResetToStateA(); + private static bool IsImageFile(string path) { var ext = System.IO.Path.GetExtension(path).ToLowerInvariant();