@deallony/shared 1.1.98 → 1.2.1

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.
@@ -4,5 +4,6 @@ export * as AD from "./ad";
4
4
  export * as EVENTS from "./events";
5
5
  export * as MOTOR from "./motor";
6
6
  export * as PROPERTY from "./property";
7
+ export * as ROUTES from "./routes";
7
8
  export * as SERVICE from "./service";
8
9
  export * as USED_PRODUCT from "./used-product";
@@ -33,12 +33,13 @@ var __importStar = (this && this.__importStar) || (function () {
33
33
  };
34
34
  })();
35
35
  Object.defineProperty(exports, "__esModule", { value: true });
36
- exports.USED_PRODUCT = exports.SERVICE = exports.PROPERTY = exports.MOTOR = exports.EVENTS = exports.AD = exports.COMMON = exports.Subject = void 0;
36
+ exports.USED_PRODUCT = exports.SERVICE = exports.ROUTES = exports.PROPERTY = exports.MOTOR = exports.EVENTS = exports.AD = exports.COMMON = exports.Subject = void 0;
37
37
  exports.Subject = __importStar(require("./common/Subject"));
38
38
  exports.COMMON = __importStar(require("./common"));
39
39
  exports.AD = __importStar(require("./ad"));
40
40
  exports.EVENTS = __importStar(require("./events"));
41
41
  exports.MOTOR = __importStar(require("./motor"));
42
42
  exports.PROPERTY = __importStar(require("./property"));
43
+ exports.ROUTES = __importStar(require("./routes"));
43
44
  exports.SERVICE = __importStar(require("./service"));
44
45
  exports.USED_PRODUCT = __importStar(require("./used-product"));
