umwd-components 0.1.663 → 0.1.664

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.
@@ -0,0 +1,9 @@
1
+ export declare function getExtendedEnduserMeLoader(): Promise<{
2
+ ok: boolean;
3
+ data: null;
4
+ error: any;
5
+ } | {
6
+ ok: boolean;
7
+ data: any;
8
+ error: null;
9
+ }>;
@@ -7,4 +7,3 @@ export declare function getExtendedDispatcherMeLoader(): Promise<{
7
7
  data: any;
8
8
  error: null;
9
9
  }>;
10
- export declare function getDispatcherMeLoader(token: string): Promise<any>;
@@ -189,7 +189,6 @@ export { default as EnduserProfileEditForm } from "./components/e-commerce/endus
189
189
  export { default as EnduserProfileDisplay } from "./components/e-commerce/enduser/EnduserProfileDisplay";
190
190
  export { updateDispatcherProfileAction as updateDispatcherProfileAction } from "./data/actions/logistics/dispatcher/profile-actions";
191
191
  export { getExtendedDispatcherMeLoader as getExtendedDispatcherMeLoader } from "./data/services/logistics/dispatcher/get-dispatcher-me-loader";
192
- export { getDispatcherMeLoader as getDispatcherMeLoader } from "./data/services/logistics/dispatcher/get-dispatcher-me-loader";
193
192
  export { TextualAmountUpdater as TextualAmountUpdater } from "./components/common/TextualAmountUpdater";
194
193
  export { default as TextualIPOItemUpdater } from "./components/logistics/ipo/TextualIPOItemUpdater";
195
194
  export { default as TextualManageIPOForm } from "./components/logistics/ipo/TextualManageIPOForm";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "umwd-components",
3
- "version": "0.1.663",
3
+ "version": "0.1.664",
4
4
  "description": "UMWD Component library",
5
5
  "main": "dist/src/index.js",
6
6
  "module": "dist/src/index.js",
@@ -0,0 +1,115 @@
1
+ "use server";
2
+
3
+ import { getAuthToken } from "../../get-token";
4
+ import qs from "qs";
5
+ import { getStrapiURL } from "../../../../lib/utils";
6
+ import { unstable_noStore as noStore } from "next/cache";
7
+
8
+ const baseUrl = getStrapiURL();
9
+
10
+ const query = qs.stringify({
11
+ populate: {
12
+ enduser_profile: {
13
+ populate: {
14
+ company_address: true,
15
+ private_address: true,
16
+ business_credentials: {
17
+ populate: {
18
+ vat_validate_response: true,
19
+ eori_validate_response: true,
20
+ },
21
+ },
22
+ },
23
+ },
24
+ },
25
+ });
26
+
27
+ const roleQuery = qs.stringify({
28
+ populate: "role",
29
+ });
30
+
31
+ // used by profile page
32
+ export async function getExtendedEnduserMeLoader() {
33
+ noStore();
34
+ const url = new URL("/api/users/me", baseUrl);
35
+ url.search = query;
36
+
37
+ const authToken = await getAuthToken();
38
+ if (!authToken) return { ok: false, data: null, error: null };
39
+
40
+ try {
41
+ const response = await fetch(url.href, {
42
+ method: "GET",
43
+ headers: {
44
+ "Content-Type": "application/json",
45
+ Authorization: `Bearer ${authToken}`,
46
+ },
47
+ cache: "no-cache", // Ensure the response is not cached and revalidated on every render
48
+ });
49
+
50
+ // Check if the response status is not OK (i.e., not in the range 200-299)
51
+ if (!response.ok) throw new Error(`HTTP error! status: ${response.status}`);
52
+
53
+ const data = await response.json();
54
+
55
+ // Check if the data contains an error field
56
+ if (data.error) return { ok: false, data: null, error: data.error };
57
+
58
+ // If everything is fine, return the data
59
+ return { ok: true, data: data, error: null };
60
+ } catch (error) {
61
+ console.error("getExtendedEnduserMeLoader Error:", error);
62
+ return { ok: false, data: null, error: error };
63
+ }
64
+ }
65
+
66
+ /* export async function getEnduserMeLoader(token: string) {
67
+ const url = new URL("/api/users/me", baseUrl);
68
+ url.search = query;
69
+
70
+ try {
71
+ const response = await fetch(url, {
72
+ method: "GET",
73
+ headers: {
74
+ "Content-Type": "application/json",
75
+ Authorization: `Bearer ${token}`,
76
+ },
77
+ });
78
+ if (!response.ok) throw new Error(`HTTP error! status: ${response.status}`);
79
+
80
+ if (response.ok) {
81
+ return response.json();
82
+ } else {
83
+ throw new Error("Failed to fetch Enduser details");
84
+ }
85
+ } catch (error) {
86
+ console.error("getEnduserMeLoader Error:", error);
87
+ return null;
88
+ }
89
+ } */
90
+
91
+ /* export async function getUserRole() {
92
+ const url = new URL("/api/users/me", baseUrl);
93
+ url.search = roleQuery;
94
+
95
+ const authToken = await getAuthToken();
96
+ if (!authToken) return { ok: false, data: null, error: null };
97
+
98
+ try {
99
+ const response = await fetch(url.href, {
100
+ method: "GET",
101
+ headers: {
102
+ "Content-Type": "application/json",
103
+ Authorization: `Bearer ${authToken}`,
104
+ },
105
+ cache: "no-cache",
106
+ });
107
+ if (!response.ok) throw new Error(`HTTP error! status: ${response.status}`);
108
+ const data = await response.json();
109
+ if (data.error) return { ok: false, data: null, error: data.error };
110
+ return { ok: true, data: data, error: null };
111
+ } catch (error) {
112
+ console.error("getUserRole Error:", error);
113
+ return { ok: false, data: null, error: error };
114
+ }
115
+ } */
@@ -62,7 +62,7 @@ export async function getExtendedDispatcherMeLoader() {
62
62
  }
63
63
  }
64
64
 
65
- export async function getDispatcherMeLoader(token: string) {
65
+ /* export async function getDispatcherMeLoader(token: string) {
66
66
  const url = new URL("/api/users/me", baseUrl);
67
67
  url.search = query;
68
68
 
@@ -85,7 +85,7 @@ export async function getDispatcherMeLoader(token: string) {
85
85
  console.error("getDispatcherMeLoader Error:", error);
86
86
  return null;
87
87
  }
88
- }
88
+ } */
89
89
 
90
90
  /* export async function getUserRole() {
91
91
  const url = new URL("/api/users/me", baseUrl);
package/src/index.ts CHANGED
@@ -294,7 +294,7 @@ export { default as EnduserProfileDisplay } from "./components/e-commerce/enduse
294
294
 
295
295
  export { updateDispatcherProfileAction as updateDispatcherProfileAction } from "./data/actions/logistics/dispatcher/profile-actions";
296
296
  export { getExtendedDispatcherMeLoader as getExtendedDispatcherMeLoader } from "./data/services/logistics/dispatcher/get-dispatcher-me-loader";
297
- export { getDispatcherMeLoader as getDispatcherMeLoader } from "./data/services/logistics/dispatcher/get-dispatcher-me-loader";
297
+ // export { getDispatcherMeLoader as getDispatcherMeLoader } from "./data/services/logistics/dispatcher/get-dispatcher-me-loader";
298
298
 
299
299
  export { TextualAmountUpdater as TextualAmountUpdater } from "./components/common/TextualAmountUpdater";
300
300