@salla.sa/twilight 2.1.7 → 2.1.8

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salla.sa/twilight",
3
- "version": "2.1.7",
3
+ "version": "2.1.8",
4
4
  "description": "Salla Theme Toolkit, Webcomponents, Events, Requests, Utils",
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/esm/index.js",
@@ -1,2 +1,228 @@
1
+ import {SuccessResponse} from '../common'
2
+
3
+
4
+ export interface Loyalty {
5
+ loyalty_program_id: number;
6
+ name: string;
7
+ description: string;
8
+ image: string;
9
+ status: boolean;
10
+ points_validity_by: null;
11
+ points_validity_value: null;
12
+ prize_promotion_title: string;
13
+ prize_promotion_description: string;
14
+ prize_promotion_logo: string;
15
+ customer: Customer;
16
+ points: Point[];
17
+ prizes: Prize[];
18
+ }
19
+
20
+ export interface Customer {
21
+ id: number;
22
+ currency: string;
23
+ language: string;
24
+ first_name: string;
25
+ last_name: string;
26
+ phone: Phone;
27
+ email: string;
28
+ avatar: string;
29
+ gender: string;
30
+ birthday: Date;
31
+ loyalty_program_points: number;
32
+ }
33
+
34
+ export interface Phone {
35
+ code: string;
36
+ number: number;
37
+ country: string;
38
+ }
39
+
40
+ export interface Point {
41
+ id: number;
42
+ key: string;
43
+ name: string;
44
+ description: string;
45
+ status: boolean;
46
+ points: number;
47
+ icon: number;
48
+ color: number;
49
+ is_completed: boolean;
50
+ target_url: string;
51
+ share_store_url: string;
52
+ conditions: Condition[];
53
+ }
54
+
55
+ export interface Condition {
56
+ key: string;
57
+ points: number;
58
+ condition: null | string;
59
+ value: null;
60
+ op: string;
61
+ }
62
+
63
+ export interface Prize {
64
+ type: string;
65
+ title: string;
66
+ items: Item[];
67
+ }
68
+
69
+ export interface Item {
70
+ id: number;
71
+ key: string;
72
+ name: string;
73
+ description: string;
74
+ image: string;
75
+ status: number;
76
+ cost_points: number;
77
+ coupon_type: null | string;
78
+ coupon_amount: string;
79
+ coupon_maximum_amount: string;
80
+ included_category_ids: number[];
81
+ order_minimum_amount: string;
82
+ product_id: number | null;
83
+ use_product_image: number;
84
+ free_shipping_maximum_amount: string;
85
+ free_shipping_terms_apply: boolean;
86
+ prize_url: string;
87
+ }
88
+
89
+ /**
90
+ * Loyalty exchange Points
91
+ */
92
+ export interface ExchangePoint {
93
+ message: string;
94
+ cart: Cart;
95
+ }
96
+
97
+ export interface Cart {
98
+ items: ExchangeItem[];
99
+ require_shipping: boolean;
100
+ cart_total: CartTotal;
101
+ total_before_discount: CartTotal;
102
+ coupon: null;
103
+ free_shipping: FreeShipping;
104
+ loyalty_program: LoyaltyProgram;
105
+ }
106
+
107
+ export interface CartTotal {
108
+ amount: number;
109
+ currency: Currency;
110
+ }
111
+
112
+ export enum Currency {
113
+ Sar = "SAR",
114
+ }
115
+
116
+ export interface FreeShipping {
117
+ remaining_to_free_shipping: null;
118
+ has_free_shipping: boolean;
119
+ }
120
+
121
+ export interface ExchangeItem {
122
+ id: number;
123
+ url: string;
124
+ quantity: number;
125
+ product_id: number;
126
+ notes: null | string;
127
+ name: string;
128
+ price: CartTotal;
129
+ sale_price: CartTotal;
130
+ has_special_price: boolean;
131
+ regular_price: CartTotal;
132
+ image: string;
133
+ type: string;
134
+ hide_quantity: boolean;
135
+ features: Features;
136
+ discount_details: DiscountDetails | null;
137
+ max_items_per_user: number;
138
+ active_advance: boolean;
139
+ weight_label: string;
140
+ uploaded_files: any[];
141
+ options: Option[];
142
+ selected_options: SelectedOption[];
143
+ skus: any[];
144
+ }
145
+
146
+ export interface DiscountDetails {
147
+ discount: number;
148
+ item_total_price: CartTotal;
149
+ offer_type: null;
150
+ has_free_items: boolean;
151
+ offer_items_count: number;
152
+ special_price: CartTotal;
153
+ is_free: boolean;
154
+ name: string;
155
+ }
156
+
157
+ export interface Features {
158
+ upload_file: boolean;
159
+ note: boolean;
160
+ }
161
+
162
+ export interface Option {
163
+ id: number;
164
+ name: string;
165
+ description: string;
166
+ type: string;
167
+ required: boolean;
168
+ associated_with_order_time: number;
169
+ availability_range: boolean;
170
+ not_same_day_order: boolean;
171
+ choose_date_time: null;
172
+ from_date_time: null;
173
+ to_date_time: null;
174
+ sort: number;
175
+ advance: boolean;
176
+ display_type: null;
177
+ visibility: string;
178
+ translations: Object;
179
+ values: ValueElement[];
180
+ }
181
+
182
+ export interface ValueElement {
183
+ id: number;
184
+ name: string;
185
+ price: CartTotal;
186
+ display_value: null;
187
+ advance: boolean;
188
+ option_id: number;
189
+ image_url: null;
190
+ hashed_display_value: null;
191
+ translations: Object;
192
+ }
193
+
194
+ export interface SelectedOption {
195
+ id: number;
196
+ value: string[] | number;
197
+ }
198
+
199
+ export interface LoyaltyProgram {
200
+ points: number;
201
+ prize: ExchangePrize;
202
+ }
203
+
204
+ export interface ExchangePrize {
205
+ id: number;
206
+ name: string;
207
+ discount_amount: number;
208
+ points: number;
209
+ }
210
+
211
+
212
+ export namespace LoyaltyApiResponse {
213
+
214
+ export interface program extends SuccessResponse {
215
+ data: Loyalty
216
+ }
217
+
218
+
219
+ export interface point extends SuccessResponse {
220
+ data: ExchangePoint
221
+ }
222
+ }
223
+
224
+
1
225
  export default interface LoyaltyApi {
226
+ getProgram: () => Promise<LoyaltyApiResponse.program>
227
+ exchange: (prize_id: number, cart_id?: number) => Promise<LoyaltyApiResponse.point>
2
228
  }
@@ -1,2 +1,11 @@
1
+ import { RequestErrorEvent } from "../common";
2
+ import { LoyaltyApiResponse } from '../api/loyalty'
3
+
1
4
  export default interface LoyaltyEvent {
5
+
6
+ onProgramFetched: (callback: (response: LoyaltyApiResponse.program, prod_id: number) => void) => void;
7
+ onProgramNotFetched: RequestErrorEvent;
8
+ // Point
9
+ onExchangeFetched: (callback: (response: LoyaltyApiResponse.point, prod_id: number) => void) => void;
10
+ onExchangeFetchFailed: RequestErrorEvent;
2
11
  }