@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,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.Drawer = void 0;
|
|
7
|
+
var react_1 = __importDefault(require("react"));
|
|
8
|
+
var vista_drawer_v1_1 = require("@appcorp/app-corp-vista/molecules/vista-drawer-v1/vista-drawer-v1");
|
|
9
|
+
var vista_drawer_type_1 = require("@appcorp/app-corp-vista/type/vista-drawer-type");
|
|
10
|
+
var vista_button_type_1 = require("@appcorp/app-corp-vista/type/vista-button-type");
|
|
11
|
+
var context_1 = require("./context");
|
|
12
|
+
var form_1 = require("./form");
|
|
13
|
+
var Drawer = function (_a) {
|
|
14
|
+
var translationMap = _a.translationMap;
|
|
15
|
+
var _b = (0, context_1.useInvoiceStateContext)(), closeDrawer = _b.closeDrawer, disableSaveButton = _b.disableSaveButton, drawer = _b.drawer, handleSubmit = _b.handleSubmit;
|
|
16
|
+
return (react_1.default.createElement(vista_drawer_v1_1.VistaDrawerV1, { cancelLabel: "Cancel", cancelRounded: vista_button_type_1.VISTA_BUTTON_ROUNDED.MD, cancelSize: vista_button_type_1.VISTA_BUTTON_SIZE.LG, handleCancelOnClick: closeDrawer, handleSaveOnClick: handleSubmit, handleSetIsOpen: closeDrawer, isOpen: !!drawer, saveDisabled: disableSaveButton, saveLabel: 'Save', saveRounded: vista_button_type_1.VISTA_BUTTON_ROUNDED.MD, saveSize: vista_button_type_1.VISTA_BUTTON_SIZE.LG, size: vista_drawer_type_1.VISTA_DRAWER_SIZE.XL, title: 'Product' },
|
|
17
|
+
react_1.default.createElement(form_1.InvoiceForm, { translationMap: translationMap })));
|
|
18
|
+
};
|
|
19
|
+
exports.Drawer = Drawer;
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.InvoiceForm = void 0;
|
|
7
|
+
var react_1 = __importDefault(require("react"));
|
|
8
|
+
// import { VistaUploadV1Props } from '@appcorp/app-corp-vista/type/vista-upload-type';
|
|
9
|
+
// import { VistaTextInputV1Props } from '@appcorp/app-corp-vista/type/vista-text-input-type';
|
|
10
|
+
// import { VistaTextAreaV1Props } from '@appcorp/app-corp-vista/type/vista-text-area-type';
|
|
11
|
+
// import { VistaSelectV1Props } from '@appcorp/app-corp-vista/type/vista-select-type';
|
|
12
|
+
// import { VistaFormElements } from '@appcorp/app-corp-vista/type/vista-form-elements';
|
|
13
|
+
// import { VistaComboboxV1Props } from '@appcorp/app-corp-vista/type/vista-combobox-type';
|
|
14
|
+
// import { VISTA_FORM_ELEMENTS } from '@appcorp/app-corp-vista/utils/form-schema';
|
|
15
|
+
// import { useInvoiceStateContext } from './context';
|
|
16
|
+
// import { renderProductFormElements } from './form-elements';
|
|
17
|
+
var products_form_section_1 = require("./products-form-section");
|
|
18
|
+
var pricing_form_section_1 = require("./pricing-form-section");
|
|
19
|
+
var add_service_product_section_1 = require("./add-service-product-section");
|
|
20
|
+
var services_form_section_1 = require("./services-form-section");
|
|
21
|
+
var InvoiceForm = function () {
|
|
22
|
+
// const updated = useMemo(() => {
|
|
23
|
+
// const elements: VistaFormElements = { ...dynamicFormElements };
|
|
24
|
+
// const textInputElements: VistaTextInputV1Props[] | undefined = elements[VISTA_FORM_ELEMENTS.TEXT_INPUT_V1]?.sort((a, b) => a.order - b.order);
|
|
25
|
+
// if (textInputElements) {
|
|
26
|
+
// textInputElements?.forEach(({ label }, i) => {
|
|
27
|
+
// if (translationMap[label as string] === undefined) return label;
|
|
28
|
+
// textInputElements[i].label = translationMap[label as string];
|
|
29
|
+
// });
|
|
30
|
+
// }
|
|
31
|
+
// const textAreaElements: VistaTextAreaV1Props[] | undefined = elements[VISTA_FORM_ELEMENTS.TEXT_AREA_V1]?.sort((a, b) => a.order - b.order);
|
|
32
|
+
// if (textAreaElements) {
|
|
33
|
+
// textAreaElements?.forEach(({ label }, i) => {
|
|
34
|
+
// if (translationMap[label as string] === undefined) return label;
|
|
35
|
+
// textAreaElements[i].label = translationMap[label];
|
|
36
|
+
// });
|
|
37
|
+
// }
|
|
38
|
+
// const selectElements: VistaSelectV1Props[] | undefined = elements[VISTA_FORM_ELEMENTS.SELECT_V1]?.sort((a, b) => a.order - b.order);
|
|
39
|
+
// if (selectElements) {
|
|
40
|
+
// selectElements?.forEach(({ label }, i) => {
|
|
41
|
+
// if (translationMap[label as string] === undefined) return label;
|
|
42
|
+
// selectElements[i].label = translationMap[label as string];
|
|
43
|
+
// });
|
|
44
|
+
// }
|
|
45
|
+
// const comboboxElements: VistaComboboxV1Props[] | undefined = elements[VISTA_FORM_ELEMENTS.COMBOBOX_V1]?.sort((a, b) => a.order - b.order);
|
|
46
|
+
// if (comboboxElements) {
|
|
47
|
+
// comboboxElements?.forEach(({ label }, i) => {
|
|
48
|
+
// if (translationMap[label as string] === undefined) return label;
|
|
49
|
+
// comboboxElements[i].label = translationMap[label as string];
|
|
50
|
+
// });
|
|
51
|
+
// }
|
|
52
|
+
// const uploadElements: VistaUploadV1Props[] | undefined = elements[VISTA_FORM_ELEMENTS.UPLOAD_V1]?.sort((a, b) => a.order - b.order);
|
|
53
|
+
// if (uploadElements) {
|
|
54
|
+
// uploadElements?.forEach(({ label }, i) => {
|
|
55
|
+
// if (translationMap[label as string] === undefined) return label;
|
|
56
|
+
// uploadElements[i].label = translationMap[label as string];
|
|
57
|
+
// });
|
|
58
|
+
// }
|
|
59
|
+
// return elements;
|
|
60
|
+
// }, [dynamicFormElements, translationMap]);
|
|
61
|
+
return (react_1.default.createElement("div", { className: "flex flex-col gap-8" },
|
|
62
|
+
react_1.default.createElement(services_form_section_1.ServicesSection, null),
|
|
63
|
+
react_1.default.createElement(products_form_section_1.ProductsSection, null),
|
|
64
|
+
react_1.default.createElement(add_service_product_section_1.AddServiceProductSection, null),
|
|
65
|
+
react_1.default.createElement(pricing_form_section_1.PricingSection, null)));
|
|
66
|
+
};
|
|
67
|
+
exports.InvoiceForm = InvoiceForm;
|
|
@@ -0,0 +1,90 @@
|
|
|
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.InvoicePage = void 0;
|
|
8
|
+
var react_1 = __importDefault(require("react"));
|
|
9
|
+
var next_intl_1 = require("next-intl");
|
|
10
|
+
var util_functions_1 = require("@react-pakistan/util-functions");
|
|
11
|
+
var context_1 = require("./context");
|
|
12
|
+
var vista_table_v1_1 = require("@appcorp/app-corp-vista/organisms/vista-table-v1/vista-table-v1");
|
|
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 InvoicePage = function () {
|
|
19
|
+
var _a = (0, context_1.useInvoiceStateContext)(), count = _a.count, currentPage = _a.currentPage, pageLimit = _a.pageLimit, handleNextClick = _a.handleNextClick, handlePreviousClick = _a.handlePreviousClick,
|
|
20
|
+
// toggleDrawerOpen,
|
|
21
|
+
headerActions = _a.headerActions, handlePageLimit = _a.handlePageLimit, searchQuery = _a.searchQuery, searchOnChange = _a.searchOnChange, rowActions = _a.rowActions, invoices = _a.invoices;
|
|
22
|
+
var t = (0, next_intl_1.useTranslations)('invoicePage');
|
|
23
|
+
var translationMap = {
|
|
24
|
+
formLabelName: 'formLabelName',
|
|
25
|
+
formLabelBuyPrice: 'formLabelBuyPrice',
|
|
26
|
+
formLabelDescription: 'formLabelDescription',
|
|
27
|
+
formLabelQuantity: 'formLabelQuantity',
|
|
28
|
+
formLabelSalePrice: 'formLabelSalePrice',
|
|
29
|
+
formLabelRef: 'formLabelRef',
|
|
30
|
+
formLabelCurrency: 'formLabelCurrency',
|
|
31
|
+
formLabelImage: 'formLabelImage',
|
|
32
|
+
formLabelProductCategory: 'formLabelProductCategory',
|
|
33
|
+
};
|
|
34
|
+
var tableHeadItems = [
|
|
35
|
+
{
|
|
36
|
+
label: t('tableColumnHeaderId'),
|
|
37
|
+
width: '5%',
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
label: t('tableColumnHeaderName'),
|
|
41
|
+
width: '10%',
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
label: t('tableColumnHeaderCurrency'),
|
|
45
|
+
width: '5%',
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
label: t('tableColumnHeaderIssueExpiryDate'),
|
|
49
|
+
width: '10%',
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
label: t('tableColumnHeaderNote'),
|
|
53
|
+
width: '5%',
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
label: t('tableColumnHeaderRef'),
|
|
57
|
+
width: '5%',
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
label: t('tableColumnHeaderSubTotal'),
|
|
61
|
+
width: '5%',
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
label: t('tableColumnHeaderTaxValue'),
|
|
65
|
+
width: '5%',
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
label: t('tableColumnHeaderDiscountPrice'),
|
|
69
|
+
width: '5%',
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
label: t('tableColumnHeaderTotalPrice'),
|
|
73
|
+
width: '5%',
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
label: t('tableColumnHeaderCategory'),
|
|
77
|
+
width: '5%',
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
label: t('tableColumnHeaderActions'),
|
|
81
|
+
width: '5%',
|
|
82
|
+
},
|
|
83
|
+
];
|
|
84
|
+
var totalPagePerRecord = (0, util_functions_1.calculatePages)(count, pageLimit);
|
|
85
|
+
return (react_1.default.createElement(react_1.default.Fragment, null,
|
|
86
|
+
react_1.default.createElement(vista_table_v1_1.VistaTableV1, { currentPage: count, isNextDisabled: (0, util_functions_1.isNextButtonDisabled)(currentPage, totalPagePerRecord), isPreviousDisabled: (0, util_functions_1.isPreviousButtonDisabled)(currentPage), handleNextOnClick: handleNextClick, handlePreviousOnClick: handlePreviousClick, tableDescription: t('subTitle'), tableHeading: t('title'), totalPages: totalPagePerRecord, headerActions: headerActions, handleOnSelect: function () { return handlePageLimit; }, selectKey1: "label", nodeSelectKey: "pageLimit", selectedItem: { label: String(pageLimit) }, listOptions: (0, util_functions_1.getAvailablePageLimits)(count), searchEnabled: true, searchValue: searchQuery, searchPlaceholder: "Enter ID or Name...", searchDisabled: false, searchId: "inventory-search", handleSearchInput: searchOnChange, loading: true, pageLimit: pageLimit, rowActions: rowActions, tableBodyCols: constants_1.tableBodyCols, tableBodyRows: invoices, tableHeadItems: tableHeadItems }),
|
|
87
|
+
react_1.default.createElement(drawer_1.Drawer, { translationMap: translationMap }),
|
|
88
|
+
react_1.default.createElement(generate_toast_1.VistaToaster, null)));
|
|
89
|
+
};
|
|
90
|
+
exports.InvoicePage = InvoicePage;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
var __assign = (this && this.__assign) || function () {
|
|
4
|
+
__assign = Object.assign || function(t) {
|
|
5
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
6
|
+
s = arguments[i];
|
|
7
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
8
|
+
t[p] = s[p];
|
|
9
|
+
}
|
|
10
|
+
return t;
|
|
11
|
+
};
|
|
12
|
+
return __assign.apply(this, arguments);
|
|
13
|
+
};
|
|
14
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
15
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
16
|
+
};
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
exports.renderPricingFormElements = void 0;
|
|
19
|
+
var react_1 = __importDefault(require("react"));
|
|
20
|
+
var form_schema_1 = require("@appcorp/app-corp-vista/utils/form-schema");
|
|
21
|
+
var renderPricingFormElements = function (elementProps) {
|
|
22
|
+
var _a;
|
|
23
|
+
var elementsArray = (_a = Object.entries(form_schema_1.vistaFormSchema)
|
|
24
|
+
.flatMap(function (_a) {
|
|
25
|
+
var _b, _c;
|
|
26
|
+
var key = _a[0], config = _a[1];
|
|
27
|
+
var Component = config;
|
|
28
|
+
return (_c = (_b = (elementProps[key] || [])) === null || _b === void 0 ? void 0 : _b.filter(function (props) { return props.enabled; })) === null || _c === void 0 ? void 0 : _c.map(function (props) { return ({
|
|
29
|
+
Component: Component,
|
|
30
|
+
key: key,
|
|
31
|
+
order: props.order,
|
|
32
|
+
props: props,
|
|
33
|
+
}); });
|
|
34
|
+
})) === null || _a === void 0 ? void 0 : _a.sort(function (a, b) { return a.order - b.order; });
|
|
35
|
+
return (react_1.default.createElement("div", { className: "grid grid-cols-1 gap-4" }, elementsArray === null || elementsArray === void 0 ? void 0 : elementsArray.map(function (_a, index) {
|
|
36
|
+
var key = _a.key, Component = _a.Component, props = _a.props;
|
|
37
|
+
return (react_1.default.createElement("div", { key: "".concat(key, "-").concat(index) },
|
|
38
|
+
react_1.default.createElement(Component, __assign({}, props))));
|
|
39
|
+
})));
|
|
40
|
+
};
|
|
41
|
+
exports.renderPricingFormElements = renderPricingFormElements;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.PricingSection = void 0;
|
|
7
|
+
var react_1 = __importDefault(require("react"));
|
|
8
|
+
var vista_vertical_divider_v4_1 = require("@appcorp/app-corp-vista/molecules/vista-vertical-divider-v4");
|
|
9
|
+
var context_1 = require("./context");
|
|
10
|
+
var pricing_form_elements_1 = require("./pricing-form-elements");
|
|
11
|
+
var PricingSection = function () {
|
|
12
|
+
var dynamicPricingFormElements = (0, context_1.useInvoiceStateContext)().dynamicPricingFormElements;
|
|
13
|
+
return (react_1.default.createElement(react_1.default.Fragment, null,
|
|
14
|
+
react_1.default.createElement(vista_vertical_divider_v4_1.VistaVerticalDividerV4, { label: "Totals" }),
|
|
15
|
+
react_1.default.createElement("div", { className: "grid grid-cols-3 justify-end" },
|
|
16
|
+
react_1.default.createElement("div", null),
|
|
17
|
+
react_1.default.createElement("div", null),
|
|
18
|
+
(0, pricing_form_elements_1.renderPricingFormElements)(dynamicPricingFormElements))));
|
|
19
|
+
};
|
|
20
|
+
exports.PricingSection = PricingSection;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
var __assign = (this && this.__assign) || function () {
|
|
4
|
+
__assign = Object.assign || function(t) {
|
|
5
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
6
|
+
s = arguments[i];
|
|
7
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
8
|
+
t[p] = s[p];
|
|
9
|
+
}
|
|
10
|
+
return t;
|
|
11
|
+
};
|
|
12
|
+
return __assign.apply(this, arguments);
|
|
13
|
+
};
|
|
14
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
15
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
16
|
+
};
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
exports.renderProductsFormElements = void 0;
|
|
19
|
+
var react_1 = __importDefault(require("react"));
|
|
20
|
+
var form_schema_1 = require("@appcorp/app-corp-vista/utils/form-schema");
|
|
21
|
+
var renderProductsFormElements = function (elementProps, row) {
|
|
22
|
+
var _a;
|
|
23
|
+
var elementsArray = (_a = Object.entries(form_schema_1.vistaFormSchema)
|
|
24
|
+
.flatMap(function (_a) {
|
|
25
|
+
var _b, _c;
|
|
26
|
+
var key = _a[0], config = _a[1];
|
|
27
|
+
var Component = config;
|
|
28
|
+
return (_c = (_b = (elementProps[key] || [])) === null || _b === void 0 ? void 0 : _b.filter(function (props) { return props.enabled; })) === null || _c === void 0 ? void 0 : _c.map(function (props) { return ({
|
|
29
|
+
Component: Component,
|
|
30
|
+
key: key,
|
|
31
|
+
order: props.order,
|
|
32
|
+
props: props,
|
|
33
|
+
}); });
|
|
34
|
+
})) === null || _a === void 0 ? void 0 : _a.sort(function (a, b) { return a.order - b.order; });
|
|
35
|
+
return (react_1.default.createElement("div", { className: "grid grid-cols-[17.5%_17.5%_17.5%_17.5%_17.5%_auto] gap-4" }, elementsArray === null || elementsArray === void 0 ? void 0 : elementsArray.map(function (_a, index) {
|
|
36
|
+
var key = _a.key, Component = _a.Component, props = _a.props;
|
|
37
|
+
return (react_1.default.createElement("div", { key: "".concat(key, "-").concat(index), className: props.className },
|
|
38
|
+
react_1.default.createElement(Component, __assign({}, props, row))));
|
|
39
|
+
})));
|
|
40
|
+
};
|
|
41
|
+
exports.renderProductsFormElements = renderProductsFormElements;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.ProductsSection = void 0;
|
|
7
|
+
var react_1 = __importDefault(require("react"));
|
|
8
|
+
var vista_vertical_divider_v4_1 = require("@appcorp/app-corp-vista/molecules/vista-vertical-divider-v4");
|
|
9
|
+
var context_1 = require("./context");
|
|
10
|
+
var products_form_elements_1 = require("./products-form-elements");
|
|
11
|
+
var ProductsSection = function () {
|
|
12
|
+
var _a = (0, context_1.useInvoiceStateContext)(), dynamicProductFormElements = _a.dynamicProductFormElements, products = _a.products;
|
|
13
|
+
return (react_1.default.createElement("div", { className: "flex flex-col gap-4" },
|
|
14
|
+
react_1.default.createElement(vista_vertical_divider_v4_1.VistaVerticalDividerV4, { label: "Products" }),
|
|
15
|
+
products.map(function (row, index) { return (react_1.default.createElement("div", { key: index }, (0, products_form_elements_1.renderProductsFormElements)(dynamicProductFormElements, row))); })));
|
|
16
|
+
};
|
|
17
|
+
exports.ProductsSection = ProductsSection;
|
|
@@ -0,0 +1,138 @@
|
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
+
exports.initialInvoiceState = void 0;
|
|
15
|
+
exports.invoiceReducer = invoiceReducer;
|
|
16
|
+
var actions_1 = require("./actions");
|
|
17
|
+
var types_1 = require("./types");
|
|
18
|
+
var constants_1 = require("./constants");
|
|
19
|
+
var date_fns_1 = require("date-fns");
|
|
20
|
+
exports.initialInvoiceState = {
|
|
21
|
+
count: 0,
|
|
22
|
+
disableSaveButton: false,
|
|
23
|
+
drawer: null,
|
|
24
|
+
modal: null,
|
|
25
|
+
payments: [],
|
|
26
|
+
mode: 'Create',
|
|
27
|
+
invoiceId: '',
|
|
28
|
+
category: types_1.QUOTE_INVOICE.INVOICE,
|
|
29
|
+
company: {
|
|
30
|
+
name: '',
|
|
31
|
+
country: '',
|
|
32
|
+
createdAt: '',
|
|
33
|
+
updatedAt: '',
|
|
34
|
+
id: '',
|
|
35
|
+
phone: '',
|
|
36
|
+
email: '',
|
|
37
|
+
website: '',
|
|
38
|
+
},
|
|
39
|
+
// btnDisableInvoice: false,
|
|
40
|
+
companyId: '',
|
|
41
|
+
currency: '',
|
|
42
|
+
currentPage: 1,
|
|
43
|
+
date: new Date().toISOString(),
|
|
44
|
+
discount: '',
|
|
45
|
+
discountUnit: '',
|
|
46
|
+
errors: {},
|
|
47
|
+
expiryDate: (0, date_fns_1.addDays)(new Date(), 7).toISOString(),
|
|
48
|
+
// formLoadingInvoice: false,
|
|
49
|
+
id: '',
|
|
50
|
+
invoiceStatus: '',
|
|
51
|
+
invoices: [],
|
|
52
|
+
loading: true,
|
|
53
|
+
netTotal: '',
|
|
54
|
+
note: '',
|
|
55
|
+
pageLimit: constants_1.pageLimit,
|
|
56
|
+
ref: '',
|
|
57
|
+
searchQuery: '',
|
|
58
|
+
subTotal: '',
|
|
59
|
+
taxValue: '',
|
|
60
|
+
total: '',
|
|
61
|
+
services: [
|
|
62
|
+
{
|
|
63
|
+
mode: 'Create',
|
|
64
|
+
name: '',
|
|
65
|
+
description: '',
|
|
66
|
+
quantity: '1',
|
|
67
|
+
price: '',
|
|
68
|
+
rowTotal: '',
|
|
69
|
+
},
|
|
70
|
+
],
|
|
71
|
+
products: [
|
|
72
|
+
{
|
|
73
|
+
mode: 'Create',
|
|
74
|
+
price: '',
|
|
75
|
+
productId: '',
|
|
76
|
+
quantity: 1,
|
|
77
|
+
rowTotal: '',
|
|
78
|
+
},
|
|
79
|
+
],
|
|
80
|
+
firstName: '',
|
|
81
|
+
lastName: '',
|
|
82
|
+
country: '',
|
|
83
|
+
phone: '',
|
|
84
|
+
email: '',
|
|
85
|
+
city: '',
|
|
86
|
+
// fetchPhoneLoading: false,
|
|
87
|
+
address: '',
|
|
88
|
+
customerId: '',
|
|
89
|
+
// fieldDisabled: true,
|
|
90
|
+
// isInvoiceApiSuccess: false,
|
|
91
|
+
// pageLimit: pageLimit
|
|
92
|
+
};
|
|
93
|
+
function invoiceReducer(state, action) {
|
|
94
|
+
var _a;
|
|
95
|
+
switch (action.type) {
|
|
96
|
+
case actions_1.INVOICE_ACTION_TYPES.SET_DRAWER:
|
|
97
|
+
return __assign(__assign({}, state), { drawer: action.payload.drawer });
|
|
98
|
+
case actions_1.INVOICE_ACTION_TYPES.CLEAR_ERRORS:
|
|
99
|
+
return __assign(__assign({}, state), { errors: {} });
|
|
100
|
+
case actions_1.INVOICE_ACTION_TYPES.RESET_FORM:
|
|
101
|
+
return __assign(__assign({}, state), { disableSaveButton: false, errors: {} });
|
|
102
|
+
case actions_1.INVOICE_ACTION_TYPES.SET_DISABLE_SAVE_BUTTON:
|
|
103
|
+
return __assign(__assign({}, state), { disableSaveButton: action.payload.disableSaveButton });
|
|
104
|
+
case actions_1.INVOICE_ACTION_TYPES.SET_CURRENT_PAGE:
|
|
105
|
+
return __assign(__assign({}, state), { currentPage: action.payload.currentPage });
|
|
106
|
+
case actions_1.INVOICE_ACTION_TYPES.SET_COUNT:
|
|
107
|
+
return __assign(__assign({}, state), { count: action.payload.count });
|
|
108
|
+
case actions_1.INVOICE_ACTION_TYPES.SET_ERRORS:
|
|
109
|
+
return __assign(__assign({}, state), { disableSaveButton: false, errors: __assign({}, action.payload) });
|
|
110
|
+
case actions_1.INVOICE_ACTION_TYPES.SET_INPUT_FIELD:
|
|
111
|
+
return __assign(__assign({}, state), (_a = {}, _a[action.payload.key] = action.payload.value, _a));
|
|
112
|
+
// case INVOICE_ACTION_TYPES.SET_INPUT_IMAGES:
|
|
113
|
+
// return {
|
|
114
|
+
// ...state,
|
|
115
|
+
// [action.payload.key]: [...action.payload.value],
|
|
116
|
+
// };
|
|
117
|
+
case actions_1.INVOICE_ACTION_TYPES.SET_PAGE_LIMIT:
|
|
118
|
+
return __assign(__assign({}, state), { pageLimit: action.payload.pageLimit });
|
|
119
|
+
// case INVOICE_ACTION_TYPES.SET_PRODUCTS:
|
|
120
|
+
// return {
|
|
121
|
+
// ...state,
|
|
122
|
+
// products: [...action.payload.products],
|
|
123
|
+
// };
|
|
124
|
+
case actions_1.INVOICE_ACTION_TYPES.SET_SEARCH_QUERY:
|
|
125
|
+
return __assign(__assign({}, state), { searchQuery: action.payload.searchQuery });
|
|
126
|
+
case actions_1.INVOICE_ACTION_TYPES.SET_FORM:
|
|
127
|
+
return __assign(__assign({}, state), action.payload.form);
|
|
128
|
+
case actions_1.INVOICE_ACTION_TYPES.SET_DRAWER:
|
|
129
|
+
return __assign(__assign({}, state), { drawer: action.payload.drawer });
|
|
130
|
+
// case INVOICE_ACTION_TYPES.SET_MODAL:
|
|
131
|
+
// return {
|
|
132
|
+
// ...state,
|
|
133
|
+
// modal: action.payload.modal,
|
|
134
|
+
// };
|
|
135
|
+
default:
|
|
136
|
+
return state;
|
|
137
|
+
}
|
|
138
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
var __assign = (this && this.__assign) || function () {
|
|
4
|
+
__assign = Object.assign || function(t) {
|
|
5
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
6
|
+
s = arguments[i];
|
|
7
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
8
|
+
t[p] = s[p];
|
|
9
|
+
}
|
|
10
|
+
return t;
|
|
11
|
+
};
|
|
12
|
+
return __assign.apply(this, arguments);
|
|
13
|
+
};
|
|
14
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
15
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
16
|
+
};
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
exports.renderServicesFormElements = void 0;
|
|
19
|
+
var react_1 = __importDefault(require("react"));
|
|
20
|
+
var form_schema_1 = require("@appcorp/app-corp-vista/utils/form-schema");
|
|
21
|
+
var renderServicesFormElements = function (elementProps, row) {
|
|
22
|
+
var _a;
|
|
23
|
+
var elementsArray = (_a = Object.entries(form_schema_1.vistaFormSchema)
|
|
24
|
+
.flatMap(function (_a) {
|
|
25
|
+
var _b, _c;
|
|
26
|
+
var key = _a[0], config = _a[1];
|
|
27
|
+
var Component = config;
|
|
28
|
+
return (_c = (_b = (elementProps[key] || [])) === null || _b === void 0 ? void 0 : _b.filter(function (props) { return props.enabled; })) === null || _c === void 0 ? void 0 : _c.map(function (props) { return ({
|
|
29
|
+
Component: Component,
|
|
30
|
+
key: key,
|
|
31
|
+
order: props.order,
|
|
32
|
+
props: props,
|
|
33
|
+
}); });
|
|
34
|
+
})) === null || _a === void 0 ? void 0 : _a.sort(function (a, b) { return a.order - b.order; });
|
|
35
|
+
return (react_1.default.createElement("div", { className: "grid grid-cols-[17.5%_17.5%_17.5%_17.5%_17.5%_auto] gap-4" }, elementsArray === null || elementsArray === void 0 ? void 0 : elementsArray.map(function (_a, index) {
|
|
36
|
+
var key = _a.key, Component = _a.Component, props = _a.props;
|
|
37
|
+
return (react_1.default.createElement("div", { key: "".concat(key, "-").concat(index), className: props.className },
|
|
38
|
+
react_1.default.createElement(Component, __assign({}, props, row))));
|
|
39
|
+
})));
|
|
40
|
+
};
|
|
41
|
+
exports.renderServicesFormElements = renderServicesFormElements;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.ServicesSection = void 0;
|
|
7
|
+
var react_1 = __importDefault(require("react"));
|
|
8
|
+
var vista_vertical_divider_v4_1 = require("@appcorp/app-corp-vista/molecules/vista-vertical-divider-v4");
|
|
9
|
+
var context_1 = require("./context");
|
|
10
|
+
var services_form_elements_1 = require("./services-form-elements");
|
|
11
|
+
var ServicesSection = function () {
|
|
12
|
+
var _a = (0, context_1.useInvoiceStateContext)(), services = _a.services, dynamicServiceFormElements = _a.dynamicServiceFormElements;
|
|
13
|
+
return (react_1.default.createElement("div", { className: "flex flex-col gap-4" },
|
|
14
|
+
react_1.default.createElement(vista_vertical_divider_v4_1.VistaVerticalDividerV4, { label: "Services" }),
|
|
15
|
+
services.map(function (row, index) { return (react_1.default.createElement("div", { key: index }, (0, services_form_elements_1.renderServicesFormElements)(dynamicServiceFormElements, row))); })));
|
|
16
|
+
};
|
|
17
|
+
exports.ServicesSection = ServicesSection;
|