@salla.sa/twilight 2.2.8 → 2.4.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salla.sa/twilight",
3
- "version": "2.2.8",
3
+ "version": "2.4.0",
4
4
  "description": "Salla Theme Toolkit, Webcomponents, Events, Requests, Utils",
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/esm/index.js",
@@ -0,0 +1,42 @@
1
+ import { SuccessResponse } from "../common";
2
+
3
+ export interface Scope {
4
+ id: number;
5
+ name: string;
6
+ selected: boolean;
7
+ }
8
+
9
+ export interface ProductAvailability {
10
+ name: string;
11
+ selected: boolean;
12
+ availability: Availability;
13
+ }
14
+
15
+ export interface Availability {
16
+ label: string;
17
+ key: string;
18
+ color: string;
19
+ }
20
+
21
+
22
+ export namespace ScopeApiResponse {
23
+
24
+ export interface scopeList extends SuccessResponse {
25
+ data: Scope[];
26
+ }
27
+
28
+ export interface scopeAddition extends SuccessResponse {
29
+ data: Scope
30
+ }
31
+
32
+ export interface availability extends SuccessResponse {
33
+ data: ProductAvailability[];
34
+ }
35
+ }
36
+
37
+
38
+ export default interface ScopeApi {
39
+ get: () => Promise<ScopeApiResponse.scopeList>
40
+ createScope: (payload: Object) => Promise<SuccessResponse>
41
+ getProductAvailability: (product_id: number) => Promise<ScopeApiResponse.availability>
42
+ }
@@ -1,4 +1,4 @@
1
- import {SuccessResponse} from "../../common";
1
+ import { SuccessResponse } from "../../common";
2
2
  export namespace CartResponse {
3
3
  export interface update extends SuccessResponse {
4
4
  data: CartUpdatedData;
@@ -1,6 +1,6 @@
1
- import {SuccessResponse} from "../../common";
2
- import {ProductResponse} from "./response";
3
- import {ProductRequest} from "./request";
1
+ import { SuccessResponse } from "../../common";
2
+ import { ProductResponse } from "./response";
3
+ import { ProductRequest } from "./request";
4
4
 
5
5
  export * from "./request";
6
6
  export * from "./response";
@@ -11,4 +11,6 @@ export default interface ProductApi {
11
11
  search: (keyword: string | ProductRequest.search) => Promise<ProductResponse.search>;
12
12
  categories: (categoryId?: number) => Promise<ProductResponse.categories>; //get all categories or sub_categories
13
13
  offers: (product_id: number) => Promise<ProductResponse.offers>; //get all categories or sub_categories
14
+ getGiftDetails: (product_id: number) => Promise<ProductResponse.giftResponse>;
15
+ addGiftToCart: (product_id: number, payload: Object, withRedirect: boolean);
14
16
  }
@@ -8,6 +8,14 @@ export interface Category {
8
8
 
9
9
  export type ProductOption = { [key: number]: number | string | number[] };
10
10
 
11
+
12
+ export interface Receiver {
13
+ name: string;
14
+ country_code: string;
15
+ mobile: string;
16
+ }
17
+
18
+
11
19
  export namespace ProductRequest {
12
20
  export interface addItem {
13
21
  id: number;
@@ -32,4 +40,14 @@ export namespace ProductRequest {
32
40
  country_code?: string | 'SA';//required when request without email
33
41
  phone?: string | '555555555';//required when request without email
34
42
  }
43
+
44
+ export interface giftToCart {
45
+ text: string;
46
+ sender_name: string;
47
+ receiver: Receiver;
48
+ quantity: number;
49
+ deliver_at: string;
50
+ image_url: string;
51
+ time_zone: string;
52
+ }
35
53
  }
@@ -37,6 +37,27 @@ export interface Offer {
37
37
  }
38
38
  }
39
39
 
40
+ /**
41
+ * Gifting System
42
+ */
43
+ export interface Gift {
44
+ quantity: number;
45
+ product: Product;
46
+ sender_name: string;
47
+ images: GiftImage[];
48
+ texts: GiftText[];
49
+ }
50
+
51
+ export interface GiftImage {
52
+ id: number;
53
+ url: string;
54
+ }
55
+
56
+ export interface GiftText {
57
+ id: number;
58
+ text: string;
59
+ }
60
+
40
61
  export namespace ProductResponse {
41
62
  export interface search extends SuccessResponse {
42
63
  data: Product[];
@@ -67,7 +88,16 @@ export namespace ProductResponse {
67
88
  export interface sizeGuides extends SuccessResponse {
68
89
  data: Array<SizeGuide>;
69
90
  }
70
-
71
91
 
92
+ export interface giftResponse extends SuccessResponse {
93
+ data: Gift
94
+ }
95
+
96
+ export interface giftToCart extends SuccessResponse {
97
+ data: Object
98
+ }
72
99
 
100
+ export interface giftImageUpload extends SuccessResponse {
101
+ data: Object | String
102
+ }
73
103
  }
@@ -0,0 +1,14 @@
1
+ import { RequestErrorEvent } from "../common";
2
+ import { ScopeApiResponse } from '../api/branches'
3
+
4
+ export default interface BranchesEvent {
5
+ onScopeFetched: (callback: (response: ScopeApiResponse.scopeList) => void) => void;
6
+ onScopeFetchFailed: RequestErrorEvent;
7
+ // POST
8
+ onNewScopeSubmitted: (callback: (response: ScopeApiResponse.scopeAddition) => void) => void;
9
+ onscopeChangeFailed: RequestErrorEvent;
10
+
11
+ // Availability
12
+ onproductAvailableFetched: (callback: (response: ScopeApiResponse.availability, product_id: number) => void) => void;
13
+ onProductAvailabilityFetchFailed: RequestErrorEvent;
14
+ }
@@ -1,6 +1,6 @@
1
- import {OfferSummary} from "../api/cart";
2
- import {ProductResponse} from "../api/product";
3
- import {RequestError, RequestErrorEvent, RequestErrorEventWithData, SuccessResponse} from "../common";
1
+ import { OfferSummary } from "../api/cart";
2
+ import { ProductResponse } from "../api/product";
3
+ import { RequestError, RequestErrorEvent, RequestErrorEventWithData, SuccessResponse } from "../common";
4
4
 
5
5
  export default interface ProductEvent {
6
6
  onPriceUpdated: (callback: (response: ProductResponse.getPrice, product_id: number) => void) => void;
@@ -10,7 +10,7 @@ export default interface ProductEvent {
10
10
  onCategoriesFetched: (callback: (response: ProductResponse.categories) => void) => void;
11
11
  onCategoriesFailed: RequestError;
12
12
  onSearchResults: (callback: (response: ProductResponse.search, query?: string) => void) => void;
13
- onSearchFailed: RequestErrorEventWithData</*query*/string|undefined>;
13
+ onSearchFailed: RequestErrorEventWithData</*query*/string | undefined>;
14
14
 
15
15
  onOfferExisted: (callback: (offer: OfferSummary) => void) => void;
16
16
  onOffersFetched: (callback: (response: ProductResponse.offers) => void) => void;
@@ -18,4 +18,13 @@ export default interface ProductEvent {
18
18
 
19
19
  onSizeGuideFetched: (callback: (response: ProductResponse.sizeGuides, prod_id: number) => void) => void;
20
20
  onSizeGuideFetchFailed: RequestErrorEvent;
21
+
22
+ onGiftFetched: (callback: (response: ProductResponse.giftResponse, product_id: number) => void) => void;
23
+ onGiftFetchFailed: RequestErrorEvent;
24
+
25
+ onAddGiftToCartSucceeded: (callback: (response: ProductResponse.giftToCart, product_id: number) => void) => void;
26
+ onAddGiftToCartFailed: RequestErrorEvent;
27
+
28
+ onGiftImageUploadSucceeded: (callback: (response: ProductResponse.giftImageUpload) => void) => void;
29
+ onGiftImageUploadFailed: RequestErrorEvent;
21
30
  }
@@ -1,27 +0,0 @@
1
- import {SuccessResponse} from "../common";
2
-
3
- export interface GiftPayload {
4
- id: number;
5
- image?: BinaryType;
6
- image_url_id?: number;
7
- text_id?: number;//required if text not provided
8
- text?: string;//required if text_id not provided
9
- sender_name?: string;
10
- receiver: {
11
- name: string;
12
- mobile: number;
13
- country_code: string | 'SA';
14
- email?: string;
15
- };
16
- deliver_at: string | '2022-02-22 02:22 pm';
17
- }
18
-
19
- export interface GiftResponse extends SuccessResponse {
20
- data:{
21
- redirect: string;
22
- }
23
- }
24
-
25
- export default interface GiftApi {
26
- buy: (GiftPayload) => Promise<GiftResponse>;
27
- }
@@ -1,7 +0,0 @@
1
- import { RequestErrorEventWithData} from "../common";
2
- import {GiftResponse} from "../api/gift";
3
-
4
- export default interface GiftEvent {
5
- onBuyingSucceeded: (callback: (response: GiftResponse, product_id: number) => void) => void;
6
- onBuyingFailed: RequestErrorEventWithData</*product_id*/number|undefined>;
7
- }