@appcorp/stellar-solutions-invoice-module 0.1.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.
Files changed (76) hide show
  1. package/README.md +36 -0
  2. package/base-modules/invoice/actions.d.ts +134 -0
  3. package/base-modules/invoice/actions.js +29 -0
  4. package/base-modules/invoice/add-service-product-section.d.ts +2 -0
  5. package/base-modules/invoice/add-service-product-section.js +21 -0
  6. package/base-modules/invoice/calculate-subtotal.d.ts +2 -0
  7. package/base-modules/invoice/calculate-subtotal.js +20 -0
  8. package/base-modules/invoice/constants.d.ts +42 -0
  9. package/base-modules/invoice/constants.js +450 -0
  10. package/base-modules/invoice/context.d.ts +10 -0
  11. package/base-modules/invoice/context.js +661 -0
  12. package/base-modules/invoice/drawer.d.ts +8 -0
  13. package/base-modules/invoice/drawer.js +19 -0
  14. package/base-modules/invoice/form.d.ts +8 -0
  15. package/base-modules/invoice/form.js +67 -0
  16. package/base-modules/invoice/invoice.d.ts +10 -0
  17. package/base-modules/invoice/invoice.js +90 -0
  18. package/base-modules/invoice/pricing-form-elements.d.ts +3 -0
  19. package/base-modules/invoice/pricing-form-elements.js +41 -0
  20. package/base-modules/invoice/pricing-form-section.d.ts +2 -0
  21. package/base-modules/invoice/pricing-form-section.js +20 -0
  22. package/base-modules/invoice/products-form-elements.d.ts +4 -0
  23. package/base-modules/invoice/products-form-elements.js +41 -0
  24. package/base-modules/invoice/products-form-section.d.ts +2 -0
  25. package/base-modules/invoice/products-form-section.js +17 -0
  26. package/base-modules/invoice/reducer.d.ts +4 -0
  27. package/base-modules/invoice/reducer.js +138 -0
  28. package/base-modules/invoice/services-form-elements.d.ts +4 -0
  29. package/base-modules/invoice/services-form-elements.js +41 -0
  30. package/base-modules/invoice/services-form-section.d.ts +2 -0
  31. package/base-modules/invoice/services-form-section.js +17 -0
  32. package/base-modules/invoice/types.d.ts +163 -0
  33. package/base-modules/invoice/types.js +40 -0
  34. package/base-modules/invoice/validate.d.ts +36 -0
  35. package/base-modules/invoice/validate.js +17 -0
  36. package/base-modules/product/actions.d.ts +113 -0
  37. package/base-modules/product/actions.js +22 -0
  38. package/base-modules/product/constants.d.ts +33 -0
  39. package/base-modules/product/constants.js +204 -0
  40. package/base-modules/product/context.d.ts +10 -0
  41. package/base-modules/product/context.js +557 -0
  42. package/base-modules/product/drawer.d.ts +8 -0
  43. package/base-modules/product/drawer.js +19 -0
  44. package/base-modules/product/form-elements.d.ts +2 -0
  45. package/base-modules/product/form-elements.js +41 -0
  46. package/base-modules/product/form.d.ts +8 -0
  47. package/base-modules/product/form.js +107 -0
  48. package/base-modules/product/product.d.ts +10 -0
  49. package/base-modules/product/product.js +80 -0
  50. package/base-modules/product/reducer.d.ts +4 -0
  51. package/base-modules/product/reducer.js +88 -0
  52. package/base-modules/product/types.d.ts +87 -0
  53. package/base-modules/product/types.js +28 -0
  54. package/base-modules/product/validate.d.ts +36 -0
  55. package/base-modules/product/validate.js +17 -0
  56. package/base-modules/product-category/actions.d.ts +90 -0
  57. package/base-modules/product-category/actions.js +19 -0
  58. package/base-modules/product-category/constants.d.ts +28 -0
  59. package/base-modules/product-category/constants.js +74 -0
  60. package/base-modules/product-category/context.d.ts +10 -0
  61. package/base-modules/product-category/context.js +390 -0
  62. package/base-modules/product-category/drawer.d.ts +8 -0
  63. package/base-modules/product-category/drawer.js +19 -0
  64. package/base-modules/product-category/form-elements.d.ts +2 -0
  65. package/base-modules/product-category/form-elements.js +41 -0
  66. package/base-modules/product-category/form.d.ts +8 -0
  67. package/base-modules/product-category/form.js +81 -0
  68. package/base-modules/product-category/product-category.d.ts +10 -0
  69. package/base-modules/product-category/product-category.js +53 -0
  70. package/base-modules/product-category/reducer.d.ts +4 -0
  71. package/base-modules/product-category/reducer.js +73 -0
  72. package/base-modules/product-category/types.d.ts +59 -0
  73. package/base-modules/product-category/types.js +11 -0
  74. package/base-modules/product-category/validate.d.ts +12 -0
  75. package/base-modules/product-category/validate.js +11 -0
  76. package/package.json +60 -0
