@serik_lav/api-fe 0.47.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (279) hide show
  1. package/CHANGELOG.md +906 -0
  2. package/README.md +1100 -0
  3. package/dist/entities/ad/api/adApi.d.ts +6 -0
  4. package/dist/entities/ad/api/adApi.d.ts.map +1 -0
  5. package/dist/entities/ad/api/adApi.js +29 -0
  6. package/dist/entities/ad/api/adApi.js.map +1 -0
  7. package/dist/entities/ad/index.d.ts +3 -0
  8. package/dist/entities/ad/index.d.ts.map +1 -0
  9. package/dist/entities/ad/index.js +3 -0
  10. package/dist/entities/ad/index.js.map +1 -0
  11. package/dist/entities/ad/model/types.d.ts +22 -0
  12. package/dist/entities/ad/model/types.d.ts.map +1 -0
  13. package/dist/entities/ad/model/types.js +1 -0
  14. package/dist/entities/ad/model/types.js.map +1 -0
  15. package/dist/entities/auth/api/authApi.d.ts +9 -0
  16. package/dist/entities/auth/api/authApi.d.ts.map +1 -0
  17. package/dist/entities/auth/api/authApi.js +46 -0
  18. package/dist/entities/auth/api/authApi.js.map +1 -0
  19. package/dist/entities/auth/index.d.ts +3 -0
  20. package/dist/entities/auth/index.d.ts.map +1 -0
  21. package/dist/entities/auth/index.js +3 -0
  22. package/dist/entities/auth/index.js.map +1 -0
  23. package/dist/entities/auth/model/types.d.ts +77 -0
  24. package/dist/entities/auth/model/types.d.ts.map +1 -0
  25. package/dist/entities/auth/model/types.js +1 -0
  26. package/dist/entities/auth/model/types.js.map +1 -0
  27. package/dist/entities/cart/api/cartApi.d.ts +12 -0
  28. package/dist/entities/cart/api/cartApi.d.ts.map +1 -0
  29. package/dist/entities/cart/api/cartApi.js +396 -0
  30. package/dist/entities/cart/api/cartApi.js.map +1 -0
  31. package/dist/entities/cart/index.d.ts +3 -0
  32. package/dist/entities/cart/index.d.ts.map +1 -0
  33. package/dist/entities/cart/index.js +4 -0
  34. package/dist/entities/cart/index.js.map +1 -0
  35. package/dist/entities/cart/model/types.d.ts +91 -0
  36. package/dist/entities/cart/model/types.d.ts.map +1 -0
  37. package/dist/entities/cart/model/types.js +1 -0
  38. package/dist/entities/cart/model/types.js.map +1 -0
  39. package/dist/entities/category/api/categoryApi.d.ts +8 -0
  40. package/dist/entities/category/api/categoryApi.d.ts.map +1 -0
  41. package/dist/entities/category/api/categoryApi.js +33 -0
  42. package/dist/entities/category/api/categoryApi.js.map +1 -0
  43. package/dist/entities/category/index.d.ts +4 -0
  44. package/dist/entities/category/index.d.ts.map +1 -0
  45. package/dist/entities/category/index.js +4 -0
  46. package/dist/entities/category/index.js.map +1 -0
  47. package/dist/entities/category/model/store-category.d.ts +88 -0
  48. package/dist/entities/category/model/store-category.d.ts.map +1 -0
  49. package/dist/entities/category/model/store-category.js +24 -0
  50. package/dist/entities/category/model/store-category.js.map +1 -0
  51. package/dist/entities/category/model/types.d.ts +155 -0
  52. package/dist/entities/category/model/types.d.ts.map +1 -0
  53. package/dist/entities/category/model/types.js +18 -0
  54. package/dist/entities/category/model/types.js.map +1 -0
  55. package/dist/entities/category/model/useCategoryBreadcrumbs.d.ts +30 -0
  56. package/dist/entities/category/model/useCategoryBreadcrumbs.d.ts.map +1 -0
  57. package/dist/entities/category/model/useCategoryBreadcrumbs.js +72 -0
  58. package/dist/entities/category/model/useCategoryBreadcrumbs.js.map +1 -0
  59. package/dist/entities/chat/api/chatApi.d.ts +15 -0
  60. package/dist/entities/chat/api/chatApi.d.ts.map +1 -0
  61. package/dist/entities/chat/api/chatApi.js +400 -0
  62. package/dist/entities/chat/api/chatApi.js.map +1 -0
  63. package/dist/entities/chat/index.d.ts +3 -0
  64. package/dist/entities/chat/index.d.ts.map +1 -0
  65. package/dist/entities/chat/index.js +3 -0
  66. package/dist/entities/chat/index.js.map +1 -0
  67. package/dist/entities/chat/model/types.d.ts +439 -0
  68. package/dist/entities/chat/model/types.d.ts.map +1 -0
  69. package/dist/entities/chat/model/types.js +1 -0
  70. package/dist/entities/chat/model/types.js.map +1 -0
  71. package/dist/entities/country/api/countryApi.d.ts +5 -0
  72. package/dist/entities/country/api/countryApi.d.ts.map +1 -0
  73. package/dist/entities/country/api/countryApi.js +21 -0
  74. package/dist/entities/country/api/countryApi.js.map +1 -0
  75. package/dist/entities/country/index.d.ts +3 -0
  76. package/dist/entities/country/index.d.ts.map +1 -0
  77. package/dist/entities/country/index.js +3 -0
  78. package/dist/entities/country/index.js.map +1 -0
  79. package/dist/entities/country/model/types.d.ts +19 -0
  80. package/dist/entities/country/model/types.d.ts.map +1 -0
  81. package/dist/entities/country/model/types.js +1 -0
  82. package/dist/entities/country/model/types.js.map +1 -0
  83. package/dist/entities/customer/api/customerApi.d.ts +6 -0
  84. package/dist/entities/customer/api/customerApi.d.ts.map +1 -0
  85. package/dist/entities/customer/api/customerApi.js +21 -0
  86. package/dist/entities/customer/api/customerApi.js.map +1 -0
  87. package/dist/entities/customer/index.d.ts +3 -0
  88. package/dist/entities/customer/index.d.ts.map +1 -0
  89. package/dist/entities/customer/index.js +3 -0
  90. package/dist/entities/customer/index.js.map +1 -0
  91. package/dist/entities/customer/model/types.d.ts +237 -0
  92. package/dist/entities/customer/model/types.d.ts.map +1 -0
  93. package/dist/entities/customer/model/types.js +1 -0
  94. package/dist/entities/customer/model/types.js.map +1 -0
  95. package/dist/entities/favorite/api/favoriteApi.d.ts +32 -0
  96. package/dist/entities/favorite/api/favoriteApi.d.ts.map +1 -0
  97. package/dist/entities/favorite/api/favoriteApi.js +344 -0
  98. package/dist/entities/favorite/api/favoriteApi.js.map +1 -0
  99. package/dist/entities/favorite/index.d.ts +3 -0
  100. package/dist/entities/favorite/index.d.ts.map +1 -0
  101. package/dist/entities/favorite/index.js +3 -0
  102. package/dist/entities/favorite/index.js.map +1 -0
  103. package/dist/entities/favorite/model/types.d.ts +39 -0
  104. package/dist/entities/favorite/model/types.d.ts.map +1 -0
  105. package/dist/entities/favorite/model/types.js +1 -0
  106. package/dist/entities/favorite/model/types.js.map +1 -0
  107. package/dist/entities/notification/api/notificationApi.d.ts +12 -0
  108. package/dist/entities/notification/api/notificationApi.d.ts.map +1 -0
  109. package/dist/entities/notification/api/notificationApi.js +109 -0
  110. package/dist/entities/notification/api/notificationApi.js.map +1 -0
  111. package/dist/entities/notification/index.d.ts +3 -0
  112. package/dist/entities/notification/index.d.ts.map +1 -0
  113. package/dist/entities/notification/index.js +3 -0
  114. package/dist/entities/notification/index.js.map +1 -0
  115. package/dist/entities/notification/model/types.d.ts +273 -0
  116. package/dist/entities/notification/model/types.d.ts.map +1 -0
  117. package/dist/entities/notification/model/types.js +1 -0
  118. package/dist/entities/notification/model/types.js.map +1 -0
  119. package/dist/entities/novaposhta/api/novaposhtaApi.d.ts +11 -0
  120. package/dist/entities/novaposhta/api/novaposhtaApi.d.ts.map +1 -0
  121. package/dist/entities/novaposhta/api/novaposhtaApi.js +69 -0
  122. package/dist/entities/novaposhta/api/novaposhtaApi.js.map +1 -0
  123. package/dist/entities/novaposhta/index.d.ts +6 -0
  124. package/dist/entities/novaposhta/index.d.ts.map +1 -0
  125. package/dist/entities/novaposhta/index.js +6 -0
  126. package/dist/entities/novaposhta/index.js.map +1 -0
  127. package/dist/entities/novaposhta/model/novaposhtaCity.d.ts +101 -0
  128. package/dist/entities/novaposhta/model/novaposhtaCity.d.ts.map +1 -0
  129. package/dist/entities/novaposhta/model/novaposhtaCity.js +16 -0
  130. package/dist/entities/novaposhta/model/novaposhtaCity.js.map +1 -0
  131. package/dist/entities/novaposhta/model/novaposhtaSettlement.d.ts +140 -0
  132. package/dist/entities/novaposhta/model/novaposhtaSettlement.d.ts.map +1 -0
  133. package/dist/entities/novaposhta/model/novaposhtaSettlement.js +23 -0
  134. package/dist/entities/novaposhta/model/novaposhtaSettlement.js.map +1 -0
  135. package/dist/entities/novaposhta/model/novaposhtaStreet.d.ts +123 -0
  136. package/dist/entities/novaposhta/model/novaposhtaStreet.d.ts.map +1 -0
  137. package/dist/entities/novaposhta/model/novaposhtaStreet.js +16 -0
  138. package/dist/entities/novaposhta/model/novaposhtaStreet.js.map +1 -0
  139. package/dist/entities/novaposhta/model/novaposhtaWarehouse.d.ts +131 -0
  140. package/dist/entities/novaposhta/model/novaposhtaWarehouse.d.ts.map +1 -0
  141. package/dist/entities/novaposhta/model/novaposhtaWarehouse.js +19 -0
  142. package/dist/entities/novaposhta/model/novaposhtaWarehouse.js.map +1 -0
  143. package/dist/entities/order/api/orderApi.d.ts +18 -0
  144. package/dist/entities/order/api/orderApi.d.ts.map +1 -0
  145. package/dist/entities/order/api/orderApi.js +105 -0
  146. package/dist/entities/order/api/orderApi.js.map +1 -0
  147. package/dist/entities/order/index.d.ts +3 -0
  148. package/dist/entities/order/index.d.ts.map +1 -0
  149. package/dist/entities/order/index.js +3 -0
  150. package/dist/entities/order/index.js.map +1 -0
  151. package/dist/entities/order/model/types.d.ts +630 -0
  152. package/dist/entities/order/model/types.d.ts.map +1 -0
  153. package/dist/entities/order/model/types.js +27 -0
  154. package/dist/entities/order/model/types.js.map +1 -0
  155. package/dist/entities/product/api/productApi.d.ts +27 -0
  156. package/dist/entities/product/api/productApi.d.ts.map +1 -0
  157. package/dist/entities/product/api/productApi.js +252 -0
  158. package/dist/entities/product/api/productApi.js.map +1 -0
  159. package/dist/entities/product/index.d.ts +3 -0
  160. package/dist/entities/product/index.d.ts.map +1 -0
  161. package/dist/entities/product/index.js +3 -0
  162. package/dist/entities/product/index.js.map +1 -0
  163. package/dist/entities/product/model/store-product.d.ts +138 -0
  164. package/dist/entities/product/model/store-product.d.ts.map +1 -0
  165. package/dist/entities/product/model/store-product.js +9 -0
  166. package/dist/entities/product/model/store-product.js.map +1 -0
  167. package/dist/entities/product/model/types.d.ts +898 -0
  168. package/dist/entities/product/model/types.d.ts.map +1 -0
  169. package/dist/entities/product/model/types.js +40 -0
  170. package/dist/entities/product/model/types.js.map +1 -0
  171. package/dist/entities/referral/api/referralApi.d.ts +7 -0
  172. package/dist/entities/referral/api/referralApi.d.ts.map +1 -0
  173. package/dist/entities/referral/api/referralApi.js +41 -0
  174. package/dist/entities/referral/api/referralApi.js.map +1 -0
  175. package/dist/entities/referral/index.d.ts +3 -0
  176. package/dist/entities/referral/index.d.ts.map +1 -0
  177. package/dist/entities/referral/index.js +3 -0
  178. package/dist/entities/referral/index.js.map +1 -0
  179. package/dist/entities/referral/model/types.d.ts +42 -0
  180. package/dist/entities/referral/model/types.d.ts.map +1 -0
  181. package/dist/entities/referral/model/types.js +1 -0
  182. package/dist/entities/referral/model/types.js.map +1 -0
  183. package/dist/entities/store/api/storeApi.d.ts +14 -0
  184. package/dist/entities/store/api/storeApi.d.ts.map +1 -0
  185. package/dist/entities/store/api/storeApi.js +134 -0
  186. package/dist/entities/store/api/storeApi.js.map +1 -0
  187. package/dist/entities/store/index.d.ts +3 -0
  188. package/dist/entities/store/index.d.ts.map +1 -0
  189. package/dist/entities/store/index.js +3 -0
  190. package/dist/entities/store/index.js.map +1 -0
  191. package/dist/entities/store/model/types.d.ts +853 -0
  192. package/dist/entities/store/model/types.d.ts.map +1 -0
  193. package/dist/entities/store/model/types.js +1 -0
  194. package/dist/entities/store/model/types.js.map +1 -0
  195. package/dist/entities/stories/api/storiesApi.d.ts +12 -0
  196. package/dist/entities/stories/api/storiesApi.d.ts.map +1 -0
  197. package/dist/entities/stories/api/storiesApi.js +225 -0
  198. package/dist/entities/stories/api/storiesApi.js.map +1 -0
  199. package/dist/entities/stories/index.d.ts +3 -0
  200. package/dist/entities/stories/index.d.ts.map +1 -0
  201. package/dist/entities/stories/index.js +3 -0
  202. package/dist/entities/stories/index.js.map +1 -0
  203. package/dist/entities/stories/model/types.d.ts +330 -0
  204. package/dist/entities/stories/model/types.d.ts.map +1 -0
  205. package/dist/entities/stories/model/types.js +1 -0
  206. package/dist/entities/stories/model/types.js.map +1 -0
  207. package/dist/entities/supplier/api/supplierApi.d.ts +20 -0
  208. package/dist/entities/supplier/api/supplierApi.d.ts.map +1 -0
  209. package/dist/entities/supplier/api/supplierApi.js +148 -0
  210. package/dist/entities/supplier/api/supplierApi.js.map +1 -0
  211. package/dist/entities/supplier/index.d.ts +3 -0
  212. package/dist/entities/supplier/index.d.ts.map +1 -0
  213. package/dist/entities/supplier/index.js +3 -0
  214. package/dist/entities/supplier/index.js.map +1 -0
  215. package/dist/entities/supplier/model/types.d.ts +295 -0
  216. package/dist/entities/supplier/model/types.d.ts.map +1 -0
  217. package/dist/entities/supplier/model/types.js +1 -0
  218. package/dist/entities/supplier/model/types.js.map +1 -0
  219. package/dist/entities/system/api/systemApi.d.ts +7 -0
  220. package/dist/entities/system/api/systemApi.d.ts.map +1 -0
  221. package/dist/entities/system/api/systemApi.js +60 -0
  222. package/dist/entities/system/api/systemApi.js.map +1 -0
  223. package/dist/entities/system/index.d.ts +3 -0
  224. package/dist/entities/system/index.d.ts.map +1 -0
  225. package/dist/entities/system/index.js +3 -0
  226. package/dist/entities/system/index.js.map +1 -0
  227. package/dist/entities/system/model/types.d.ts +55 -0
  228. package/dist/entities/system/model/types.d.ts.map +1 -0
  229. package/dist/entities/system/model/types.js +1 -0
  230. package/dist/entities/system/model/types.js.map +1 -0
  231. package/dist/index.d.ts +20 -0
  232. package/dist/index.d.ts.map +1 -0
  233. package/dist/index.js +21 -0
  234. package/dist/index.js.map +1 -0
  235. package/dist/shared/api/api.d.ts +18 -0
  236. package/dist/shared/api/api.d.ts.map +1 -0
  237. package/dist/shared/api/api.js +74 -0
  238. package/dist/shared/api/api.js.map +1 -0
  239. package/dist/shared/api/index.d.ts +3 -0
  240. package/dist/shared/api/index.d.ts.map +1 -0
  241. package/dist/shared/api/index.js +3 -0
  242. package/dist/shared/api/index.js.map +1 -0
  243. package/dist/shared/api/validation-error/ValidationError.d.ts +7 -0
  244. package/dist/shared/api/validation-error/ValidationError.d.ts.map +1 -0
  245. package/dist/shared/api/validation-error/ValidationError.js +1 -0
  246. package/dist/shared/api/validation-error/ValidationError.js.map +1 -0
  247. package/dist/shared/api/validation-error/handleValidationError.d.ts +2 -0
  248. package/dist/shared/api/validation-error/handleValidationError.d.ts.map +1 -0
  249. package/dist/shared/api/validation-error/handleValidationError.js +24 -0
  250. package/dist/shared/api/validation-error/handleValidationError.js.map +1 -0
  251. package/dist/shared/api/validation-error/index.d.ts +3 -0
  252. package/dist/shared/api/validation-error/index.d.ts.map +1 -0
  253. package/dist/shared/api/validation-error/index.js +3 -0
  254. package/dist/shared/api/validation-error/index.js.map +1 -0
  255. package/dist/shared/api/validation-error/isValidationError.d.ts +3 -0
  256. package/dist/shared/api/validation-error/isValidationError.d.ts.map +1 -0
  257. package/dist/shared/api/validation-error/isValidationError.js +11 -0
  258. package/dist/shared/api/validation-error/isValidationError.js.map +1 -0
  259. package/dist/shared/lib/getNextPageParam.d.ts +3 -0
  260. package/dist/shared/lib/getNextPageParam.d.ts.map +1 -0
  261. package/dist/shared/lib/getNextPageParam.js +4 -0
  262. package/dist/shared/lib/getNextPageParam.js.map +1 -0
  263. package/dist/shared/lib/index.d.ts +3 -0
  264. package/dist/shared/lib/index.d.ts.map +1 -0
  265. package/dist/shared/lib/index.js +3 -0
  266. package/dist/shared/lib/index.js.map +1 -0
  267. package/dist/shared/lib/objectToFormData.d.ts +2 -0
  268. package/dist/shared/lib/objectToFormData.d.ts.map +1 -0
  269. package/dist/shared/lib/objectToFormData.js +36 -0
  270. package/dist/shared/lib/objectToFormData.js.map +1 -0
  271. package/dist/shared/model/index.d.ts +2 -0
  272. package/dist/shared/model/index.d.ts.map +1 -0
  273. package/dist/shared/model/index.js +2 -0
  274. package/dist/shared/model/index.js.map +1 -0
  275. package/dist/shared/model/types.d.ts +75 -0
  276. package/dist/shared/model/types.d.ts.map +1 -0
  277. package/dist/shared/model/types.js +31 -0
  278. package/dist/shared/model/types.js.map +1 -0
  279. package/package.json +46 -0
