umwd-components 0.1.712 → 0.1.714

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.
@@ -2,8 +2,7 @@
2
2
  * INFO Fetch all Invoices
3
3
  * used by the Invoices table in the admin panel
4
4
  */
5
- declare function getAllInvoices(currentPage: number, rowsPerPage: number, order: "asc" | "desc", orderBy: string, is_archive?: boolean[], // default to only non-archived OPOs
6
- filters?: {
5
+ declare function getAllInvoices(currentPage: number, rowsPerPage: number, order: "asc" | "desc", orderBy: string, filters?: {
7
6
  [key: string]: string;
8
7
  }): Promise<any>;
9
8
  export { getAllInvoices };
@@ -1,6 +1,14 @@
1
1
  /**
2
2
  * INFO Fetch all IPOs
3
3
  * used by the IPOs table in the admin panel
4
+ * @param currentPage - The current page number for pagination
5
+ * @param rowsPerPage - The number of rows per page for pagination
6
+ * @param order - The order direction, either "asc" or "desc"
7
+ * @param orderBy - The field to order by, defaults to "id"
8
+ * @param is_archive - An array of booleans to filter by archived status, defaulting to only non-archived IPOs
9
+ * @param filters - An object containing additional filters to apply
10
+ * @return A promise that resolves to the fetched IPO data
11
+ * * @throws Will throw an error if the fetch fails
4
12
  */
5
13
  declare function getTableIpos(currentPage: number, rowsPerPage: number, order: "asc" | "desc", orderBy: string, is_archive?: boolean[], // default to only non-archived OPOs
6
14
  filters?: {
@@ -1 +1,14 @@
1
- export declare function getTableVendors(currentPage: number, rowsPerPage: number, order: "asc" | "desc", orderBy: string): Promise<any>;
1
+ /**
2
+ * INFO Fetch all vendors
3
+ * used by the Vendors table in the admin panel
4
+ * @param currentPage - The current page number for pagination
5
+ * @param rowsPerPage - The number of rows per page for pagination
6
+ * @param order - The order direction, either "asc" or "desc"
7
+ * @param orderBy - The field to order by, defaults to "id"
8
+ * @return A promise that resolves to the fetched vendor data
9
+ * @throws Will throw an error if the fetch fails
10
+ * */
11
+ declare function getTableVendors(currentPage: number, rowsPerPage: number, order: "asc" | "desc", orderBy: string, filters?: {
12
+ [key: string]: string;
13
+ }): Promise<any>;
14
+ export { getTableVendors };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "umwd-components",
3
- "version": "0.1.712",
3
+ "version": "0.1.714",
4
4
  "description": "UMWD Component library",
5
5
  "main": "dist/src/index.js",
6
6
  "module": "dist/src/index.js",
@@ -17,7 +17,7 @@ async function getAllInvoices(
17
17
  rowsPerPage: number,
18
18
  order: "asc" | "desc",
19
19
  orderBy: string,
20
- is_archive: boolean[] = [false], // default to only non-archived OPOs
20
+ // is_archive: boolean[] = [false], // default to only non-archived OPOs
21
21
  filters: { [key: string]: string } = {}
22
22
  ) {
23
23
  noStore();
@@ -12,7 +12,16 @@ const baseUrl = getStrapiURL();
12
12
  /**
13
13
  * INFO Fetch all IPOs
14
14
  * used by the IPOs table in the admin panel
15
+ * @param currentPage - The current page number for pagination
16
+ * @param rowsPerPage - The number of rows per page for pagination
17
+ * @param order - The order direction, either "asc" or "desc"
18
+ * @param orderBy - The field to order by, defaults to "id"
19
+ * @param is_archive - An array of booleans to filter by archived status, defaulting to only non-archived IPOs
20
+ * @param filters - An object containing additional filters to apply
21
+ * @return A promise that resolves to the fetched IPO data
22
+ * * @throws Will throw an error if the fetch fails
15
23
  */
24
+
16
25
  async function getTableIpos(
17
26
  currentPage: number,
18
27
  rowsPerPage: number,
@@ -23,10 +32,6 @@ async function getTableIpos(
23
32
  ) {
24
33
  noStore();
25
34
 
26
- const user = await getUserRole();
27
- const role = user?.data?.role?.type;
28
- const isEnduser = role === "enduser";
29
-
30
35
  const url = new URL(`/api/ipos`, baseUrl);
31
36
 
32
37
  const processedFilters = processFilters(filters);
@@ -4,23 +4,41 @@ import qs from "qs";
4
4
  import { fetchData } from "../loaders";
5
5
  import { getStrapiURL } from "../../../lib/utils";
6
6
  import { unstable_noStore as noStore } from "next/cache";
7
-
8
- // this is the get all product function for the backend, it should be universal so it also works on the frontend
9
- // this function is based on get all orders which the frontenduser uses to get all orders in it's order table
7
+ import { processFilters } from "../../../lib/processFilters";
10
8
 
11
9
  const baseUrl = getStrapiURL();
12
10
 
13
- export async function getTableVendors(
11
+ /**
12
+ * INFO Fetch all vendors
13
+ * used by the Vendors table in the admin panel
14
+ * @param currentPage - The current page number for pagination
15
+ * @param rowsPerPage - The number of rows per page for pagination
16
+ * @param order - The order direction, either "asc" or "desc"
17
+ * @param orderBy - The field to order by, defaults to "id"
18
+ * @return A promise that resolves to the fetched vendor data
19
+ * @throws Will throw an error if the fetch fails
20
+ * */
21
+ async function getTableVendors(
14
22
  currentPage: number,
15
23
  rowsPerPage: number,
16
24
  order: "asc" | "desc",
17
- orderBy: string
25
+ orderBy: string,
26
+ // is_archive: boolean[] = [false], // default to only non-archived OPOs
27
+ filters: { [key: string]: string } = {}
18
28
  ) {
19
29
  noStore();
20
30
 
21
31
  const url = new URL(`/api/vendor-profiles`, baseUrl);
22
32
 
33
+ const processedFilters = processFilters(filters);
34
+
23
35
  url.search = qs.stringify({
36
+ filters: {
37
+ // is_archive: {
38
+ // $in: is_archive,
39
+ // },
40
+ ...processedFilters,
41
+ },
24
42
  sort: `${orderBy || "id"}:${order || "desc"}`,
25
43
  populate: {
26
44
  business_credentials: true,
@@ -33,3 +51,5 @@ export async function getTableVendors(
33
51
 
34
52
  return await fetchData(url.href);
35
53
  }
54
+
55
+ export { getTableVendors };