@@ -0,0 +1,303 @@
1
+ type SubjectTypeValue = string;
2
+ type GenericParams = Record<string, unknown>;
3
+ export declare const APP_ROUTES: {
4
+ readonly main: {
5
+ readonly home: () => {
6
+ pathname: string;
7
+ };
8
+ };
9
+ readonly categories: {
10
+ readonly all: (params: {
11
+ type: SubjectTypeValue;
12
+ }) => {
13
+ pathname: string;
14
+ params: {
15
+ type: SubjectTypeValue;
16
+ };
17
+ };
18
+ readonly filter_by_id: (params: {
19
+ category_id: string | number;
20
+ type: SubjectTypeValue;
21
+ }) => {
22
+ pathname: string;
23
+ params: {
24
+ id: string | number;
25
+ category_id: string | number;
26
+ type: string;
27
+ };
28
+ };
29
+ };
30
+ readonly ads: {
31
+ readonly new: (props?: {
32
+ categoryId?: unknown;
33
+ subject_type?: SubjectTypeValue;
34
+ }) => {
35
+ pathname: string;
36
+ params: {
37
+ categoryId?: unknown;
38
+ subject_type?: SubjectTypeValue;
39
+ };
40
+ };
41
+ readonly details: (ad_id: number | string, ad?: unknown) => {
42
+ pathname: string;
43
+ params: {
44
+ id: string | number;
45
+ ad: string;
46
+ };
47
+ };
48
+ readonly filter: (props: {
49
+ subject_type: SubjectTypeValue;
50
+ category_id?: number;
51
+ }) => {
52
+ pathname: string;
53
+ params: {
54
+ subject_type: SubjectTypeValue;
55
+ category_id?: number;
56
+ };
57
+ };
58
+ readonly promote: (params: {
59
+ id: number | string;
60
+ }) => {
61
+ pathname: string;
62
+ params: {
63
+ ad_id: string | number;
64
+ };
65
+ };
66
+ readonly promotionHistory: (params: {
67
+ id: number | string;
68
+ }) => {
69
+ pathname: string;
70
+ params: {
71
+ ad_id: string | number;
72
+ };
73
+ };
74
+ readonly list: (params: GenericParams) => {
75
+ pathname: string;
76
+ params: {
77
+ subject_type: {};
78
+ filter: string;
79
+ };
80
+ } | {
81
+ pathname: string;
82
+ params: {
83
+ filter: string;
84
+ subject_type?: undefined;
85
+ };
86
+ };
87
+ };
88
+ readonly properties: {
89
+ readonly add: (props?: {
90
+ categoryId?: number;
91
+ }) => {
92
+ pathname: string;
93
+ params: {
94
+ categoryId?: number;
95
+ };
96
+ };
97
+ readonly edit: (property_id: number | string) => {
98
+ pathname: string;
99
+ params: {
100
+ id: string | number;
101
+ };
102
+ };
103
+ };
104
+ readonly motor: {
105
+ readonly add: (props?: {
106
+ categoryId?: number;
107
+ }) => {
108
+ pathname: string;
109
+ params: {
110
+ categoryId?: number;
111
+ };
112
+ };
113
+ readonly edit: (motor_id: number | string) => {
114
+ pathname: string;
115
+ params: {
116
+ id: string | number;
117
+ };
118
+ };
119
+ };
120
+ readonly services: {
121
+ readonly add: (props?: {
122
+ categoryId?: number;
123
+ }) => {
124
+ pathname: string;
125
+ params: {
126
+ categoryId?: number;
127
+ };
128
+ };
129
+ readonly edit: (service_id: number | string) => {
130
+ pathname: string;
131
+ params: {
132
+ id: string | number;
133
+ };
134
+ };
135
+ readonly myService: () => {
136
+ pathname: string;
137
+ };
138
+ readonly filtered_list: (params: {
139
+ category_id: number;
140
+ price_max: number;
141
+ price_min_fixed: number;
142
+ access_type_id: number;
143
+ text: string;
144
+ city_id: number;
145
+ district_ids: number[];
146
+ getDefault: "1" | "0";
147
+ }) => {
148
+ pathname: string;
149
+ params: {
150
+ getDefault: "0" | "1";
151
+ category_id: number;
152
+ price_max: number;
153
+ price_min_fixed: number;
154
+ access_type_id: number;
155
+ text: string;
156
+ city_id: number;
157
+ district_ids: number[];
158
+ };
159
+ };
160
+ };
161
+ readonly system: {
162
+ readonly privicy: () => {
163
+ pathname: string;
164
+ };
165
+ readonly general_settings: () => {
166
+ pathname: string;
167
+ };
168
+ readonly contact: () => {
169
+ pathname: string;
170
+ };
171
+ readonly download: () => {
172
+ pathname: string;
173
+ };
174
+ readonly needMobileApp: () => {
175
+ pathname: string;
176
+ };
177
+ readonly noInternet: () => {
178
+ pathname: string;
179
+ };
180
+ };
181
+ readonly settings: {
182
+ readonly selectCurrency: () => {
183
+ pathname: string;
184
+ };
185
+ readonly selectCity: () => {
186
+ pathname: string;
187
+ };
188
+ readonly selectBoundary: () => {
189
+ pathname: string;
190
+ };
191
+ readonly general_settings: () => {
192
+ pathname: string;
193
+ };
194
+ };
195
+ readonly auth: {
196
+ readonly login: (props?: {
197
+ categoryId?: unknown;
198
+ subject_type?: SubjectTypeValue;
199
+ }) => {
200
+ pathname: string;
201
+ params: {
202
+ categoryId?: unknown;
203
+ subject_type?: SubjectTypeValue;
204
+ };
205
+ };
206
+ readonly editProfile: () => {
207
+ pathname: string;
208
+ };
209
+ };
210
+ readonly user: {
211
+ readonly myAds: () => {
212
+ pathname: string;
213
+ };
214
+ readonly favorites: () => {
215
+ pathname: string;
216
+ };
217
+ readonly profile: (id: string | number) => {
218
+ pathname: string;
219
+ params: {
220
+ id: string | number;
221
+ };
222
+ };
223
+ readonly referral: () => {
224
+ pathname: string;
225
+ };
226
+ readonly referralCode: (code: string) => {
227
+ pathname: string;
228
+ params: {
229
+ code: string;
230
+ };
231
+ };
232
+ readonly myReferralCode: () => {
233
+ pathname: string;
234
+ };
235
+ readonly myNumbers: () => {
236
+ pathname: string;
237
+ };
238
+ };
239
+ readonly product: {
240
+ readonly save: (props?: {
241
+ product_id?: number | string;
242
+ isFree?: boolean;
243
+ categoryId?: number;
244
+ }) => {
245
+ pathname: string;
246
+ params: {
247
+ id: string | number | undefined;
248
+ isFree: boolean | undefined;
249
+ categoryId: number | undefined;
250
+ };
251
+ };
252
+ };
253
+ readonly chat: {
254
+ readonly chatlist: () => {
255
+ pathname: string;
256
+ };
257
+ readonly messages: (params: {
258
+ provider_id: string | number;
259
+ chat_room_id: string | number;
260
+ ad_id: string | number;
261
+ requester_id: string | number;
262
+ }) => {
263
+ pathname: string;
264
+ params: {
265
+ provider_id: string | number;
266
+ chat_room_id: string | number;
267
+ ad_id: string | number;
268
+ requester_id: string | number;
269
+ };
270
+ };
271
+ readonly offerPrice: (props: {
272
+ provider_id: string | number;
273
+ ad_price: number;
274
+ currency_id: number;
275
+ ad_id?: string | number;
276
+ chat_room_id?: string | number;
277
+ by_call: string;
278
+ by_message: string;
279
+ by_whatsapp: string;
280
+ phone: string;
281
+ }) => {
282
+ pathname: string;
283
+ params: {
284
+ provider_id: string | number;
285
+ currency_id: number;
286
+ ad_id: string | number | undefined;
287
+ chat_room_id: string | number | undefined;
288
+ by_call: string;
289
+ by_message: string;
290
+ by_whatsapp: string;
291
+ phone: string;
292
+ ad_price: number;
293
+ };
294
+ };
295
+ };
296
+ readonly wallet: {
297
+ readonly details: () => {
298
+ pathname: string;
299
+ };
300
+ };
301
+ };
302
+ export type SharedAppRoutes = typeof APP_ROUTES;
303
+ export {};
@@ -0,0 +1,136 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.APP_ROUTES = void 0;
4
+ exports.APP_ROUTES = {
5
+ main: {
6
+ home: () => ({ pathname: "/(tabs)" }),
7
+ },
8
+ categories: {
9
+ all: (params) => ({
10
+ pathname: "/category/all-category",
11
+ params,
12
+ }),
13
+ filter_by_id: (params) => ({
14
+ pathname: "/category/[id]",
15
+ params: { id: params.category_id, category_id: params.category_id, type: params.type },
16
+ }),
17
+ },
18
+ ads: {
19
+ new: (props) => ({
20
+ pathname: "/ad/new",
21
+ params: { ...props },
22
+ }),
23
+ details: (ad_id, ad) => {
24
+ const data = JSON.stringify(ad);
25
+ return { pathname: "/ad/details/[id]", params: { id: ad_id, ad: data } };
26
+ },
27
+ filter: (props) => ({
28
+ pathname: "/ad/filter",
29
+ params: { ...props },
30
+ }),
31
+ promote: (params) => ({
32
+ pathname: "/ad/promotions/new/[ad_id]",
33
+ params: { ad_id: params.id },
34
+ }),
35
+ promotionHistory: (params) => ({
36
+ pathname: "/ad/promotions/history/[ad_id]",
37
+ params: { ad_id: params.id },
38
+ }),
39
+ list: (params) => {
40
+ const filter = JSON.stringify(params);
41
+ if (params === null || params === void 0 ? void 0 : params.subject_type) {
42
+ return {
43
+ pathname: "/ad/[subject_type]",
44
+ params: {
45
+ subject_type: params.subject_type,
46
+ filter,
47
+ },
48
+ };
49
+ }
50
+ return {
51
+ pathname: "/ad/list",
52
+ params: { filter },
53
+ };
54
+ },
55
+ },
56
+ properties: {
57
+ add: (props) => ({ pathname: "/properties/save", params: { ...props } }),
58
+ edit: (property_id) => ({ pathname: "/properties/save", params: { id: property_id } }),
59
+ },
60
+ motor: {
61
+ add: (props) => ({ pathname: "/motor/save", params: { ...props } }),
62
+ edit: (motor_id) => ({ pathname: "/motor/save", params: { id: motor_id } }),
63
+ },
64
+ services: {
65
+ add: (props) => ({ pathname: "/screens/AddServiceScreen", params: { ...props } }),
66
+ edit: (service_id) => ({ pathname: "/screens/AddServiceScreen", params: { id: service_id } }),
67
+ myService: () => ({ pathname: "/(tabs)/my-service" }),
68
+ filtered_list: (params) => ({
69
+ pathname: "/services/list/filtred",
70
+ params: {
71
+ ...params,
72
+ getDefault: params.getDefault || "1",
73
+ },
74
+ }),
75
+ },
76
+ system: {
77
+ privicy: () => ({ pathname: "/privacy-policy" }),
78
+ general_settings: () => ({ pathname: "/system/general-settings" }),
79
+ contact: () => ({ pathname: "/system/contact-us" }),
80
+ download: () => ({ pathname: "/system/download-app" }),
81
+ needMobileApp: () => ({ pathname: "/system/need-mobile-app" }),
82
+ noInternet: () => ({ pathname: "/system/no-internet" }),
83
+ },
84
+ settings: {
85
+ selectCurrency: () => ({ pathname: "/settings/select-currency" }),
86
+ selectCity: () => ({ pathname: "/settings/select-city" }),
87
+ selectBoundary: () => ({ pathname: "/settings/select-boundary" }),
88
+ general_settings: () => ({ pathname: "/system/general-settings" }),
89
+ },
90
+ auth: {
91
+ login: (props) => ({
92
+ pathname: "/auth/login",
93
+ params: { ...props },
94
+ }),
95
+ editProfile: () => ({ pathname: "/auth/edit-profile" }),
96
+ },
97
+ user: {
98
+ myAds: () => ({ pathname: "/(tabs)/my-service" }),
99
+ favorites: () => ({ pathname: "/(tabs)/favorite" }),
100
+ profile: (id) => ({ pathname: "/user/profile/[id]", params: { id } }),
101
+ referral: () => ({ pathname: "/user/referral" }),
102
+ referralCode: (code) => ({ pathname: "/user/referral/[code]", params: { code } }),
103
+ myReferralCode: () => ({ pathname: "/user/referral/my-code" }),
104
+ myNumbers: () => ({ pathname: "/user/my-numbers" }),
105
+ },
106
+ product: {
107
+ save: (props) => ({
108
+ pathname: "/products/save",
109
+ params: { id: props === null || props === void 0 ? void 0 : props.product_id, isFree: props === null || props === void 0 ? void 0 : props.isFree, categoryId: props === null || props === void 0 ? void 0 : props.categoryId },
110
+ }),
111
+ },
112
+ chat: {
113
+ chatlist: () => ({ pathname: "/(tabs)/chat" }),
114
+ messages: (params) => ({
115
+ pathname: "/chat/[provider_id]",
116
+ params,
117
+ }),
118
+ offerPrice: (props) => ({
119
+ pathname: "/chat/offer-price",
120
+ params: {
121
+ provider_id: props.provider_id,
122
+ currency_id: props.currency_id,
123
+ ad_id: props.ad_id,
124
+ chat_room_id: props.chat_room_id,
125
+ by_call: props.by_call,
126
+ by_message: props.by_message,
127
+ by_whatsapp: props.by_whatsapp,
128
+ phone: props.phone,
129
+ ad_price: props.ad_price,
130
+ },
131
+ }),
132
+ },
133
+ wallet: {
134
+ details: () => ({ pathname: "/wallet" }),
135
+ },
136
+ };
@@ -0,0 +1 @@
1
+ export * from "./app";
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./app"), exports);
@@ -1 +1,2 @@
1
1
  export * from './converter';
