@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.
- package/README.md +36 -0
- package/base-modules/invoice/actions.d.ts +134 -0
- package/base-modules/invoice/actions.js +29 -0
- package/base-modules/invoice/add-service-product-section.d.ts +2 -0
- package/base-modules/invoice/add-service-product-section.js +21 -0
- package/base-modules/invoice/calculate-subtotal.d.ts +2 -0
- package/base-modules/invoice/calculate-subtotal.js +20 -0
- package/base-modules/invoice/constants.d.ts +42 -0
- package/base-modules/invoice/constants.js +450 -0
- package/base-modules/invoice/context.d.ts +10 -0
- package/base-modules/invoice/context.js +661 -0
- package/base-modules/invoice/drawer.d.ts +8 -0
- package/base-modules/invoice/drawer.js +19 -0
- package/base-modules/invoice/form.d.ts +8 -0
- package/base-modules/invoice/form.js +67 -0
- package/base-modules/invoice/invoice.d.ts +10 -0
- package/base-modules/invoice/invoice.js +90 -0
- package/base-modules/invoice/pricing-form-elements.d.ts +3 -0
- package/base-modules/invoice/pricing-form-elements.js +41 -0
- package/base-modules/invoice/pricing-form-section.d.ts +2 -0
- package/base-modules/invoice/pricing-form-section.js +20 -0
- package/base-modules/invoice/products-form-elements.d.ts +4 -0
- package/base-modules/invoice/products-form-elements.js +41 -0
- package/base-modules/invoice/products-form-section.d.ts +2 -0
- package/base-modules/invoice/products-form-section.js +17 -0
- package/base-modules/invoice/reducer.d.ts +4 -0
- package/base-modules/invoice/reducer.js +138 -0
- package/base-modules/invoice/services-form-elements.d.ts +4 -0
- package/base-modules/invoice/services-form-elements.js +41 -0
- package/base-modules/invoice/services-form-section.d.ts +2 -0
- package/base-modules/invoice/services-form-section.js +17 -0
- package/base-modules/invoice/types.d.ts +163 -0
- package/base-modules/invoice/types.js +40 -0
- package/base-modules/invoice/validate.d.ts +36 -0
- package/base-modules/invoice/validate.js +17 -0
- package/base-modules/product/actions.d.ts +113 -0
- package/base-modules/product/actions.js +22 -0
- package/base-modules/product/constants.d.ts +33 -0
- package/base-modules/product/constants.js +204 -0
- package/base-modules/product/context.d.ts +10 -0
- package/base-modules/product/context.js +557 -0
- package/base-modules/product/drawer.d.ts +8 -0
- package/base-modules/product/drawer.js +19 -0
- package/base-modules/product/form-elements.d.ts +2 -0
- package/base-modules/product/form-elements.js +41 -0
- package/base-modules/product/form.d.ts +8 -0
- package/base-modules/product/form.js +107 -0
- package/base-modules/product/product.d.ts +10 -0
- package/base-modules/product/product.js +80 -0
- package/base-modules/product/reducer.d.ts +4 -0
- package/base-modules/product/reducer.js +88 -0
- package/base-modules/product/types.d.ts +87 -0
- package/base-modules/product/types.js +28 -0
- package/base-modules/product/validate.d.ts +36 -0
- package/base-modules/product/validate.js +17 -0
- package/base-modules/product-category/actions.d.ts +90 -0
- package/base-modules/product-category/actions.js +19 -0
- package/base-modules/product-category/constants.d.ts +28 -0
- package/base-modules/product-category/constants.js +74 -0
- package/base-modules/product-category/context.d.ts +10 -0
- package/base-modules/product-category/context.js +390 -0
- package/base-modules/product-category/drawer.d.ts +8 -0
- package/base-modules/product-category/drawer.js +19 -0
- package/base-modules/product-category/form-elements.d.ts +2 -0
- package/base-modules/product-category/form-elements.js +41 -0
- package/base-modules/product-category/form.d.ts +8 -0
- package/base-modules/product-category/form.js +81 -0
- package/base-modules/product-category/product-category.d.ts +10 -0
- package/base-modules/product-category/product-category.js +53 -0
- package/base-modules/product-category/reducer.d.ts +4 -0
- package/base-modules/product-category/reducer.js +73 -0
- package/base-modules/product-category/types.d.ts +59 -0
- package/base-modules/product-category/types.js +11 -0
- package/base-modules/product-category/validate.d.ts +12 -0
- package/base-modules/product-category/validate.js +11 -0
- package/package.json +60 -0
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
13
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
14
|
+
if (k2 === undefined) k2 = k;
|
|
15
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
16
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
17
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
18
|
+
}
|
|
19
|
+
Object.defineProperty(o, k2, desc);
|
|
20
|
+
}) : (function(o, m, k, k2) {
|
|
21
|
+
if (k2 === undefined) k2 = k;
|
|
22
|
+
o[k2] = m[k];
|
|
23
|
+
}));
|
|
24
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
25
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
26
|
+
}) : function(o, v) {
|
|
27
|
+
o["default"] = v;
|
|
28
|
+
});
|
|
29
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
30
|
+
var ownKeys = function(o) {
|
|
31
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
32
|
+
var ar = [];
|
|
33
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
34
|
+
return ar;
|
|
35
|
+
};
|
|
36
|
+
return ownKeys(o);
|
|
37
|
+
};
|
|
38
|
+
return function (mod) {
|
|
39
|
+
if (mod && mod.__esModule) return mod;
|
|
40
|
+
var result = {};
|
|
41
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
42
|
+
__setModuleDefault(result, mod);
|
|
43
|
+
return result;
|
|
44
|
+
};
|
|
45
|
+
})();
|
|
46
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
47
|
+
exports.ProductForm = void 0;
|
|
48
|
+
var react_1 = __importStar(require("react"));
|
|
49
|
+
var form_schema_1 = require("@appcorp/app-corp-vista/utils/form-schema");
|
|
50
|
+
var context_1 = require("./context");
|
|
51
|
+
var form_elements_1 = require("./form-elements");
|
|
52
|
+
var ProductForm = function (_a) {
|
|
53
|
+
var translationMap = _a.translationMap;
|
|
54
|
+
var dynamicFormElements = (0, context_1.useProductStateContext)().dynamicFormElements;
|
|
55
|
+
var updated = (0, react_1.useMemo)(function () {
|
|
56
|
+
var _a, _b, _c, _d, _e;
|
|
57
|
+
var elements = __assign({}, dynamicFormElements);
|
|
58
|
+
var textInputElements = (_a = elements[form_schema_1.VISTA_FORM_ELEMENTS.TEXT_INPUT_V1]) === null || _a === void 0 ? void 0 : _a.sort(function (a, b) { return a.order - b.order; });
|
|
59
|
+
if (textInputElements) {
|
|
60
|
+
textInputElements === null || textInputElements === void 0 ? void 0 : textInputElements.forEach(function (_a, i) {
|
|
61
|
+
var label = _a.label;
|
|
62
|
+
if (translationMap[label] === undefined)
|
|
63
|
+
return label;
|
|
64
|
+
textInputElements[i].label = translationMap[label];
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
var textAreaElements = (_b = elements[form_schema_1.VISTA_FORM_ELEMENTS.TEXT_AREA_V1]) === null || _b === void 0 ? void 0 : _b.sort(function (a, b) { return a.order - b.order; });
|
|
68
|
+
if (textAreaElements) {
|
|
69
|
+
textAreaElements === null || textAreaElements === void 0 ? void 0 : textAreaElements.forEach(function (_a, i) {
|
|
70
|
+
var label = _a.label;
|
|
71
|
+
if (translationMap[label] === undefined)
|
|
72
|
+
return label;
|
|
73
|
+
textAreaElements[i].label = translationMap[label];
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
var selectElements = (_c = elements[form_schema_1.VISTA_FORM_ELEMENTS.SELECT_V1]) === null || _c === void 0 ? void 0 : _c.sort(function (a, b) { return a.order - b.order; });
|
|
77
|
+
if (selectElements) {
|
|
78
|
+
selectElements === null || selectElements === void 0 ? void 0 : selectElements.forEach(function (_a, i) {
|
|
79
|
+
var label = _a.label;
|
|
80
|
+
if (translationMap[label] === undefined)
|
|
81
|
+
return label;
|
|
82
|
+
selectElements[i].label = translationMap[label];
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
var comboboxElements = (_d = elements[form_schema_1.VISTA_FORM_ELEMENTS.COMBOBOX_V1]) === null || _d === void 0 ? void 0 : _d.sort(function (a, b) { return a.order - b.order; });
|
|
86
|
+
if (comboboxElements) {
|
|
87
|
+
comboboxElements === null || comboboxElements === void 0 ? void 0 : comboboxElements.forEach(function (_a, i) {
|
|
88
|
+
var label = _a.label;
|
|
89
|
+
if (translationMap[label] === undefined)
|
|
90
|
+
return label;
|
|
91
|
+
comboboxElements[i].label = translationMap[label];
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
var uploadElements = (_e = elements[form_schema_1.VISTA_FORM_ELEMENTS.UPLOAD_V1]) === null || _e === void 0 ? void 0 : _e.sort(function (a, b) { return a.order - b.order; });
|
|
95
|
+
if (uploadElements) {
|
|
96
|
+
uploadElements === null || uploadElements === void 0 ? void 0 : uploadElements.forEach(function (_a, i) {
|
|
97
|
+
var label = _a.label;
|
|
98
|
+
if (translationMap[label] === undefined)
|
|
99
|
+
return label;
|
|
100
|
+
uploadElements[i].label = translationMap[label];
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
return elements;
|
|
104
|
+
}, [dynamicFormElements, translationMap]);
|
|
105
|
+
return react_1.default.createElement(react_1.default.Fragment, null, (0, form_elements_1.renderProductFormElements)(updated));
|
|
106
|
+
};
|
|
107
|
+
exports.ProductForm = ProductForm;
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
"use strict";
|
|
3
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
4
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
5
|
+
};
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.ProductPage = void 0;
|
|
8
|
+
var vista_table_v1_1 = require("@appcorp/app-corp-vista/organisms/vista-table-v1/vista-table-v1");
|
|
9
|
+
var react_1 = __importDefault(require("react"));
|
|
10
|
+
var next_intl_1 = require("next-intl");
|
|
11
|
+
var util_functions_1 = require("@react-pakistan/util-functions");
|
|
12
|
+
var context_1 = require("./context");
|
|
13
|
+
var constants_1 = require("./constants");
|
|
14
|
+
var drawer_1 = require("./drawer");
|
|
15
|
+
var generate_toast_1 = require("@appcorp/app-corp-vista/utils/generate-toast");
|
|
16
|
+
require("slick-carousel/slick/slick.css");
|
|
17
|
+
require("slick-carousel/slick/slick-theme.css");
|
|
18
|
+
var ProductPage = function () {
|
|
19
|
+
var _a = (0, context_1.useProductStateContext)(), count = _a.count, currentPage = _a.currentPage, handleNextClick = _a.handleNextClick, handlePageLimit = _a.handlePageLimit, handlePreviousClick = _a.handlePreviousClick, headerActions = _a.headerActions, listLoading = _a.listLoading, pageLimit = _a.pageLimit, products = _a.products, rowActions = _a.rowActions, searchOnChange = _a.searchOnChange, searchQuery = _a.searchQuery;
|
|
20
|
+
var t = (0, next_intl_1.useTranslations)('productPage');
|
|
21
|
+
var translationMap = {
|
|
22
|
+
formLabelName: t('formLabelName'),
|
|
23
|
+
formLabelBuyPrice: t('formLabelBuyPrice'),
|
|
24
|
+
formLabelDescription: t('formLabelDescription'),
|
|
25
|
+
formLabelQuantity: t('formLabelQuantity'),
|
|
26
|
+
formLabelSalePrice: t('formLabelSalePrice'),
|
|
27
|
+
formLabelRef: t('formLabelRef'),
|
|
28
|
+
formLabelCurrency: t('formLabelCurrency'),
|
|
29
|
+
formLabelImage: t('formLabelImage'),
|
|
30
|
+
formLabelProductCategory: t('formLabelProductCategory'),
|
|
31
|
+
};
|
|
32
|
+
var tableHeadItems = [
|
|
33
|
+
{
|
|
34
|
+
label: t('tableColumnHeaderId'),
|
|
35
|
+
width: '5%',
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
label: t('tableColumnHeaderName'),
|
|
39
|
+
width: '20%',
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
label: t('tableColumnHeaderDescription'),
|
|
43
|
+
width: '15%',
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
label: t('formLabelCurrency'),
|
|
47
|
+
width: '5%',
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
label: t('tableColumnHeaderSalePrice'),
|
|
51
|
+
width: '10%',
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
label: t('tableColumnHeaderBuyPrice'),
|
|
55
|
+
width: '10%',
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
label: t('tableColumnHeaderProductCategory'),
|
|
59
|
+
width: '10%',
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
label: t('tableColumnHeaderRef'),
|
|
63
|
+
width: '10%',
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
label: t('tableColumnHeaderQuantity'),
|
|
67
|
+
width: '5%',
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
label: t('tableColumnHeaderActions'),
|
|
71
|
+
width: '5%',
|
|
72
|
+
},
|
|
73
|
+
];
|
|
74
|
+
var totalPages = (0, util_functions_1.calculatePages)(count, pageLimit);
|
|
75
|
+
return (react_1.default.createElement(react_1.default.Fragment, null,
|
|
76
|
+
react_1.default.createElement(vista_table_v1_1.VistaTableV1, { currentPage: Number(currentPage), handleNextOnClick: handleNextClick, handleOnSelect: handlePageLimit, handlePreviousOnClick: handlePreviousClick, handleSearchInput: searchOnChange, headerActions: headerActions, isNextDisabled: (0, util_functions_1.isNextButtonDisabled)(currentPage, totalPages), isPreviousDisabled: (0, util_functions_1.isPreviousButtonDisabled)(currentPage), listOptions: (0, util_functions_1.getAvailablePageLimits)(count), loading: listLoading, nodeSelectKey: "pageLimit", pageLimit: pageLimit, rowActions: rowActions, searchDisabled: false, searchEnabled: true, searchId: "product-search", searchPlaceholder: t('tableHeaderSearchPlaceholder'), searchValue: searchQuery, selectKey1: "option", selectedItem: { option: String(pageLimit) }, tableBodyCols: constants_1.tableBodyCols, tableBodyRows: products, tableDescription: t('tableDescription'), tableHeadItems: tableHeadItems, tableHeading: t('tableTitle'), totalPages: Number(totalPages) }),
|
|
77
|
+
react_1.default.createElement(drawer_1.Drawer, { translationMap: translationMap }),
|
|
78
|
+
react_1.default.createElement(generate_toast_1.VistaToaster, null)));
|
|
79
|
+
};
|
|
80
|
+
exports.ProductPage = ProductPage;
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
13
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
14
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
15
|
+
if (ar || !(i in from)) {
|
|
16
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
17
|
+
ar[i] = from[i];
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
21
|
+
};
|
|
22
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
23
|
+
exports.initialProductState = void 0;
|
|
24
|
+
exports.productReducer = productReducer;
|
|
25
|
+
var actions_1 = require("./actions");
|
|
26
|
+
var constants_1 = require("./constants");
|
|
27
|
+
exports.initialProductState = {
|
|
28
|
+
buyPrice: '',
|
|
29
|
+
count: 0,
|
|
30
|
+
currency: 'PKR',
|
|
31
|
+
currentPage: 1,
|
|
32
|
+
description: '',
|
|
33
|
+
disableSaveButton: true,
|
|
34
|
+
drawer: null,
|
|
35
|
+
errors: {},
|
|
36
|
+
id: '',
|
|
37
|
+
images: [],
|
|
38
|
+
modal: null,
|
|
39
|
+
name: '',
|
|
40
|
+
pageLimit: constants_1.pageLimit,
|
|
41
|
+
productCategories: [],
|
|
42
|
+
productCategoryId: '',
|
|
43
|
+
productCategoryQuery: '',
|
|
44
|
+
products: [],
|
|
45
|
+
quantity: '1',
|
|
46
|
+
ref: '',
|
|
47
|
+
salePrice: '',
|
|
48
|
+
searchQuery: '',
|
|
49
|
+
};
|
|
50
|
+
function productReducer(state, action) {
|
|
51
|
+
var _a, _b;
|
|
52
|
+
switch (action.type) {
|
|
53
|
+
case actions_1.PRODUCT_ACTION_TYPES.CLEAR_ERRORS:
|
|
54
|
+
return __assign(__assign({}, state), { errors: {} });
|
|
55
|
+
case actions_1.PRODUCT_ACTION_TYPES.RESET_FORM:
|
|
56
|
+
return __assign(__assign({}, state), { description: '', disableSaveButton: false, errors: {}, name: '' });
|
|
57
|
+
case actions_1.PRODUCT_ACTION_TYPES.SET_DISABLE_SAVE_BUTTON:
|
|
58
|
+
return __assign(__assign({}, state), { disableSaveButton: action.payload.disableSaveButton });
|
|
59
|
+
case actions_1.PRODUCT_ACTION_TYPES.SET_CURRENT_PAGE:
|
|
60
|
+
return __assign(__assign({}, state), { currentPage: action.payload.currentPage });
|
|
61
|
+
case actions_1.PRODUCT_ACTION_TYPES.SET_COUNT:
|
|
62
|
+
return __assign(__assign({}, state), { count: action.payload.count });
|
|
63
|
+
case actions_1.PRODUCT_ACTION_TYPES.SET_ERRORS:
|
|
64
|
+
return __assign(__assign({}, state), { disableSaveButton: false, errors: __assign({}, action.payload) });
|
|
65
|
+
case actions_1.PRODUCT_ACTION_TYPES.SET_INPUT_FIELD:
|
|
66
|
+
return __assign(__assign({}, state), (_a = {}, _a[action.payload.key] = action.payload.value, _a));
|
|
67
|
+
case actions_1.PRODUCT_ACTION_TYPES.SET_INPUT_IMAGES:
|
|
68
|
+
return __assign(__assign({}, state), (_b = {}, _b[action.payload.key] = __spreadArray([], action.payload.value, true), _b));
|
|
69
|
+
case actions_1.PRODUCT_ACTION_TYPES.SET_PAGE_LIMIT:
|
|
70
|
+
return __assign(__assign({}, state), { pageLimit: action.payload.pageLimit });
|
|
71
|
+
case actions_1.PRODUCT_ACTION_TYPES.SET_PRODUCTS:
|
|
72
|
+
return __assign(__assign({}, state), { products: __spreadArray([], action.payload.products, true) });
|
|
73
|
+
case actions_1.PRODUCT_ACTION_TYPES.SET_SEARCH_QUERY:
|
|
74
|
+
return __assign(__assign({}, state), { searchQuery: action.payload.searchQuery });
|
|
75
|
+
case actions_1.PRODUCT_ACTION_TYPES.SET_FORM:
|
|
76
|
+
return __assign(__assign({}, state), action.payload.form);
|
|
77
|
+
case actions_1.PRODUCT_ACTION_TYPES.SET_DRAWER:
|
|
78
|
+
return __assign(__assign({}, state), { drawer: action.payload.drawer });
|
|
79
|
+
case actions_1.PRODUCT_ACTION_TYPES.SET_MODAL:
|
|
80
|
+
return __assign(__assign({}, state), { modal: action.payload.modal });
|
|
81
|
+
case actions_1.PRODUCT_ACTION_TYPES.SET_PRODUCT_CATEGORY_QUERY:
|
|
82
|
+
return __assign(__assign({}, state), { productCategoryQuery: action.payload.productCategoryQuery });
|
|
83
|
+
case actions_1.PRODUCT_ACTION_TYPES.SET_PRODUCT_CATEGORIES:
|
|
84
|
+
return __assign(__assign({}, state), { productCategories: action.payload.productCategories });
|
|
85
|
+
default:
|
|
86
|
+
return state;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
@@ -0,0 +1,87 @@
|
|
|
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 { ProductActions } from './actions';
|
|
6
|
+
import { ProductCategoryBE } from '@react-pakistan/util-functions/api/stellar-solutions/type';
|
|
7
|
+
export interface ProductContextType {
|
|
8
|
+
byIdError?: Error;
|
|
9
|
+
byIdLoading: boolean;
|
|
10
|
+
clearSearch: () => void;
|
|
11
|
+
closeDrawer: () => void;
|
|
12
|
+
deleteError?: Error;
|
|
13
|
+
deleteLoading: boolean;
|
|
14
|
+
dispatch: Dispatch<ProductActions>;
|
|
15
|
+
dynamicFormElements: VistaFormElements;
|
|
16
|
+
handleChange: (field: string, value: string | number | number[]) => void;
|
|
17
|
+
handleNextClick: () => void;
|
|
18
|
+
handlePageLimit: (node: string, value: string | any) => void;
|
|
19
|
+
handlePreviousClick: () => void;
|
|
20
|
+
handleSubmit: () => void;
|
|
21
|
+
handleUploadImage: () => void;
|
|
22
|
+
headerActions: VistaTableHeaderActionItem[];
|
|
23
|
+
listError?: Error;
|
|
24
|
+
listFetchNow: () => void;
|
|
25
|
+
listLoading: boolean;
|
|
26
|
+
rowActions: RowActionItem[];
|
|
27
|
+
searchOnChange: (k: string, v: string) => void;
|
|
28
|
+
updateError?: Error;
|
|
29
|
+
updateLoading: boolean;
|
|
30
|
+
}
|
|
31
|
+
export interface ProductTypeBE {
|
|
32
|
+
buyPrice: string;
|
|
33
|
+
createdAt: string;
|
|
34
|
+
currency: string;
|
|
35
|
+
description?: string;
|
|
36
|
+
id: string;
|
|
37
|
+
images?: string[];
|
|
38
|
+
name: string;
|
|
39
|
+
productCategory?: ProductCategoryBE;
|
|
40
|
+
productCategoryId: string;
|
|
41
|
+
quantity: string;
|
|
42
|
+
ref?: string;
|
|
43
|
+
salePrice: string;
|
|
44
|
+
updatedAt: string;
|
|
45
|
+
}
|
|
46
|
+
export interface ProductState extends Omit<ProductTypeBE, 'createdAt' | 'updatedAt'> {
|
|
47
|
+
count: number;
|
|
48
|
+
currentPage: number;
|
|
49
|
+
disableSaveButton: boolean;
|
|
50
|
+
drawer: null | PRODUCT_DRAWER;
|
|
51
|
+
errors: {
|
|
52
|
+
[key: string]: string;
|
|
53
|
+
};
|
|
54
|
+
modal: null | PRODUCT_MODAL;
|
|
55
|
+
pageLimit: number;
|
|
56
|
+
productCategories: ProductCategoryBE[];
|
|
57
|
+
productCategoryQuery: string;
|
|
58
|
+
products: ProductTypeBE[];
|
|
59
|
+
searchQuery: string;
|
|
60
|
+
}
|
|
61
|
+
export interface FetchProductsArgs {
|
|
62
|
+
currentPage: number;
|
|
63
|
+
pageLimit: number;
|
|
64
|
+
searchQuery?: string;
|
|
65
|
+
}
|
|
66
|
+
export declare enum PRODUCT_DRAWER {
|
|
67
|
+
PRODUCT_FORM_DRAWER = "PRODUCT_FORM_DRAWER"
|
|
68
|
+
}
|
|
69
|
+
export declare enum PRODUCT_MODAL {
|
|
70
|
+
DUMMY = "DUMMY"
|
|
71
|
+
}
|
|
72
|
+
export declare enum CURRENCY {
|
|
73
|
+
AUD = "AUD",
|
|
74
|
+
BHD = "BHD",
|
|
75
|
+
CAD = "CAD",
|
|
76
|
+
CNY = "CNY",
|
|
77
|
+
EUR = "EUR",
|
|
78
|
+
GBP = "GBP",
|
|
79
|
+
JOD = "JOD",
|
|
80
|
+
JPY = "JPY",
|
|
81
|
+
KWD = "KWD",
|
|
82
|
+
MYR = "MYR",
|
|
83
|
+
OMR = "OMR",
|
|
84
|
+
PKR = "PKR",
|
|
85
|
+
SAR = "SAR",
|
|
86
|
+
USD = "USD"
|
|
87
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CURRENCY = exports.PRODUCT_MODAL = exports.PRODUCT_DRAWER = void 0;
|
|
4
|
+
var PRODUCT_DRAWER;
|
|
5
|
+
(function (PRODUCT_DRAWER) {
|
|
6
|
+
PRODUCT_DRAWER["PRODUCT_FORM_DRAWER"] = "PRODUCT_FORM_DRAWER";
|
|
7
|
+
})(PRODUCT_DRAWER || (exports.PRODUCT_DRAWER = PRODUCT_DRAWER = {}));
|
|
8
|
+
var PRODUCT_MODAL;
|
|
9
|
+
(function (PRODUCT_MODAL) {
|
|
10
|
+
PRODUCT_MODAL["DUMMY"] = "DUMMY";
|
|
11
|
+
})(PRODUCT_MODAL || (exports.PRODUCT_MODAL = PRODUCT_MODAL = {}));
|
|
12
|
+
var CURRENCY;
|
|
13
|
+
(function (CURRENCY) {
|
|
14
|
+
CURRENCY["AUD"] = "AUD";
|
|
15
|
+
CURRENCY["BHD"] = "BHD";
|
|
16
|
+
CURRENCY["CAD"] = "CAD";
|
|
17
|
+
CURRENCY["CNY"] = "CNY";
|
|
18
|
+
CURRENCY["EUR"] = "EUR";
|
|
19
|
+
CURRENCY["GBP"] = "GBP";
|
|
20
|
+
CURRENCY["JOD"] = "JOD";
|
|
21
|
+
CURRENCY["JPY"] = "JPY";
|
|
22
|
+
CURRENCY["KWD"] = "KWD";
|
|
23
|
+
CURRENCY["MYR"] = "MYR";
|
|
24
|
+
CURRENCY["OMR"] = "OMR";
|
|
25
|
+
CURRENCY["PKR"] = "PKR";
|
|
26
|
+
CURRENCY["SAR"] = "SAR";
|
|
27
|
+
CURRENCY["USD"] = "USD";
|
|
28
|
+
})(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,90 @@
|
|
|
1
|
+
import { PRODUCT_CATEGORY_DRAWER, PRODUCT_CATEGORY_MODAL, ProductCategoryTypeBE } from './types';
|
|
2
|
+
export declare enum PRODUCT_CATEGORY_ACTION_TYPES {
|
|
3
|
+
CLEAR_ERRORS = "CLEAR_ERRORS",
|
|
4
|
+
RESET_FORM = "RESET_FORM",
|
|
5
|
+
SET_COUNT = "SET_COUNT",
|
|
6
|
+
SET_CURRENT_PAGE = "SET_CURRENT_PAGE",
|
|
7
|
+
SET_DISABLE_SAVE_BUTTON = "SET_DISABLE_SAVE_BUTTON",
|
|
8
|
+
SET_DRAWER = "SET_DRAWER",
|
|
9
|
+
SET_ERRORS = "SET_ERRORS",
|
|
10
|
+
SET_FORM = "SET_FORM",
|
|
11
|
+
SET_INPUT_FIELD = "SET_INPUT_FIELD",
|
|
12
|
+
SET_MODAL = "SET_MODAL",
|
|
13
|
+
SET_PAGE_LIMIT = "SET_PAGE_LIMIT",
|
|
14
|
+
SET_PRODUCT_CATEGORIES = "SET_PRODUCT_CATEGORIES",
|
|
15
|
+
SET_SEARCH_QUERY = "SET_SEARCH_QUERY"
|
|
16
|
+
}
|
|
17
|
+
export type ClearErrorAction = {
|
|
18
|
+
type: PRODUCT_CATEGORY_ACTION_TYPES.CLEAR_ERRORS;
|
|
19
|
+
};
|
|
20
|
+
export type ResetFormAction = {
|
|
21
|
+
type: PRODUCT_CATEGORY_ACTION_TYPES.RESET_FORM;
|
|
22
|
+
};
|
|
23
|
+
export type SetCountAction = {
|
|
24
|
+
type: PRODUCT_CATEGORY_ACTION_TYPES.SET_COUNT;
|
|
25
|
+
payload: {
|
|
26
|
+
count: number;
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
export type SetDisableSaveButtonAction = {
|
|
30
|
+
type: PRODUCT_CATEGORY_ACTION_TYPES.SET_DISABLE_SAVE_BUTTON;
|
|
31
|
+
payload: {
|
|
32
|
+
disableSaveButton: boolean;
|
|
33
|
+
};
|
|
34
|
+
};
|
|
35
|
+
export type SetCurrentPageAction = {
|
|
36
|
+
type: PRODUCT_CATEGORY_ACTION_TYPES.SET_CURRENT_PAGE;
|
|
37
|
+
payload: {
|
|
38
|
+
currentPage: number;
|
|
39
|
+
};
|
|
40
|
+
};
|
|
41
|
+
export type SetErrorsAction = {
|
|
42
|
+
type: PRODUCT_CATEGORY_ACTION_TYPES.SET_ERRORS;
|
|
43
|
+
payload: {
|
|
44
|
+
[key: string]: string;
|
|
45
|
+
};
|
|
46
|
+
};
|
|
47
|
+
export type SetInputFieldAction = {
|
|
48
|
+
type: PRODUCT_CATEGORY_ACTION_TYPES.SET_INPUT_FIELD;
|
|
49
|
+
payload: {
|
|
50
|
+
key: keyof ProductCategoryTypeBE;
|
|
51
|
+
value: string | string[] | boolean | number | number[];
|
|
52
|
+
};
|
|
53
|
+
};
|
|
54
|
+
export type SetPageLimitAction = {
|
|
55
|
+
type: PRODUCT_CATEGORY_ACTION_TYPES.SET_PAGE_LIMIT;
|
|
56
|
+
payload: {
|
|
57
|
+
pageLimit: number;
|
|
58
|
+
};
|
|
59
|
+
};
|
|
60
|
+
export type SetProductCategoriesAction = {
|
|
61
|
+
type: PRODUCT_CATEGORY_ACTION_TYPES.SET_PRODUCT_CATEGORIES;
|
|
62
|
+
payload: {
|
|
63
|
+
productCategories: ProductCategoryTypeBE[];
|
|
64
|
+
};
|
|
65
|
+
};
|
|
66
|
+
export type SetSearchQueryAction = {
|
|
67
|
+
type: PRODUCT_CATEGORY_ACTION_TYPES.SET_SEARCH_QUERY;
|
|
68
|
+
payload: {
|
|
69
|
+
searchQuery: string;
|
|
70
|
+
};
|
|
71
|
+
};
|
|
72
|
+
export type SetFormAction = {
|
|
73
|
+
type: PRODUCT_CATEGORY_ACTION_TYPES.SET_FORM;
|
|
74
|
+
payload: {
|
|
75
|
+
form: ProductCategoryTypeBE;
|
|
76
|
+
};
|
|
77
|
+
};
|
|
78
|
+
export type SetDrawerAction = {
|
|
79
|
+
type: PRODUCT_CATEGORY_ACTION_TYPES.SET_DRAWER;
|
|
80
|
+
payload: {
|
|
81
|
+
drawer: PRODUCT_CATEGORY_DRAWER | null;
|
|
82
|
+
};
|
|
83
|
+
};
|
|
84
|
+
export type SetModalAction = {
|
|
85
|
+
type: PRODUCT_CATEGORY_ACTION_TYPES.SET_MODAL;
|
|
86
|
+
payload: {
|
|
87
|
+
modal: PRODUCT_CATEGORY_MODAL | null;
|
|
88
|
+
};
|
|
89
|
+
};
|
|
90
|
+
export type ProductCategoryActions = SetInputFieldAction | ClearErrorAction | ResetFormAction | SetErrorsAction | SetCurrentPageAction | SetDisableSaveButtonAction | SetPageLimitAction | SetSearchQueryAction | SetProductCategoriesAction | SetCountAction | SetFormAction | SetDrawerAction | SetModalAction;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PRODUCT_CATEGORY_ACTION_TYPES = void 0;
|
|
4
|
+
var PRODUCT_CATEGORY_ACTION_TYPES;
|
|
5
|
+
(function (PRODUCT_CATEGORY_ACTION_TYPES) {
|
|
6
|
+
PRODUCT_CATEGORY_ACTION_TYPES["CLEAR_ERRORS"] = "CLEAR_ERRORS";
|
|
7
|
+
PRODUCT_CATEGORY_ACTION_TYPES["RESET_FORM"] = "RESET_FORM";
|
|
8
|
+
PRODUCT_CATEGORY_ACTION_TYPES["SET_COUNT"] = "SET_COUNT";
|
|
9
|
+
PRODUCT_CATEGORY_ACTION_TYPES["SET_CURRENT_PAGE"] = "SET_CURRENT_PAGE";
|
|
10
|
+
PRODUCT_CATEGORY_ACTION_TYPES["SET_DISABLE_SAVE_BUTTON"] = "SET_DISABLE_SAVE_BUTTON";
|
|
11
|
+
PRODUCT_CATEGORY_ACTION_TYPES["SET_DRAWER"] = "SET_DRAWER";
|
|
12
|
+
PRODUCT_CATEGORY_ACTION_TYPES["SET_ERRORS"] = "SET_ERRORS";
|
|
13
|
+
PRODUCT_CATEGORY_ACTION_TYPES["SET_FORM"] = "SET_FORM";
|
|
14
|
+
PRODUCT_CATEGORY_ACTION_TYPES["SET_INPUT_FIELD"] = "SET_INPUT_FIELD";
|
|
15
|
+
PRODUCT_CATEGORY_ACTION_TYPES["SET_MODAL"] = "SET_MODAL";
|
|
16
|
+
PRODUCT_CATEGORY_ACTION_TYPES["SET_PAGE_LIMIT"] = "SET_PAGE_LIMIT";
|
|
17
|
+
PRODUCT_CATEGORY_ACTION_TYPES["SET_PRODUCT_CATEGORIES"] = "SET_PRODUCT_CATEGORIES";
|
|
18
|
+
PRODUCT_CATEGORY_ACTION_TYPES["SET_SEARCH_QUERY"] = "SET_SEARCH_QUERY";
|
|
19
|
+
})(PRODUCT_CATEGORY_ACTION_TYPES || (exports.PRODUCT_CATEGORY_ACTION_TYPES = PRODUCT_CATEGORY_ACTION_TYPES = {}));
|
|
@@ -0,0 +1,28 @@
|
|
|
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 staticFormElements: VistaFormElements;
|
|
8
|
+
export declare const PRODUCT_CATEGORY_API_ROUTES: {
|
|
9
|
+
PRODUCT_CATEGORIES: string;
|
|
10
|
+
PRODUCT_CATEGORY: string;
|
|
11
|
+
PRODUCT_CATEGORY_BY_ID: string;
|
|
12
|
+
};
|
|
13
|
+
export declare const tableBodyCols: ({
|
|
14
|
+
componentType: VISTA_TABLE_CELL_TYPE;
|
|
15
|
+
key: string;
|
|
16
|
+
} | {
|
|
17
|
+
componentType: VISTA_TABLE_CELL_TYPE;
|
|
18
|
+
key?: undefined;
|
|
19
|
+
} | {
|
|
20
|
+
componentType: VISTA_TABLE_CELL_TYPE;
|
|
21
|
+
key: never[];
|
|
22
|
+
})[];
|
|
23
|
+
export declare const messages: {
|
|
24
|
+
name: string;
|
|
25
|
+
success: string;
|
|
26
|
+
error: string;
|
|
27
|
+
};
|
|
28
|
+
export declare const formInfo: {};
|