@@ -0,0 +1,237 @@
1
+ /**
2
+ * Данные клиента / дроппера
3
+ */
4
+ export interface Customer {
5
+ /**
6
+ * ID клиента
7
+ *
8
+ * @example 19794
9
+ */
10
+ customer_id: number;
11
+ /**
12
+ * URL аватара клиента
13
+ *
14
+ * @example "https://cdn.buymeua.shop/storage/avatar/abc123.jpg"
15
+ */
16
+ avatar_url: string | null;
17
+ /**
18
+ * ID группы клиента
19
+ *
20
+ * @example 3
21
+ */
22
+ customer_group_id: number;
23
+ /**
24
+ * Telegram ID клиента
25
+ *
26
+ * @example 123456789
27
+ */
28
+ telegram_id: string | null;
29
+ /**
30
+ * Флаг гостевого аккаунта
31
+ *
32
+ * @example false
33
+ */
34
+ guest: boolean;
35
+ /**
36
+ * Название группы клиента
37
+ *
38
+ * @example "Дропшипинг"
39
+ */
40
+ customer_group: string;
41
+ /**
42
+ * Полное имя клиента
43
+ *
44
+ * @example "Maksym2 Kerus2"
45
+ */
46
+ name: string;
47
+ /**
48
+ * Имя клиента
49
+ *
50
+ * @example "Maksym2"
51
+ */
52
+ firstname: string;
53
+ /**
54
+ * Фамилия клиента
55
+ *
56
+ * @example "Kerus2"
57
+ */
58
+ lastname: string;
59
+ /**
60
+ * Отчество клиента
61
+ *
62
+ * @example "Петрович"
63
+ */
64
+ middlename: string | null;
65
+ /**
66
+ * Email клиента
67
+ *
68
+ * @example "user@example.com"
69
+ */
70
+ email: string;
71
+ /**
72
+ * Телефон клиента
73
+ *
74
+ * @example "+38(097)-160-22-22"
75
+ */
76
+ telephone: string;
77
+ /**
78
+ * Количество товаров в списке желаний
79
+ *
80
+ * @example 0
81
+ */
82
+ wishlist: number;
83
+ /**
84
+ * ФИО владельца карты для выплат
85
+ *
86
+ * @example "Іваненко Олександр Петрович"
87
+ */
88
+ card_fio: string | null;
89
+ /**
90
+ * Номер карты для выплат
91
+ *
92
+ * @example "5168742012345678"
93
+ */
94
+ card_number: string | null;
95
+ /**
96
+ * Телефон, привязанный к карте
97
+ *
98
+ * @example "+380991234567"
99
+ */
100
+ card_phone: string | null;
101
+ /**
102
+ * Регистрационный номер плательщика НДС
103
+ *
104
+ * @example "1234567890"
105
+ */
106
+ rr: string | null;
107
+ /**
108
+ * Адрес криптокошелька
109
+ *
110
+ * @example 0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb
111
+ */
112
+ crypto_wallet: string | null;
113
+ /**
114
+ * Флаг подтверждения телефона
115
+ *
116
+ * @example true
117
+ */
118
+ is_confirm_telephone: boolean;
119
+ /**
120
+ * ЄДРПОУ код организации (для юридических лиц)
121
+ *
122
+ * @example "234233432423"
123
+ */
124
+ ederpou: string | null;
125
+ /**
126
+ * IBAN банковского счета
127
+ *
128
+ * @example "UA12313123"
129
+ */
130
+ iban: string | null;
131
+ /**
132
+ * Telegram username менеджера
133
+ *
134
+ * @example "@manager_username"
135
+ */
136
+ manager_telegram_username: string | null;
137
+ }
138
+ /**
139
+ * Інформація про користувача
140
+ */
141
+ export interface CustomerAccount {
142
+ /**
143
+ * @example 10045
144
+ */
145
+ customer_id: number;
146
+ /**
147
+ * @example "https://cdn.buyme.ua/avatar/10045.jpg"
148
+ */
149
+ avatar: string;
150
+ /**
151
+ * @example 2
152
+ */
153
+ customer_group_id: number;
154
+ /**
155
+ * @example 856312345
156
+ */
157
+ telegram_id: number | null;
158
+ /**
159
+ * @example false
160
+ */
161
+ guest: boolean;
162
+ /**
163
+ * @example "Оптовий покупець"
164
+ */
165
+ customer_group: string | null;
166
+ /**
167
+ * @example "Олена Іваненко"
168
+ */
169
+ name: string;
170
+ /**
171
+ * @example "Олена"
172
+ */
173
+ firstname: string;
174
+ /**
175
+ * @example "Іваненко"
176
+ */
177
+ lastname: string;
178
+ /**
179
+ * @example "Олексіївна"
180
+ */
181
+ middlename: string;
182
+ /**
183
+ * @example "olena@example.com"
184
+ */
185
+ email: string;
186
+ /**
187
+ * @example "+380931234567"
188
+ */
189
+ telephone: string;
190
+ /**
191
+ * @example true
192
+ */
193
+ is_confirm_telephone: boolean;
194
+ /**
195
+ * @example "Іваненко Олена Олексіївна"
196
+ */
197
+ card_fio: string;
198
+ /**
199
+ * @example "12345678"
200
+ */
201
+ ederpou: string;
202
+ /**
203
+ * @example "UA123456789012345678901234567"
204
+ */
205
+ iban: string;
206
+ /**
207
+ * @example "ЛАВРИНЮК АЛІНА ОЛЕКСІЇВНА"
208
+ */
209
+ open_data_full_name: string;
210
+ }
211
+ /**
212
+ * Зберегти налаштування користувача
213
+ */
214
+ export interface SaveCustomerSettingsRequest {
215
+ customer_group_id?: number;
216
+ firstname?: string;
217
+ lastname?: string;
218
+ middlename?: string;
219
+ email?: string;
220
+ iban?: string;
221
+ card_fio?: string;
222
+ ederpou?: string;
223
+ /**
224
+ * Аватар користувача (jpeg, png, jpg, gif, max: 2048kb)
225
+ */
226
+ avatar?: File;
227
+ }
228
+ /**
229
+ * Успішне збереження налаштувань
230
+ */
231
+ export interface SaveCustomerSettingsResponse {
232
+ /**
233
+ * @see {@link CustomerAccount}
234
+ */
235
+ data: CustomerAccount;
236
+ }
237
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/entities/customer/model/types.ts"],"names":[],"mappings":"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"}
@@ -0,0 +1 @@
1
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/entities/customer/model/types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,32 @@
1
+ import type { AddFavoriteMerchantItemRequest, AddFavoriteMerchantItemResponse, GetFavoriteCountResponse, GetFavoriteMerchantItemsRequest, GetFavoriteMerchantItemsResponse, GetFavoriteMerchantsRequest, GetFavoriteMerchantsResponse } from '../model/types';
2
+ export declare const favoriteApi: import("@reduxjs/toolkit/query").Api<import("@reduxjs/toolkit/query").BaseQueryFn<string | import("@reduxjs/toolkit/query").FetchArgs, unknown, import("@reduxjs/toolkit/query").FetchBaseQueryError>, import("@reduxjs/toolkit/query").UpdateDefinitions<import("@reduxjs/toolkit/query").UpdateDefinitions<import("@reduxjs/toolkit/query").UpdateDefinitions<{
3
+ getCartCount: import("@reduxjs/toolkit/query").QueryDefinition<void, import("@reduxjs/toolkit/query").BaseQueryFn<string | import("@reduxjs/toolkit/query").FetchArgs, unknown, import("@reduxjs/toolkit/query").FetchBaseQueryError>, never, import("../../cart").GetCartCountResponse, "buymeuaApi", unknown>;
4
+ getCartMerchants: import("@reduxjs/toolkit/query").InfiniteQueryDefinition<void | import("../../cart").GetCartMerchantsRequest, number, import("@reduxjs/toolkit/query").BaseQueryFn<string | import("@reduxjs/toolkit/query").FetchArgs, unknown, import("@reduxjs/toolkit/query").FetchBaseQueryError>, never, import("../../cart").GetCartMerchantsResponse, "buymeuaApi", unknown>;
5
+ getCartMerchantItems: import("@reduxjs/toolkit/query").InfiniteQueryDefinition<import("../../cart").GetCartMerchantItemsRequest, number, import("@reduxjs/toolkit/query").BaseQueryFn<string | import("@reduxjs/toolkit/query").FetchArgs, unknown, import("@reduxjs/toolkit/query").FetchBaseQueryError>, never, import("../../cart").GetCartMerchantItemsResponse, "buymeuaApi", unknown>;
6
+ addToCart: import("@reduxjs/toolkit/query").MutationDefinition<import("../../cart").AddToCartRequest, import("@reduxjs/toolkit/query").BaseQueryFn<string | import("@reduxjs/toolkit/query").FetchArgs, unknown, import("@reduxjs/toolkit/query").FetchBaseQueryError>, never, import("../../cart").AddToCartResponse, "buymeuaApi", unknown>;
7
+ removeItemFromCart: import("@reduxjs/toolkit/query").MutationDefinition<import("../../cart").RemoveItemFromCartRequest, import("@reduxjs/toolkit/query").BaseQueryFn<string | import("@reduxjs/toolkit/query").FetchArgs, unknown, import("@reduxjs/toolkit/query").FetchBaseQueryError>, never, undefined, "buymeuaApi", unknown>;
8
+ removeMerchantFromCart: import("@reduxjs/toolkit/query").MutationDefinition<import("../../cart").RemoveMerchantFromCartRequest, import("@reduxjs/toolkit/query").BaseQueryFn<string | import("@reduxjs/toolkit/query").FetchArgs, unknown, import("@reduxjs/toolkit/query").FetchBaseQueryError>, never, undefined, "buymeuaApi", unknown>;
9
+ updateCartItemQuantity: import("@reduxjs/toolkit/query").MutationDefinition<import("../../cart").UpdateCartItemQuantityRequest, import("@reduxjs/toolkit/query").BaseQueryFn<string | import("@reduxjs/toolkit/query").FetchArgs, unknown, import("@reduxjs/toolkit/query").FetchBaseQueryError>, never, import("../../cart").UpdateCartItemQuantityResponse, "buymeuaApi", unknown>;
10
+ toggleGiftPackage: import("@reduxjs/toolkit/query").MutationDefinition<import("../../cart").ToggleGiftPackageRequest, import("@reduxjs/toolkit/query").BaseQueryFn<string | import("@reduxjs/toolkit/query").FetchArgs, unknown, import("@reduxjs/toolkit/query").FetchBaseQueryError>, never, import("../../cart").ToggleGiftPackageResponse, "buymeuaApi", unknown>;
11
+ }, "CartCount" | "CartMerchant" | "CartMerchantItem", never> & {
12
+ getProducts: import("@reduxjs/toolkit/query").InfiniteQueryDefinition<void | import("../../product").GetProductsRequest, number, import("@reduxjs/toolkit/query").BaseQueryFn<string | import("@reduxjs/toolkit/query").FetchArgs, unknown, import("@reduxjs/toolkit/query").FetchBaseQueryError>, "CartCount" | "CartMerchant" | "CartMerchantItem", import("../../product").GetProductsResponse, "buymeuaApi", unknown>;
13
+ getPaginatedProducts: import("@reduxjs/toolkit/query").QueryDefinition<void | import("../../product").GetPaginatedProductsRequest, import("@reduxjs/toolkit/query").BaseQueryFn<string | import("@reduxjs/toolkit/query").FetchArgs, unknown, import("@reduxjs/toolkit/query").FetchBaseQueryError>, "CartCount" | "CartMerchant" | "CartMerchantItem", import("../../product").GetProductsResponse, "buymeuaApi", unknown>;
14
+ getProductsByQr: import("@reduxjs/toolkit/query").InfiniteQueryDefinition<void | import("../../product").GetProductsByQrRequest, number, import("@reduxjs/toolkit/query").BaseQueryFn<string | import("@reduxjs/toolkit/query").FetchArgs, unknown, import("@reduxjs/toolkit/query").FetchBaseQueryError>, "CartCount" | "CartMerchant" | "CartMerchantItem", import("../../product").GetProductsByQrResponse, "buymeuaApi", unknown>;
15
+ getProduct: import("@reduxjs/toolkit/query").QueryDefinition<import("../../product").GetProductRequest, import("@reduxjs/toolkit/query").BaseQueryFn<string | import("@reduxjs/toolkit/query").FetchArgs, unknown, import("@reduxjs/toolkit/query").FetchBaseQueryError>, "CartCount" | "CartMerchant" | "CartMerchantItem", import("../../product").GetProductResponse, "buymeuaApi", unknown>;
16
+ getProductStatistics: import("@reduxjs/toolkit/query").QueryDefinition<import("../../product").GetProductStatisticsRequest, import("@reduxjs/toolkit/query").BaseQueryFn<string | import("@reduxjs/toolkit/query").FetchArgs, unknown, import("@reduxjs/toolkit/query").FetchBaseQueryError>, "CartCount" | "CartMerchant" | "CartMerchantItem", import("../../product").GetProductStatisticsResponse, "buymeuaApi", unknown>;
17
+ getProductDetails: import("@reduxjs/toolkit/query").QueryDefinition<import("../../product").GetProductDetailsRequest, import("@reduxjs/toolkit/query").BaseQueryFn<string | import("@reduxjs/toolkit/query").FetchArgs, unknown, import("@reduxjs/toolkit/query").FetchBaseQueryError>, "CartCount" | "CartMerchant" | "CartMerchantItem", import("../../product").GetProductDetailsResponse, "buymeuaApi", unknown>;
18
+ getProductAttributes: import("@reduxjs/toolkit/query").QueryDefinition<void | import("../../product").GetProductAttributesRequest, import("@reduxjs/toolkit/query").BaseQueryFn<string | import("@reduxjs/toolkit/query").FetchArgs, unknown, import("@reduxjs/toolkit/query").FetchBaseQueryError>, "CartCount" | "CartMerchant" | "CartMerchantItem", import("../../product").GetProductAttributesResponse, "buymeuaApi", unknown>;
19
+ getProductOptions: import("@reduxjs/toolkit/query").QueryDefinition<void | import("../../product").GetProductOptionsRequest, import("@reduxjs/toolkit/query").BaseQueryFn<string | import("@reduxjs/toolkit/query").FetchArgs, unknown, import("@reduxjs/toolkit/query").FetchBaseQueryError>, "CartCount" | "CartMerchant" | "CartMerchantItem", import("../../product").GetProductOptionsResponse, "buymeuaApi", unknown>;
20
+ getSupplierProducts: import("@reduxjs/toolkit/query").InfiniteQueryDefinition<void | import("../../product").GetSupplierProductsRequest, number, import("@reduxjs/toolkit/query").BaseQueryFn<string | import("@reduxjs/toolkit/query").FetchArgs, unknown, import("@reduxjs/toolkit/query").FetchBaseQueryError>, "CartCount" | "CartMerchant" | "CartMerchantItem", import("../../product").GetSupplierProductsResponse, "buymeuaApi", unknown>;
21
+ getPaginatedSupplierProducts: import("@reduxjs/toolkit/query").QueryDefinition<void | import("../../product").GetPaginatedSupplierProductsRequest, import("@reduxjs/toolkit/query").BaseQueryFn<string | import("@reduxjs/toolkit/query").FetchArgs, unknown, import("@reduxjs/toolkit/query").FetchBaseQueryError>, "CartCount" | "CartMerchant" | "CartMerchantItem", import("../../product").GetSupplierProductsResponse, "buymeuaApi", unknown>;
22
+ getSupplierProductDetails: import("@reduxjs/toolkit/query").QueryDefinition<import("../../product").GetSupplierProductDetailsRequest, import("@reduxjs/toolkit/query").BaseQueryFn<string | import("@reduxjs/toolkit/query").FetchArgs, unknown, import("@reduxjs/toolkit/query").FetchBaseQueryError>, "CartCount" | "CartMerchant" | "CartMerchantItem", import("../../product").GetSupplierProductDetailsResponse, "buymeuaApi", unknown>;
23
+ generateProductDescription: import("@reduxjs/toolkit/query").QueryDefinition<import("../../product").GenerateProductDescriptionRequest, import("@reduxjs/toolkit/query").BaseQueryFn<string | import("@reduxjs/toolkit/query").FetchArgs, unknown, import("@reduxjs/toolkit/query").FetchBaseQueryError>, "CartCount" | "CartMerchant" | "CartMerchantItem", import("../../product").GenerateProductDescriptionResponse, "buymeuaApi", unknown>;
24
+ getStoreProducts: import("@reduxjs/toolkit/query").InfiniteQueryDefinition<void | import("../../product/model/store-product").GetStoreProductsRequest, number, import("@reduxjs/toolkit/query").BaseQueryFn<string | import("@reduxjs/toolkit/query").FetchArgs, unknown, import("@reduxjs/toolkit/query").FetchBaseQueryError>, "CartCount" | "CartMerchant" | "CartMerchantItem", import("../../product/model/store-product").GetStoreProductsResponse, "buymeuaApi", unknown>;
25
+ }, "CartCount" | "CartMerchant" | "CartMerchantItem" | "Product" | "ProductDetails" | "SupplierProduct" | "SupplierProductDetails", never> & {
26
+ getFavoriteCount: import("@reduxjs/toolkit/query").QueryDefinition<void, import("@reduxjs/toolkit/query").BaseQueryFn<string | import("@reduxjs/toolkit/query").FetchArgs, unknown, import("@reduxjs/toolkit/query").FetchBaseQueryError>, "CartCount" | "CartMerchant" | "CartMerchantItem" | "Product" | "ProductDetails" | "SupplierProduct" | "SupplierProductDetails", GetFavoriteCountResponse, "buymeuaApi", unknown>;
27
+ getFavoriteMerchants: import("@reduxjs/toolkit/query").InfiniteQueryDefinition<void | GetFavoriteMerchantsRequest, number, import("@reduxjs/toolkit/query").BaseQueryFn<string | import("@reduxjs/toolkit/query").FetchArgs, unknown, import("@reduxjs/toolkit/query").FetchBaseQueryError>, "CartCount" | "CartMerchant" | "CartMerchantItem" | "Product" | "ProductDetails" | "SupplierProduct" | "SupplierProductDetails", GetFavoriteMerchantsResponse, "buymeuaApi", unknown>;
28
+ getFavoriteMerchantItems: import("@reduxjs/toolkit/query").InfiniteQueryDefinition<GetFavoriteMerchantItemsRequest, number, import("@reduxjs/toolkit/query").BaseQueryFn<string | import("@reduxjs/toolkit/query").FetchArgs, unknown, import("@reduxjs/toolkit/query").FetchBaseQueryError>, "CartCount" | "CartMerchant" | "CartMerchantItem" | "Product" | "ProductDetails" | "SupplierProduct" | "SupplierProductDetails", GetFavoriteMerchantItemsResponse, "buymeuaApi", unknown>;
29
+ addFavoriteMerchantItem: import("@reduxjs/toolkit/query").MutationDefinition<AddFavoriteMerchantItemRequest, import("@reduxjs/toolkit/query").BaseQueryFn<string | import("@reduxjs/toolkit/query").FetchArgs, unknown, import("@reduxjs/toolkit/query").FetchBaseQueryError>, "CartCount" | "CartMerchant" | "CartMerchantItem" | "Product" | "ProductDetails" | "SupplierProduct" | "SupplierProductDetails", AddFavoriteMerchantItemResponse, "buymeuaApi", unknown>;
30
+ deleteFavoriteMerchantItem: import("@reduxjs/toolkit/query").MutationDefinition<AddFavoriteMerchantItemRequest, import("@reduxjs/toolkit/query").BaseQueryFn<string | import("@reduxjs/toolkit/query").FetchArgs, unknown, import("@reduxjs/toolkit/query").FetchBaseQueryError>, "CartCount" | "CartMerchant" | "CartMerchantItem" | "Product" | "ProductDetails" | "SupplierProduct" | "SupplierProductDetails", undefined, "buymeuaApi", unknown>;
31
+ }, "CartCount" | "CartMerchant" | "CartMerchantItem" | "Product" | "ProductDetails" | "SupplierProduct" | "SupplierProductDetails" | "FavoriteCount" | "FavoriteMerchant" | "FavoriteMerchantItem", never>, "buymeuaApi", "CartCount" | "CartMerchant" | "CartMerchantItem" | "Product" | "ProductDetails" | "SupplierProduct" | "SupplierProductDetails" | "FavoriteCount" | "FavoriteMerchant" | "FavoriteMerchantItem", typeof import("@reduxjs/toolkit/query").coreModuleName | typeof import("@reduxjs/toolkit/query/react").reactHooksModuleName>;
32
+ //# sourceMappingURL=favoriteApi.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"favoriteApi.d.ts","sourceRoot":"","sources":["../../../../src/entities/favorite/api/favoriteApi.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,8BAA8B,EAC9B,+BAA+B,EAG/B,wBAAwB,EACxB,+BAA+B,EAC/B,gCAAgC,EAChC,2BAA2B,EAC3B,4BAA4B,EAC7B,MAAM,gBAAgB,CAAC;AAGxB,eAAO,MAAM,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;uhBAugBpB,CAAC"}
@@ -0,0 +1,344 @@
1
+ import { productApi } from '../../product';
2
+ import { getNextPageParam } from '../../../shared/lib';
3
+ export const favoriteApi = productApi
4
+ .injectEndpoints({
5
+ endpoints: (build) => ({
6
+ // eslint-disable-next-line @typescript-eslint/no-invalid-void-type
7
+ getFavoriteCount: build.query({
8
+ query: (_arg) => ({
9
+ url: 'v1/favorite/count',
10
+ }),
11
+ }),
12
+ getFavoriteMerchants: build.infiniteQuery({
13
+ infiniteQueryOptions: {
14
+ initialPageParam: 1,
15
+ getNextPageParam,
16
+ },
17
+ query: (arg) => ({
18
+ url: 'v1/favorite/merchants',
19
+ params: {
20
+ ...arg.queryArg,
21
+ page: arg.pageParam,
22
+ },
23
+ }),
24
+ }),
25
+ getFavoriteMerchantItems: build.infiniteQuery({
26
+ infiniteQueryOptions: {
27
+ initialPageParam: 1,
28
+ getNextPageParam,
29
+ },
30
+ query: (arg) => ({
31
+ url: 'v1/favorite/merchant-items',
32
+ params: {
33
+ ...arg.queryArg,
34
+ page: arg.pageParam,
35
+ },
36
+ }),
37
+ }),
38
+ addFavoriteMerchantItem: build.mutation({
39
+ query: ({ optimisticUpdate, ...arg }) => ({
40
+ url: 'v1/favorite',
41
+ method: 'POST',
42
+ body: arg,
43
+ }),
44
+ // TODO: Review, refactor, standalone func to this and deleteFavoriteMerchantItem
45
+ onQueryStarted: async (queryArgument, mutationLifeCycleApi) => {
46
+ if (!queryArgument.optimisticUpdate)
47
+ return;
48
+ const patchResult = mutationLifeCycleApi.dispatch(favoriteApi.util.updateQueryData('getFavoriteMerchantItems', {
49
+ merchant_id: queryArgument.optimisticUpdate.product.merchant_id,
50
+ }, (draft) => {
51
+ const firstPage = draft.pages[0];
52
+ if (!firstPage || !queryArgument.optimisticUpdate?.product)
53
+ return;
54
+ const favoriteItem = {
55
+ ...queryArgument.optimisticUpdate.product,
56
+ favorite_item_id: performance.now() + Math.random() * 1000,
57
+ };
58
+ firstPage.data.unshift(favoriteItem);
59
+ }));
60
+ const favoriteCountPatchResult = mutationLifeCycleApi.dispatch(favoriteApi.util.updateQueryData('getFavoriteCount', undefined, (draft) => {
61
+ draft.total_quantity += 1;
62
+ }));
63
+ let productPatchResult;
64
+ let supplierProductPatchResult;
65
+ let productDetailsPatchResult;
66
+ let supplierProductDetailsPatchResult;
67
+ for (const { endpointName, originalArgs, } of favoriteApi.util.selectInvalidatedBy(mutationLifeCycleApi.getState(), [
68
+ {
69
+ type: 'Product',
70
+ id: queryArgument.optimisticUpdate.product.id,
71
+ },
72
+ ])) {
73
+ if (endpointName !== 'getProducts')
74
+ continue;
75
+ productPatchResult = mutationLifeCycleApi.dispatch(favoriteApi.util.updateQueryData('getProducts', originalArgs, (draft) => {
76
+ draft.pages.forEach((page) => {
77
+ page.data.forEach((product) => {
78
+ if (product.id ===
79
+ queryArgument.optimisticUpdate?.product.id) {
80
+ product.in_favorite = true;
81
+ }
82
+ });
83
+ });
84
+ }));
85
+ }
86
+ for (const { endpointName, originalArgs, } of favoriteApi.util.selectInvalidatedBy(mutationLifeCycleApi.getState(), [
87
+ {
88
+ type: 'SupplierProduct',
89
+ id: queryArgument.optimisticUpdate.product.id,
90
+ },
91
+ ])) {
92
+ if (endpointName !== 'getSupplierProducts')
93
+ continue;
94
+ supplierProductPatchResult = mutationLifeCycleApi.dispatch(favoriteApi.util.updateQueryData('getSupplierProducts', originalArgs, (draft) => {
95
+ draft.pages.forEach((page) => {
96
+ page.data.forEach((product) => {
97
+ if (product.id ===
98
+ queryArgument.optimisticUpdate?.product.id) {
99
+ product.in_favorite = true;
100
+ }
101
+ });
102
+ });
103
+ }));
104
+ }
105
+ for (const { endpointName, originalArgs, } of favoriteApi.util.selectInvalidatedBy(mutationLifeCycleApi.getState(), [
106
+ {
107
+ type: 'ProductDetails',
108
+ id: queryArgument.optimisticUpdate.product.id,
109
+ },
110
+ ])) {
111
+ if (endpointName !== 'getProductDetails')
112
+ continue;
113
+ productDetailsPatchResult = mutationLifeCycleApi.dispatch(favoriteApi.util.updateQueryData('getProductDetails', originalArgs, (draft) => {
114
+ draft.data.in_favorite = true;
115
+ }));
116
+ }
117
+ for (const { endpointName, originalArgs, } of favoriteApi.util.selectInvalidatedBy(mutationLifeCycleApi.getState(), [
118
+ {
119
+ type: 'SupplierProductDetails',
120
+ id: queryArgument.optimisticUpdate.product.id,
121
+ },
122
+ ])) {
123
+ if (endpointName !== 'getSupplierProductDetails')
124
+ continue;
125
+ supplierProductDetailsPatchResult = mutationLifeCycleApi.dispatch(favoriteApi.util.updateQueryData('getSupplierProductDetails', originalArgs, (draft) => {
126
+ draft.data.in_favorite = true;
127
+ }));
128
+ }
129
+ try {
130
+ await mutationLifeCycleApi.queryFulfilled;
131
+ }
132
+ catch {
133
+ patchResult.undo();
134
+ favoriteCountPatchResult.undo();
135
+ if (productPatchResult)
136
+ productPatchResult.undo();
137
+ if (supplierProductPatchResult)
138
+ supplierProductPatchResult.undo();
139
+ if (productDetailsPatchResult)
140
+ productDetailsPatchResult.undo();
141
+ if (supplierProductDetailsPatchResult)
142
+ supplierProductDetailsPatchResult.undo();
143
+ }
144
+ },
145
+ }),
146
+ deleteFavoriteMerchantItem: build.mutation({
147
+ query: ({ optimisticUpdate, ...arg }) => ({
148
+ url: 'v1/favorite',
149
+ method: 'DELETE',
150
+ body: arg,
151
+ }),
152
+ onQueryStarted: async (queryArgument, mutationLifeCycleApi) => {
153
+ if (!queryArgument.optimisticUpdate)
154
+ return;
155
+ let patchResult;
156
+ for (const { endpointName, originalArgs, } of favoriteApi.util.selectInvalidatedBy(mutationLifeCycleApi.getState(), [
157
+ {
158
+ type: 'FavoriteMerchantItem',
159
+ id: queryArgument.optimisticUpdate.product.id,
160
+ },
161
+ ])) {
162
+ if (endpointName !== 'getFavoriteMerchantItems')
163
+ continue;
164
+ patchResult = mutationLifeCycleApi.dispatch(favoriteApi.util.updateQueryData('getFavoriteMerchantItems', originalArgs, (draft) => {
165
+ draft.pages.forEach((favoriteMerchantItems) => {
166
+ favoriteMerchantItems.data.forEach((item, index) => {
167
+ if (item.id === queryArgument.optimisticUpdate?.product.id) {
168
+ favoriteMerchantItems.data.splice(index, 1);
169
+ }
170
+ });
171
+ });
172
+ }));
173
+ }
174
+ const favoriteCountPatchResult = mutationLifeCycleApi.dispatch(favoriteApi.util.updateQueryData('getFavoriteCount', undefined, (draft) => {
175
+ draft.total_quantity -= 1;
176
+ }));
177
+ let productPatchResult;
178
+ let supplierProductPatchResult;
179
+ let productDetailsPatchResult;
180
+ let supplierProductDetailsPatchResult;
181
+ for (const { endpointName, originalArgs, } of favoriteApi.util.selectInvalidatedBy(mutationLifeCycleApi.getState(), [
182
+ {
183
+ type: 'Product',
184
+ id: queryArgument.optimisticUpdate.product.id,
185
+ },
186
+ ])) {
187
+ if (endpointName !== 'getProducts')
188
+ continue;
189
+ productPatchResult = mutationLifeCycleApi.dispatch(favoriteApi.util.updateQueryData('getProducts', originalArgs, (draft) => {
190
+ draft.pages.forEach((page) => {
191
+ page.data.forEach((product) => {
192
+ if (product.id ===
193
+ queryArgument.optimisticUpdate?.product.id) {
194
+ product.in_favorite = false;
195
+ }
196
+ });
197
+ });
198
+ }));
199
+ }
200
+ for (const { endpointName, originalArgs, } of favoriteApi.util.selectInvalidatedBy(mutationLifeCycleApi.getState(), [
201
+ {
202
+ type: 'SupplierProduct',
203
+ id: queryArgument.optimisticUpdate.product.id,
204
+ },
205
+ ])) {
206
+ if (endpointName !== 'getSupplierProducts')
207
+ continue;
208
+ supplierProductPatchResult = mutationLifeCycleApi.dispatch(favoriteApi.util.updateQueryData('getSupplierProducts', originalArgs, (draft) => {
209
+ draft.pages.forEach((page) => {
210
+ page.data.forEach((product) => {
211
+ if (product.id ===
212
+ queryArgument.optimisticUpdate?.product.id) {
213
+ product.in_favorite = false;
214
+ }
215
+ });
216
+ });
217
+ }));
218
+ }
219
+ for (const { endpointName, originalArgs, } of favoriteApi.util.selectInvalidatedBy(mutationLifeCycleApi.getState(), [
220
+ {
221
+ type: 'ProductDetails',
222
+ id: queryArgument.optimisticUpdate.product.id,
223
+ },
224
+ ])) {
225
+ if (endpointName !== 'getProductDetails')
226
+ continue;
227
+ productDetailsPatchResult = mutationLifeCycleApi.dispatch(favoriteApi.util.updateQueryData('getProductDetails', originalArgs, (draft) => {
228
+ draft.data.in_favorite = false;
229
+ }));
230
+ }
231
+ for (const { endpointName, originalArgs, } of favoriteApi.util.selectInvalidatedBy(mutationLifeCycleApi.getState(), [
232
+ {
233
+ type: 'SupplierProductDetails',
234
+ id: queryArgument.optimisticUpdate.product.id,
235
+ },
236
+ ])) {
237
+ if (endpointName !== 'getSupplierProductDetails')
238
+ continue;
239
+ supplierProductDetailsPatchResult = mutationLifeCycleApi.dispatch(favoriteApi.util.updateQueryData('getSupplierProductDetails', originalArgs, (draft) => {
240
+ draft.data.in_favorite = false;
241
+ }));
242
+ }
243
+ try {
244
+ await mutationLifeCycleApi.queryFulfilled;
245
+ }
246
+ catch {
247
+ if (patchResult)
248
+ patchResult.undo();
249
+ favoriteCountPatchResult.undo();
250
+ if (productPatchResult)
251
+ productPatchResult.undo();
252
+ if (supplierProductPatchResult)
253
+ supplierProductPatchResult.undo();
254
+ if (productDetailsPatchResult)
255
+ productDetailsPatchResult.undo();
256
+ if (supplierProductDetailsPatchResult)
257
+ supplierProductDetailsPatchResult.undo();
258
+ }
259
+ },
260
+ }),
261
+ }),
262
+ overrideExisting: false,
263
+ })
264
+ .enhanceEndpoints({
265
+ // TODO: Refactor invalidation
266
+ addTagTypes: ['FavoriteCount', 'FavoriteMerchant', 'FavoriteMerchantItem'],
267
+ endpoints: {
268
+ getFavoriteCount: {
269
+ providesTags: (_result, _error, _arg, _meta) => {
270
+ return [{ type: 'FavoriteCount', id: 'LIST' }];
271
+ },
272
+ },
273
+ getFavoriteMerchants: {
274
+ providesTags: (result, _error, _arg, _meta) => {
275
+ return result
276
+ ? [
277
+ ...result.pages
278
+ .flatMap((page) => page.data)
279
+ .map((favoriteMerchant) => ({
280
+ type: 'FavoriteMerchant',
281
+ id: favoriteMerchant.store_id,
282
+ })),
283
+ { type: 'FavoriteMerchant', id: 'LIST' },
284
+ ]
285
+ : [{ type: 'FavoriteMerchant', id: 'LIST' }];
286
+ },
287
+ },
288
+ getFavoriteMerchantItems: {
289
+ providesTags: (result, _error, _arg, _meta) => {
290
+ return result
291
+ ? [
292
+ ...result.pages
293
+ .flatMap((page) => page.data)
294
+ .map((favoriteMerchantItem) => ({
295
+ type: 'FavoriteMerchantItem',
296
+ id: favoriteMerchantItem.favorite_item_id,
297
+ productId: favoriteMerchantItem.id,
298
+ })),
299
+ { type: 'FavoriteMerchantItem', id: 'LIST' },
300
+ ]
301
+ : [{ type: 'FavoriteMerchantItem', id: 'LIST' }];
302
+ },
303
+ },
304
+ addFavoriteMerchantItem: {
305
+ invalidatesTags: (_result, _error, arg, _meta) => {
306
+ return arg.optimisticUpdate
307
+ ? [
308
+ { type: 'FavoriteMerchant', id: 'LIST' },
309
+ { type: 'FavoriteMerchantItem', id: 'LIST' },
310
+ ]
311
+ : [
312
+ { type: 'FavoriteMerchant', id: 'LIST' },
313
+ { type: 'FavoriteMerchantItem', id: 'LIST' },
314
+ { type: 'FavoriteCount', id: 'LIST' },
315
+ { type: 'Product', id: arg.product_id },
316
+ { type: 'ProductDetails', id: arg.product_id },
317
+ { type: 'SupplierProduct', id: arg.product_id },
318
+ { type: 'SupplierProductDetails', id: arg.product_id },
319
+ { type: 'CartMerchantItem', productId: arg.product_id },
320
+ ];
321
+ },
322
+ },
323
+ deleteFavoriteMerchantItem: {
324
+ invalidatesTags: (_result, _error, arg, _meta) => {
325
+ return arg.optimisticUpdate
326
+ ? [
327
+ { type: 'FavoriteMerchant', id: 'LIST' },
328
+ { type: 'FavoriteMerchantItem', id: 'LIST' },
329
+ ]
330
+ : [
331
+ { type: 'FavoriteMerchant', id: 'LIST' },
332
+ { type: 'FavoriteMerchantItem', id: 'LIST' },
333
+ { type: 'FavoriteCount', id: 'LIST' },
334
+ { type: 'Product', id: arg.product_id },
335
+ { type: 'ProductDetails', id: arg.product_id },
336
+ { type: 'SupplierProduct', id: arg.product_id },
337
+ { type: 'SupplierProductDetails', id: arg.product_id },
338
+ { type: 'CartMerchantItem', productId: arg.product_id },
339
+ ];
340
+ },
341
+ },
342
+ },
343
+ });
344
+ //# sourceMappingURL=favoriteApi.js.map