2
+ export * from './routes';
@@ -15,3 +15,4 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./converter"), exports);
18
+ __exportStar(require("./routes"), exports);
@@ -0,0 +1,11 @@
1
+ type RoutePrimitive = string | number | boolean;
2
+ type RouteParamValue = RoutePrimitive | null | undefined | RoutePrimitive[];
3
+ export type RouteLike = {
4
+ pathname: string;
5
+ params?: Record<string, RouteParamValue>;
6
+ };
7
+ export declare const routeToString: (route: RouteLike) => string;
8
+ export declare const RoutesUtils: {
9
+ routeToString: (route: RouteLike) => string;
10
+ };
11
+ export {};
@@ -0,0 +1,41 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.RoutesUtils = exports.routeToString = void 0;
4
+ const isNil = (value) => value == null;
5
+ const encodeParam = (value) => encodeURIComponent(String(value));
6
+ const stringifyQueryValue = (value) => {
7
+ if (isNil(value)) {
8
+ return undefined;
9
+ }
10
+ if (Array.isArray(value)) {
11
+ if (!value.length) {
12
+ return undefined;
13
+ }
14
+ return value.map((item) => encodeParam(item)).join(",");
15
+ }
16
+ return encodeParam(value);
17
+ };
18
+ const routeToString = (route) => {
19
+ const rawPathname = (route === null || route === void 0 ? void 0 : route.pathname) || "";
20
+ const params = (route === null || route === void 0 ? void 0 : route.params) || {};
21
+ let pathname = rawPathname;
22
+ const queryEntries = [];
23
+ for (const [key, value] of Object.entries(params)) {
24
+ const dynamicSegment = `[${key}]`;
25
+ if (pathname.includes(dynamicSegment) && !isNil(value) && !Array.isArray(value)) {
26
+ pathname = pathname.replace(dynamicSegment, encodeParam(value));
27
+ continue;
28
+ }
29
+ const queryValue = stringifyQueryValue(value);
30
+ if (queryValue === undefined) {
31
+ continue;
32
+ }
33
+ queryEntries.push(`${encodeURIComponent(key)}=${queryValue}`);
34
+ }
35
+ const query = queryEntries.join("&");
36
+ return query ? `${pathname}?${query}` : pathname;
37
+ };
38
+ exports.routeToString = routeToString;
39
+ exports.RoutesUtils = {
40
+ routeToString: exports.routeToString,
41
+ };
@@ -4,5 +4,6 @@ export * as AD from "./ad/index.js";
4
4
  export * as EVENTS from "./events/index.js";