@@ -0,0 +1,163 @@
1
+ import { RowActionItem } from '@appcorp/app-corp-vista/type/vista-dropdown-menu-type';
2
+ import { VistaTableHeaderActionItem } from '@appcorp/app-corp-vista/type/vista-table-type';
3
+ import { VistaFormElements } from '@appcorp/app-corp-vista/type/vista-form-elements';
4
+ import { Dispatch } from 'react';
5
+ import { InvoiceActions } from './actions';
6
+ import { CompanyTypeBE } from '@appcorp/stellar-solutions-company-module/base-modules/company/types';
7
+ export interface InvoiceContextType {
8
+ byIdError?: Error;
9
+ byIdLoading: boolean;
10
+ clearSearch: () => void;
11
+ closeDrawer: () => void;
12
+ deleteError?: Error;
13
+ deleteLoading: boolean;
14
+ dispatch: Dispatch<InvoiceActions>;
15
+ dynamicFormElements: VistaFormElements;
16
+ dynamicPricingFormElements: VistaFormElements;
17
+ dynamicProductFormElements: VistaFormElements;
18
+ dynamicServiceFormElements: VistaFormElements;
19
+ handleChange: (field: string, value: string | number | number[]) => void;
20
+ handleNextClick: () => void;
21
+ handlePageLimit: (node: string, value: object) => void;
22
+ handlePreviousClick: () => void;
23
+ handleSubmit: () => void;
24
+ headerActions: VistaTableHeaderActionItem[];
25
+ listError?: Error;
26
+ listFetchNow: () => void;
27
+ listLoading: boolean;
28
+ rowActions: RowActionItem[];
29
+ searchOnChange: (k: string, v: string) => void;
30
+ updateError?: Error;
31
+ updateLoading: boolean;
32
+ }
33
+ export interface Product {
34
+ productId: string;
35
+ quantity: number;
36
+ price: string;
37
+ mode: 'Create' | 'Edit' | '';
38
+ rowTotal: string;
39
+ }
40
+ export interface Service {
41
+ id?: string;
42
+ name: string;
43
+ description: string;
44
+ quantity: string;
45
+ price: string;
46
+ mode: 'Create' | 'Edit' | '';
47
+ rowTotal: string;
48
+ }
49
+ export interface CustomerTypeBE {
50
+ address?: string;
51
+ city: string;
52
+ country: string;
53
+ createdAt: string;
54
+ email?: string;
55
+ firstName: string;
56
+ id: string;
57
+ invoices: InvoiceTypeBE[];
58
+ lastName: string;
59
+ phone: string;
60
+ updatedAt: string;
61
+ }
62
+ export declare enum PAYMENT_MODE {
63
+ }
64
+ export declare enum PAYMENT_TYPE {
65
+ }
66
+ export interface PaymentTypeBE {
67
+ amount: string;
68
+ attachment?: string;
69
+ balance: string;
70
+ createdAt: string;
71
+ currency: string;
72
+ date: string;
73
+ description?: string;
74
+ id: string;
75
+ mode: PAYMENT_MODE;
76
+ paymentType: PAYMENT_TYPE;
77
+ quoteInvoice: InvoiceTypeBE;
78
+ quoteInvoiceId: string;
79
+ ref?: string;
80
+ updatedAt: string;
81
+ }
82
+ export interface InvoiceTypeBE {
83
+ category: string;
84
+ company: CompanyTypeBE;
85
+ companyId: string;
86
+ createdAt: string;
87
+ currency: string;
88
+ currentPage: number;
89
+ customerId: string;
90
+ date: string;
91
+ discount: string;
92
+ discountUnit: string;
93
+ expiryDate: string;
94
+ id: string;
95
+ invoiceId: string;
96
+ invoiceStatus: string;
97
+ loading: boolean;
98
+ mode: 'Create' | 'Edit';
99
+ note: string;
100
+ payments: PaymentTypeBE[] | [];
101
+ products: Product[];
102
+ ref: string;
103
+ services: Service[];
104
+ subTotal: string;
105
+ taxValue: string;
106
+ total: string;
107
+ count: number;
108
+ updatedAt: string;
109
+ }
110
+ export interface InvoiceState extends Omit<InvoiceTypeBE, 'createdAt' | 'updatedAt'> {
111
+ count: number;
112
+ currentPage: number;
113
+ disableSaveButton: boolean;
114
+ drawer: null | INVOICE_DRAWER;
115
+ errors: {
116
+ [key: string]: string;
117
+ };
118
+ modal: null | PRODUCT_MODAL;
119
+ pageLimit: number;
120
+ invoices: InvoiceTypeBE[];
121
+ products: Product[];
122
+ searchQuery: string;
123
+ netTotal: string;
124
+ firstName: string;
125
+ lastName: string;
126
+ country: string;
127
+ phone: string;
128
+ email: string;
129
+ city: string;
130
+ address: string;
131
+ }
132
+ export interface FetchInvoicesArgs {
133
+ currentPage: number;
134
+ pageLimit: number;
135
+ searchQuery?: string;
136
+ }
137
+ export declare enum INVOICE_DRAWER {
138
+ INVOICE_COMPANY_FORM_DRAWER = "INVOICE_COMPANY_FORM_DRAWER",
139
+ INVOICE_CUSTOMER_FORM_DRAWER = "INVOICE_CUSTOMER_FORM_DRAWER"
140
+ }
141
+ export declare enum PRODUCT_MODAL {
142
+ DUMMY = "DUMMY"
143
+ }
144
+ export declare enum QUOTE_INVOICE {
145
+ QUOTE = "QUOTE",
146
+ INVOICE = "INVOICE"
147
+ }
148
+ export declare enum CURRENCY {
149
+ AUD = "AUD",
150
+ BHD = "BHD",
151
+ CAD = "CAD",
152
+ CNY = "CNY",
153
+ EUR = "EUR",
154
+ GBP = "GBP",
155
+ JOD = "JOD",
156
+ JPY = "JPY",
157
+ KWD = "KWD",
158
+ MYR = "MYR",
159
+ OMR = "OMR",
160
+ PKR = "PKR",
161
+ SAR = "SAR",
162
+ USD = "USD"
163
+ }
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CURRENCY = exports.QUOTE_INVOICE = exports.PRODUCT_MODAL = exports.INVOICE_DRAWER = exports.PAYMENT_TYPE = exports.PAYMENT_MODE = void 0;
4
+ var PAYMENT_MODE;
5
+ (function (PAYMENT_MODE) {
6
+ })(PAYMENT_MODE || (exports.PAYMENT_MODE = PAYMENT_MODE = {}));
7
+ var PAYMENT_TYPE;
8
+ (function (PAYMENT_TYPE) {
9
+ })(PAYMENT_TYPE || (exports.PAYMENT_TYPE = PAYMENT_TYPE = {}));
10
+ var INVOICE_DRAWER;
11
+ (function (INVOICE_DRAWER) {
12
+ INVOICE_DRAWER["INVOICE_COMPANY_FORM_DRAWER"] = "INVOICE_COMPANY_FORM_DRAWER";
13
+ INVOICE_DRAWER["INVOICE_CUSTOMER_FORM_DRAWER"] = "INVOICE_CUSTOMER_FORM_DRAWER";
14
+ })(INVOICE_DRAWER || (exports.INVOICE_DRAWER = INVOICE_DRAWER = {}));
15
+ var PRODUCT_MODAL;
16
+ (function (PRODUCT_MODAL) {
17
+ PRODUCT_MODAL["DUMMY"] = "DUMMY";
18
+ })(PRODUCT_MODAL || (exports.PRODUCT_MODAL = PRODUCT_MODAL = {}));
19
+ var QUOTE_INVOICE;
20
+ (function (QUOTE_INVOICE) {
21
+ QUOTE_INVOICE["QUOTE"] = "QUOTE";
22
+ QUOTE_INVOICE["INVOICE"] = "INVOICE";
23
+ })(QUOTE_INVOICE || (exports.QUOTE_INVOICE = QUOTE_INVOICE = {}));
24
+ var CURRENCY;
25
+ (function (CURRENCY) {
26
+ CURRENCY["AUD"] = "AUD";
27
+ CURRENCY["BHD"] = "BHD";
28
+ CURRENCY["CAD"] = "CAD";
29
+ CURRENCY["CNY"] = "CNY";
30
+ CURRENCY["EUR"] = "EUR";
31
+ CURRENCY["GBP"] = "GBP";
32
+ CURRENCY["JOD"] = "JOD";
33
+ CURRENCY["JPY"] = "JPY";
34
+ CURRENCY["KWD"] = "KWD";
35
+ CURRENCY["MYR"] = "MYR";
36
+ CURRENCY["OMR"] = "OMR";
37
+ CURRENCY["PKR"] = "PKR";
38
+ CURRENCY["SAR"] = "SAR";
39
+ CURRENCY["USD"] = "USD";
40
+ })(CURRENCY || (exports.CURRENCY = CURRENCY = {}));
@@ -0,0 +1,36 @@
1
+ import { z } from 'zod';
2
+ export declare const formValidation: z.ZodObject<{
3
+ buyPrice: z.ZodString;
4
+ currency: z.ZodString;
5
+ description: z.ZodOptional<z.ZodString>;
6
+ images: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
7
+ name: z.ZodString;
8
+ product: z.ZodOptional<z.ZodString>;
9
+ productCategoryId: z.ZodString;
10
+ quantity: z.ZodString;
11
+ ref: z.ZodOptional<z.ZodString>;
12
+ salePrice: z.ZodString;
13
+ }, "strip", z.ZodTypeAny, {
14
+ currency: string;
15
+ name: string;
16
+ quantity: string;
17
+ buyPrice: string;
18
+ productCategoryId: string;
19
+ salePrice: string;
20
+ ref?: string | undefined;
21
+ description?: string | undefined;
22
+ images?: string[] | undefined;
23
+ product?: string | undefined;
24
+ }, {
25
+ currency: string;
26
+ name: string;
27
+ quantity: string;
28
+ buyPrice: string;
29
+ productCategoryId: string;
30
+ salePrice: string;
31
+ ref?: string | undefined;
32
+ description?: string | undefined;
33
+ images?: string[] | undefined;
34
+ product?: string | undefined;
35
+ }>;
36
+ export type ProductCategoryFormValidate = z.infer<typeof formValidation>;
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.formValidation = void 0;
4
+ var zod_1 = require("zod");
5
+ var constants_1 = require("./constants");
6
+ exports.formValidation = zod_1.z.object({
7
+ buyPrice: zod_1.z.string(),
8
+ currency: zod_1.z.string().nonempty(constants_1.messages.currency),
9
+ description: zod_1.z.string().optional(),
10
+ images: zod_1.z.array(zod_1.z.string()).optional(),
11
+ name: zod_1.z.string().nonempty(constants_1.messages.name),
12
+ product: zod_1.z.string().optional(),
13
+ productCategoryId: zod_1.z.string().nonempty(constants_1.messages.productCategoryId),
14
+ quantity: zod_1.z.string(),
15
+ ref: zod_1.z.string().optional(),
16
+ salePrice: zod_1.z.string(),
17
+ });
@@ -0,0 +1,113 @@
1
+ import { ProductCategoryBE } from '@react-pakistan/util-functions/api/stellar-solutions/type';
2
+ import { PRODUCT_DRAWER, PRODUCT_MODAL, ProductTypeBE } from './types';
3
+ export declare enum PRODUCT_ACTION_TYPES {
4
+ CLEAR_ERRORS = "CLEAR_ERRORS",
5
+ RESET_FORM = "RESET_FORM",
6
+ SET_COUNT = "SET_COUNT",
7
+ SET_CURRENT_PAGE = "SET_CURRENT_PAGE",
8
+ SET_DISABLE_SAVE_BUTTON = "SET_DISABLE_SAVE_BUTTON",
9
+ SET_DRAWER = "SET_DRAWER",
10
+ SET_ERRORS = "SET_ERRORS",
11
+ SET_FORM = "SET_FORM",
12
+ SET_INPUT_FIELD = "SET_INPUT_FIELD",
13
+ SET_INPUT_IMAGES = "SET_INPUT_IMAGES",
14
+ SET_MODAL = "SET_MODAL",
15
+ SET_PAGE_LIMIT = "SET_PAGE_LIMIT",
16
+ SET_PRODUCTS = "SET_PRODUCTS",
17
+ SET_PRODUCT_CATEGORIES = "SET_PRODUCT_CATEGORIES",
18
+ SET_PRODUCT_CATEGORY_QUERY = "SET_PRODUCT_CATEGORY_QUERY",
19
+ SET_SEARCH_QUERY = "SET_SEARCH_QUERY"
20
+ }
21
+ export type ClearErrorAction = {
22
+ type: PRODUCT_ACTION_TYPES.CLEAR_ERRORS;
23
+ };
24
+ export type ResetFormAction = {
25
+ type: PRODUCT_ACTION_TYPES.RESET_FORM;
26
+ };
27
+ export type SetCountAction = {
28
+ type: PRODUCT_ACTION_TYPES.SET_COUNT;
29
+ payload: {
30
+ count: number;
31
+ };
32
+ };
33
+ export type SetDisableSaveButtonAction = {
34
+ type: PRODUCT_ACTION_TYPES.SET_DISABLE_SAVE_BUTTON;
35
+ payload: {
36
+ disableSaveButton: boolean;
37
+ };
38
+ };
39
+ export type SetCurrentPageAction = {
40
+ type: PRODUCT_ACTION_TYPES.SET_CURRENT_PAGE;
41
+ payload: {
42
+ currentPage: number;
43
+ };
44
+ };
45
+ export type SetErrorsAction = {
46
+ type: PRODUCT_ACTION_TYPES.SET_ERRORS;
47
+ payload: {
48
+ [key: string]: string;
49
+ };
50
+ };
51
+ export type SetInputFieldAction = {
52
+ type: PRODUCT_ACTION_TYPES.SET_INPUT_FIELD;
53
+ payload: {
54
+ key: keyof ProductTypeBE;
55
+ value: string | string[] | boolean | number | number[];
56
+ };
57
+ };
58
+ export type SetInputImagesAction = {
59
+ type: PRODUCT_ACTION_TYPES.SET_INPUT_IMAGES;
60
+ payload: {
61
+ key: keyof ProductTypeBE;
62
+ value: string[];
63
+ };
64
+ };
65
+ export type SetPageLimitAction = {
66
+ type: PRODUCT_ACTION_TYPES.SET_PAGE_LIMIT;
67
+ payload: {
68
+ pageLimit: number;
69
+ };
70
+ };
71
+ export type SetProductsAction = {
72
+ type: PRODUCT_ACTION_TYPES.SET_PRODUCTS;
73
+ payload: {
74
+ products: ProductTypeBE[];
75
+ };
76
+ };
77
+ export type SetSearchQueryAction = {
78
+ type: PRODUCT_ACTION_TYPES.SET_SEARCH_QUERY;
79
+ payload: {
80
+ searchQuery: string;
81
+ };
82
+ };
83
+ export type SetFormAction = {
84
+ type: PRODUCT_ACTION_TYPES.SET_FORM;
85
+ payload: {
86
+ form: ProductTypeBE;
87
+ };
88
+ };
89
+ export type SetDrawerAction = {
90
+ type: PRODUCT_ACTION_TYPES.SET_DRAWER;
91
+ payload: {
92
+ drawer: PRODUCT_DRAWER | null;
93
+ };
94
+ };
95
+ export type SetModalAction = {
96
+ type: PRODUCT_ACTION_TYPES.SET_MODAL;
97
+ payload: {
98
+ modal: PRODUCT_MODAL | null;
99
+ };
100
+ };
101
+ export type SetProductCategoryQueryAction = {
102
+ type: PRODUCT_ACTION_TYPES.SET_PRODUCT_CATEGORY_QUERY;
103
+ payload: {
104
+ productCategoryQuery: string;
105
+ };
106
+ };
107
+ export type SetProductCategoriesAction = {
108
+ type: PRODUCT_ACTION_TYPES.SET_PRODUCT_CATEGORIES;
109
+ payload: {
110
+ productCategories: ProductCategoryBE[];
111
+ };
112
+ };
113
+ export type ProductActions = SetInputFieldAction | ClearErrorAction | ResetFormAction | SetErrorsAction | SetCurrentPageAction | SetDisableSaveButtonAction | SetPageLimitAction | SetSearchQueryAction | SetProductsAction | SetCountAction | SetFormAction | SetDrawerAction | SetModalAction | SetInputImagesAction | SetProductCategoryQueryAction | SetProductCategoriesAction;
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PRODUCT_ACTION_TYPES = void 0;
4
+ var PRODUCT_ACTION_TYPES;
5
+ (function (PRODUCT_ACTION_TYPES) {
6
+ PRODUCT_ACTION_TYPES["CLEAR_ERRORS"] = "CLEAR_ERRORS";
7
+ PRODUCT_ACTION_TYPES["RESET_FORM"] = "RESET_FORM";
8
+ PRODUCT_ACTION_TYPES["SET_COUNT"] = "SET_COUNT";
9
+ PRODUCT_ACTION_TYPES["SET_CURRENT_PAGE"] = "SET_CURRENT_PAGE";
10
+ PRODUCT_ACTION_TYPES["SET_DISABLE_SAVE_BUTTON"] = "SET_DISABLE_SAVE_BUTTON";
11
+ PRODUCT_ACTION_TYPES["SET_DRAWER"] = "SET_DRAWER";
12
+ PRODUCT_ACTION_TYPES["SET_ERRORS"] = "SET_ERRORS";
13
+ PRODUCT_ACTION_TYPES["SET_FORM"] = "SET_FORM";
14
+ PRODUCT_ACTION_TYPES["SET_INPUT_FIELD"] = "SET_INPUT_FIELD";
15
+ PRODUCT_ACTION_TYPES["SET_INPUT_IMAGES"] = "SET_INPUT_IMAGES";
16
+ PRODUCT_ACTION_TYPES["SET_MODAL"] = "SET_MODAL";
17
+ PRODUCT_ACTION_TYPES["SET_PAGE_LIMIT"] = "SET_PAGE_LIMIT";
18
+ PRODUCT_ACTION_TYPES["SET_PRODUCTS"] = "SET_PRODUCTS";
19
+ PRODUCT_ACTION_TYPES["SET_PRODUCT_CATEGORIES"] = "SET_PRODUCT_CATEGORIES";
20
+ PRODUCT_ACTION_TYPES["SET_PRODUCT_CATEGORY_QUERY"] = "SET_PRODUCT_CATEGORY_QUERY";
21
+ PRODUCT_ACTION_TYPES["SET_SEARCH_QUERY"] = "SET_SEARCH_QUERY";
22
+ })(PRODUCT_ACTION_TYPES || (exports.PRODUCT_ACTION_TYPES = PRODUCT_ACTION_TYPES = {}));
@@ -0,0 +1,33 @@
1
+ import { VISTA_TABLE_CELL_TYPE } from '@appcorp/app-corp-vista/type/vista-table-type';
2
+ import { VistaFormElements } from '@appcorp/app-corp-vista/type/vista-form-elements';
3
+ export declare const pageLimit: number;
4
+ export declare const DEFAULT_RANGES: {
5
+ totalRange: number[];
6
+ };
7
+ export declare const formInfo: {
8
+ buyPrice: string;
9
+ salePrice: string;
10
+ };
11
+ export declare const staticFormElements: VistaFormElements;
12
+ export declare const PRODUCT_API_ROUTES: {
13
+ PRODUCTS: string;
14
+ PRODUCT: string;
15
+ PRODUCT_BY_ID: string;
16
+ };
17
+ export declare const tableBodyCols: ({
18
+ componentType: VISTA_TABLE_CELL_TYPE;
19
+ key: string;
20
+ } | {
21
+ componentType: VISTA_TABLE_CELL_TYPE;
22
+ key: string[];
23
+ })[];
24
+ export declare const messages: {
25
+ buyPrice: string;
26
+ currency: string;
27
+ error: string;
28
+ name: string;
29
+ productCategoryId: string;
30
+ quantity: string;
31
+ salePrice: string;
32
+ success: string;
33
+ };
@@ -0,0 +1,204 @@
1
+ 'use client';
2
+ "use strict";
3
+ var _a;
4
+ Object.defineProperty(exports, "__esModule", { value: true });
5
+ exports.messages = exports.tableBodyCols = exports.PRODUCT_API_ROUTES = exports.staticFormElements = exports.formInfo = exports.DEFAULT_RANGES = exports.pageLimit = void 0;
6
+ var form_schema_1 = require("@appcorp/app-corp-vista/utils/form-schema");
7
+ var vista_table_type_1 = require("@appcorp/app-corp-vista/type/vista-table-type");
8
+ exports.pageLimit = Number(process.env.NEXT_PUBLIC_PAGE_LIMIT);
9
+ exports.DEFAULT_RANGES = {
10
+ totalRange: [10, 3000],
11
+ };
12
+ exports.formInfo = {
13
+ buyPrice: 'The price incurred to manufacture or acquire the unit of this product.',
14
+ salePrice: 'The price at which this product is being sold in the market.'
15
+ };
16
+ exports.staticFormElements = (_a = {},
17
+ _a[form_schema_1.VISTA_FORM_ELEMENTS.TEXT_INPUT_V1] = [
18
+ {
19
+ enabled: true,
20
+ error: '',
21
+ handleOnChange: function () { return void 0; },
22
+ id: 'name',
23
+ label: 'formLabelName',
24
+ order: 1,
25
+ placeholder: 'Name goes here...',
26
+ required: true,
27
+ type: 'text',
28
+ value: '',
29
+ },
30
+ {
31
+ enabled: true,
32
+ error: '',
33
+ handleOnChange: function () { return void 0; },
34
+ id: 'buyPrice',
35
+ info: exports.formInfo.buyPrice,
36
+ label: 'formLabelBuyPrice',
37
+ order: 2,
38
+ placeholder: 'Buy Price goes here...',
39
+ required: true,
40
+ type: 'text',
41
+ value: '',
42
+ },
43
+ {
44
+ enabled: true,
45
+ error: '',
46
+ handleOnChange: function () { return void 0; },
47
+ id: 'salePrice',
48
+ info: exports.formInfo.salePrice,
49
+ label: 'formLabelSalePrice',
50
+ order: 3,
51
+ placeholder: 'Sale Price goes here...',
52
+ required: true,
53
+ type: 'text',
54
+ value: '',
55
+ },
56
+ {
57
+ enabled: true,
58
+ error: '',
59
+ handleOnChange: function () { return void 0; },
60
+ id: 'quantity',
61
+ label: 'formLabelQuantity',
62
+ order: 4,
63
+ placeholder: 'Quantity goes here...',
64
+ required: true,
65
+ type: 'text',
66
+ value: '',
67
+ },
68
+ {
69
+ enabled: true,
70
+ error: '',
71
+ handleOnChange: function () { return void 0; },
72
+ id: 'ref',
73
+ label: 'formLabelRef',
74
+ order: 6,
75
+ placeholder: 'Ref goes here...',
76
+ required: false,
77
+ type: 'text',
78
+ value: '',
79
+ },
80
+ ],
81
+ _a[form_schema_1.VISTA_FORM_ELEMENTS.TEXT_AREA_V1] = [
82
+ {
83
+ enabled: true,
84
+ error: '',
85
+ handleOnChange: function () { return void 0; },
86
+ id: 'description',
87
+ label: 'formLabelDescription',
88
+ order: 7,
89
+ placeholder: 'Description goes here...',
90
+ required: false,
91
+ value: '',
92
+ },
93
+ ],
94
+ _a[form_schema_1.VISTA_FORM_ELEMENTS.SELECT_V1] = [
95
+ {
96
+ enabled: true,
97
+ handleOnChange: function () { return void 0; },
98
+ label: 'formLabelCurrency',
99
+ listItems: [{ id: 'currency-1', option: 'PKR' }, { id: 'currency-2', option: 'CAD' }],
100
+ nodeSelectKey: 'currency',
101
+ order: 5,
102
+ required: true,
103
+ selectKey1: 'option',
104
+ selectedItem: { option: 'PKR' },
105
+ },
106
+ ],
107
+ _a[form_schema_1.VISTA_FORM_ELEMENTS.DIVIDER_V4] = [
108
+ {
109
+ enabled: true,
110
+ label: 'Relationship',
111
+ order: 9,
112
+ }
113
+ ],
114
+ _a[form_schema_1.VISTA_FORM_ELEMENTS.UPLOAD_V1] = [
115
+ {
116
+ disabled: false,
117
+ enabled: true,
118
+ fileInfo: 'JPG, PNG, WEBP - 1MB max',
119
+ handleClearImage: function () { return void 0; },
120
+ handleOnChange: function () { return void 0; },
121
+ id: 'attachments',
122
+ imageUrls: [],
123
+ label: 'formLabelImage',
124
+ multiple: true,
125
+ order: 8,
126
+ required: false,
127
+ type: 'file',
128
+ },
129
+ ],
130
+ _a[form_schema_1.VISTA_FORM_ELEMENTS.COMBOBOX_V1] = [
131
+ {
132
+ disabled: false,
133
+ enabled: true,
134
+ handleInputOnChange: function () { return void 0; },
135
+ handleOnBlur: function () { return void 0; },
136
+ handleOnChange: function () { return void 0; },
137
+ label: 'formLabelProductCategory',
138
+ listItems: [{ id: 'category-1', option: 'Category1' }, { id: 'category-2', option: 'Category2' }],
139
+ nodeQueryKey: '',
140
+ nodeSelectKey: 'productCategoryId',
141
+ order: 11,
142
+ query: '',
143
+ selectKey1: 'option',
144
+ selectedItem: { id: 'category-2' },
145
+ },
146
+ ],
147
+ _a);
148
+ exports.PRODUCT_API_ROUTES = {
149
+ PRODUCTS: '/api/products',
150
+ PRODUCT: '/api/product',
151
+ PRODUCT_BY_ID: '/api/product/product-by-id',
152
+ };
153
+ exports.tableBodyCols = [
154
+ {
155
+ componentType: vista_table_type_1.VISTA_TABLE_CELL_TYPE.ID,
156
+ key: 'id',
157
+ },
158
+ {
159
+ componentType: vista_table_type_1.VISTA_TABLE_CELL_TYPE.BOLD_TEXT,
160
+ key: 'name',
161
+ },
162
+ {
163
+ componentType: vista_table_type_1.VISTA_TABLE_CELL_TYPE.TEXT,
164
+ key: 'description',
165
+ },
166
+ {
167
+ componentType: vista_table_type_1.VISTA_TABLE_CELL_TYPE.TEXT,
168
+ key: 'currency',
169
+ },
170
+ {
171
+ componentType: vista_table_type_1.VISTA_TABLE_CELL_TYPE.TEXT,
172
+ key: 'salePrice',
173
+ },
174
+ {
175
+ componentType: vista_table_type_1.VISTA_TABLE_CELL_TYPE.TEXT,
176
+ key: 'buyPrice',
177
+ },
178
+ {
179
+ componentType: vista_table_type_1.VISTA_TABLE_CELL_TYPE.OBJECT,
180
+ key: ['productCategory', 'name'],
181
+ },
182
+ {
183
+ componentType: vista_table_type_1.VISTA_TABLE_CELL_TYPE.TEXT,
184
+ key: 'ref',
185
+ },
186
+ {
187
+ componentType: vista_table_type_1.VISTA_TABLE_CELL_TYPE.TEXT,
188
+ key: 'quantity',
189
+ },
190
+ {
191
+ componentType: vista_table_type_1.VISTA_TABLE_CELL_TYPE.ACTIONS,
192
+ key: 'action',
193
+ },
194
+ ];
195
+ exports.messages = {
196
+ buyPrice: 'Buy Price should be more than 1 unit',
197
+ currency: 'Please select a currency unit for this product',
198
+ error: 'Error occurred, please try again',
199
+ name: 'Product category name is required',
200
+ productCategoryId: 'Product Category Id is required',
201
+ quantity: 'Quantity should be more than 1 unit',
202
+ salePrice: 'Sale Price should be more than 1 unit',
203
+ success: 'Operation successful!',
204
+ };
@@ -0,0 +1,10 @@
1
+ import React, { FC, ReactNode } from 'react';
2
+ import { ProductContextType, ProductState } from './types';
3
+ type State = ProductContextType & ProductState;
4
+ interface StateProviderProps {
5
+ children: ReactNode;
6
+ }
7
+ export declare const ProductStateContext: React.Context<State>;
8
+ export declare const ProductStateContextProvider: FC<StateProviderProps>;
9
+ export declare const useProductStateContext: () => State;
10
+ export {};