feat(favorites): keep customer favourites on the server, as legacy did (FAV-01)

Both apps kept favourites in memory only, and the API had no route, so
the 874 favourites imported from legacy major_favorites never showed.

- GET customer/me/favorites, POST customer/me/favorites/toggle
- apps load them on sign-in, clear on sign-out, toggle optimistically
  and roll back on failure

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
s.esmaeili
2026-10-08 10:54:17 +03:30
co-authored by Claude Opus 5.5
parent 5480398a93
commit 5d386bf752
10 changed files with 257 additions and 34 deletions
+8
View File
@@ -336,6 +336,14 @@ export const api = {
getAccountingBalance: () => request<AccountingBalance>('/customer/me/accounting-balance'),
getMyOrders: () => request<OrderDetail[]>('/customer/me/orders'),
getMyLedgerEntries: () => request<LedgerEntrySummary[]>('/customer/me/ledger-entries'),
/** Favourite product ids, newest first — legacy get-favorites (FAV-01). */
getFavorites: () => request<{ ids: string[] }>('/customer/me/favorites'),
/** Legacy add-to-fav: adds or removes; answers the new state. */
toggleFavorite: (productId: string) =>
request<{ favorite: boolean }>('/customer/me/favorites/toggle', {
method: 'POST',
body: JSON.stringify({ productId }),
}),
createOrder: (dto: CreateOrderDto) => request<OrderSummary>('/orders', { method: 'POST', body: JSON.stringify(dto) }),
getLatestGoldPrice: (karatPerMille = 750) => request<GoldPriceQuote>(`/pricing/latest?karatPerMille=${karatPerMille}`),