5
5
  export * as MOTOR from "./motor/index.js";
6
6
  export * as PROPERTY from "./property/index.js";
7
+ export * as ROUTES from "./routes/index.js";
7
8
  export * as SERVICE from "./service/index.js";
8
9
  export * as USED_PRODUCT from "./used-product/index.js";
@@ -0,0 +1,133 @@
1
+ export const APP_ROUTES = {
2
+ main: {
3
+ home: () => ({ pathname: "/(tabs)" }),
4
+ },
5
+ categories: {
6
+ all: (params) => ({
7
+ pathname: "/category/all-category",
8
+ params,
9
+ }),
10
+ filter_by_id: (params) => ({
11
+ pathname: "/category/[id]",
12
+ params: { id: params.category_id, category_id: params.category_id, type: params.type },
13
+ }),
14
+ },
15
+ ads: {
16
+ new: (props) => ({
17
+ pathname: "/ad/new",
18
+ params: { ...props },
19
+ }),
20
+ details: (ad_id, ad) => {
21
+ const data = JSON.stringify(ad);
22
+ return { pathname: "/ad/details/[id]", params: { id: ad_id, ad: data } };
23
+ },
24
+ filter: (props) => ({
25
+ pathname: "/ad/filter",
26
+ params: { ...props },
27
+ }),
28
+ promote: (params) => ({
29
+ pathname: "/ad/promotions/new/[ad_id]",
30
+ params: { ad_id: params.id },
31
+ }),
32
+ promotionHistory: (params) => ({
33
+ pathname: "/ad/promotions/history/[ad_id]",
34
+ params: { ad_id: params.id },
35
+ }),
36
+ list: (params) => {
37
+ const filter = JSON.stringify(params);
38
+ if (params === null || params === void 0 ? void 0 : params.subject_type) {
39
+ return {
40
+ pathname: "/ad/[subject_type]",
41
+ params: {
42
+ subject_type: params.subject_type,
43
+ filter,
44
+ },
45
+ };
46
+ }
47
+ return {
48
+ pathname: "/ad/list",
49
+ params: { filter },
50
+ };
51
+ },
52
+ },
53
+ properties: {
54
+ add: (props) => ({ pathname: "/properties/save", params: { ...props } }),
55
+ edit: (property_id) => ({ pathname: "/properties/save", params: { id: property_id } }),
56
+ },
57
+ motor: {
58
+ add: (props) => ({ pathname: "/motor/save", params: { ...props } }),
59
+ edit: (motor_id) => ({ pathname: "/motor/save", params: { id: motor_id } }),
60
+ },
61
+ services: {
62
+ add: (props) => ({ pathname: "/screens/AddServiceScreen", params: { ...props } }),
63
+ edit: (service_id) => ({ pathname: "/screens/AddServiceScreen", params: { id: service_id } }),
64
+ myService: () => ({ pathname: "/(tabs)/my-service" }),
65
+ filtered_list: (params) => ({
66
+ pathname: "/services/list/filtred",
67
+ params: {
68
+ ...params,
69
+ getDefault: params.getDefault || "1",
70
+ },
71
+ }),
72
+ },
73
+ system: {
74
+ privicy: () => ({ pathname: "/privacy-policy" }),
75
+ general_settings: () => ({ pathname: "/system/general-settings" }),
76
+ contact: () => ({ pathname: "/system/contact-us" }),
77
+ download: () => ({ pathname: "/system/download-app" }),
78
+ needMobileApp: () => ({ pathname: "/system/need-mobile-app" }),
79
+ noInternet: () => ({ pathname: "/system/no-internet" }),
80
+ },
81
+ settings: {
82
+ selectCurrency: () => ({ pathname: "/settings/select-currency" }),
83
+ selectCity: () => ({ pathname: "/settings/select-city" }),
84
+ selectBoundary: () => ({ pathname: "/settings/select-boundary" }),
85
+ general_settings: () => ({ pathname: "/system/general-settings" }),
86
+ },
87
+ auth: {
88
+ login: (props) => ({
89
+ pathname: "/auth/login",
90
+ params: { ...props },
91
+ }),
92
+ editProfile: () => ({ pathname: "/auth/edit-profile" }),
93
+ },
94
+ user: {
95
+ myAds: () => ({ pathname: "/(tabs)/my-service" }),
96
+ favorites: () => ({ pathname: "/(tabs)/favorite" }),
97
+ profile: (id) => ({ pathname: "/user/profile/[id]", params: { id } }),
98
+ referral: () => ({ pathname: "/user/referral" }),
99
+ referralCode: (code) => ({ pathname: "/user/referral/[code]", params: { code } }),
100
+ myReferralCode: () => ({ pathname: "/user/referral/my-code" }),
101
+ myNumbers: () => ({ pathname: "/user/my-numbers" }),
102
+ },
103
+ product: {
104
+ save: (props) => ({
105
+ pathname: "/products/save",
106
+ params: { id: props === null || props === void 0 ? void 0 : props.product_id, isFree: props === null || props === void 0 ? void 0 : props.isFree, categoryId: props === null || props === void 0 ? void 0 : props.categoryId },
107
+ }),
108
+ },
109
+ chat: {
110
+ chatlist: () => ({ pathname: "/(tabs)/chat" }),
111
+ messages: (params) => ({
112
+ pathname: "/chat/[provider_id]",
113
+ params,
114
+ }),
115
+ offerPrice: (props) => ({
116
+ pathname: "/chat/offer-price",
117
+ params: {
118
+ provider_id: props.provider_id,
119
+ currency_id: props.currency_id,
120
+ ad_id: props.ad_id,
121
+ chat_room_id: props.chat_room_id,
122
+ by_call: props.by_call,
123
+ by_message: props.by_message,
124
+ by_whatsapp: props.by_whatsapp,
125
+ phone: props.phone,
126
+ ad_price: props.ad_price,
127
+ },
128
+ }),
129
+ },
130
+ wallet: {
131
+ details: () => ({ pathname: "/wallet" }),
132
+ },
133
+ };
@@ -0,0 +1 @@
1
+ export * from "./app.js";
@@ -1 +1,2 @@
1
1
  export * from './converter.js';
2
+ export * from './routes.js';
@@ -0,0 +1,37 @@
1
+ const isNil = (value) => value == null;
2
+ const encodeParam = (value) => encodeURIComponent(String(value));
3
+ const stringifyQueryValue = (value) => {
4
+ if (isNil(value)) {
5
+ return undefined;
6
+ }
7
+ if (Array.isArray(value)) {
8
+ if (!value.length) {
9
+ return undefined;
10
+ }
11
+ return value.map((item) => encodeParam(item)).join(",");
12
+ }
13
+ return encodeParam(value);
14
+ };
15
+ export const routeToString = (route) => {
16
+ const rawPathname = (route === null || route === void 0 ? void 0 : route.pathname) || "";
17
+ const params = (route === null || route === void 0 ? void 0 : route.params) || {};
18
+ let pathname = rawPathname;
19
+ const queryEntries = [];
20
+ for (const [key, value] of Object.entries(params)) {
21
+ const dynamicSegment = `[${key}]`;
22
+ if (pathname.includes(dynamicSegment) && !isNil(value) && !Array.isArray(value)) {
23
+ pathname = pathname.replace(dynamicSegment, encodeParam(value));
24
+ continue;
25
+ }
26
+ const queryValue = stringifyQueryValue(value);
27
+ if (queryValue === undefined) {
28
+ continue;
29
+ }
30
+ queryEntries.push(`${encodeURIComponent(key)}=${queryValue}`);
31
+ }
32
+ const query = queryEntries.join("&");
33
+ return query ? `${pathname}?${query}` : pathname;
34
+ };
35
+ export const RoutesUtils = {
36
+ routeToString,
37
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@deallony/shared",
3
- "version": "1.1.98",
3
+ "version": "1.2.01",
4
4
  "private": false,
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/esm/index.js",