@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,53 @@
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.ProductCategoryPage = void 0;
8
+ require("slick-carousel/slick/slick.css");
9
+ require("slick-carousel/slick/slick-theme.css");
10
+ var vista_table_v1_1 = require("@appcorp/app-corp-vista/organisms/vista-table-v1/vista-table-v1");
11
+ var react_1 = __importDefault(require("react"));
12
+ var next_intl_1 = require("next-intl");
13
+ var util_functions_1 = require("@react-pakistan/util-functions");
14
+ var context_1 = require("./context");
15
+ var constants_1 = require("./constants");
16
+ var drawer_1 = require("./drawer");
17
+ var generate_toast_1 = require("@appcorp/app-corp-vista/utils/generate-toast");
18
+ var ProductCategoryPage = function () {
19
+ var _a = (0, context_1.useProductCategoryStateContext)(), count = _a.count, currentPage = _a.currentPage, handleNextClick = _a.handleNextClick, handlePageLimit = _a.handlePageLimit, handlePreviousClick = _a.handlePreviousClick, headerActions = _a.headerActions, listLoading = _a.listLoading, pageLimit = _a.pageLimit, productCategories = _a.productCategories, rowActions = _a.rowActions, searchOnChange = _a.searchOnChange, searchQuery = _a.searchQuery;
20
+ var t = (0, next_intl_1.useTranslations)('productCategoryPage');
21
+ var translationMap = {
22
+ formLabelName: t('formLabelName'),
23
+ formLabelDescription: t('formLabelDescription'),
24
+ };
25
+ var tableHeadItems = [
26
+ {
27
+ label: t('tableColumnHeaderId'),
28
+ width: '5%',
29
+ },
30
+ {
31
+ label: t('tableColumnHeaderName'),
32
+ width: '20%',
33
+ },
34
+ {
35
+ label: t('tableColumnHeaderDescription'),
36
+ width: '50%',
37
+ },
38
+ {
39
+ label: t('tableColumnHeaderActivity'),
40
+ width: '20%',
41
+ },
42
+ {
43
+ label: t('tableColumnHeaderActions'),
44
+ width: '5%',
45
+ },
46
+ ];
47
+ var totalPages = (0, util_functions_1.calculatePages)(count, pageLimit);
48
+ return (react_1.default.createElement(react_1.default.Fragment, null,
49
+ 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-category-search", searchPlaceholder: t('tableHeaderSearchPlaceholder'), searchValue: searchQuery, selectKey1: "option", selectedItem: { option: String(pageLimit) }, tableBodyCols: constants_1.tableBodyCols, tableBodyRows: productCategories, tableDescription: t('tableDescription'), tableHeadItems: tableHeadItems, tableHeading: t('tableTitle'), totalPages: Number(totalPages) }),
50
+ react_1.default.createElement(drawer_1.Drawer, { translationMap: translationMap }),
51
+ react_1.default.createElement(generate_toast_1.VistaToaster, null)));
52
+ };
53
+ exports.ProductCategoryPage = ProductCategoryPage;
@@ -0,0 +1,4 @@
1
+ import { ProductCategoryActions } from './actions';
2
+ import { ProductCategoryState } from './types';
3
+ export declare const initialProductCategoryState: ProductCategoryState;
4
+ export declare function productCategoryReducer(state: ProductCategoryState, action: ProductCategoryActions): ProductCategoryState;
@@ -0,0 +1,73 @@
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.initialProductCategoryState = void 0;
24
+ exports.productCategoryReducer = productCategoryReducer;
25
+ var actions_1 = require("./actions");
26
+ var constants_1 = require("./constants");
27
+ exports.initialProductCategoryState = {
28
+ count: 0,
29
+ currentPage: 1,
30
+ description: '',
31
+ disableSaveButton: true,
32
+ drawer: null,
33
+ errors: {},
34
+ id: '',
35
+ modal: null,
36
+ name: '',
37
+ pageLimit: constants_1.pageLimit,
38
+ productCategories: [],
39
+ searchQuery: '',
40
+ };
41
+ function productCategoryReducer(state, action) {
42
+ var _a;
43
+ switch (action.type) {
44
+ case actions_1.PRODUCT_CATEGORY_ACTION_TYPES.CLEAR_ERRORS:
45
+ return __assign(__assign({}, state), { errors: {} });
46
+ case actions_1.PRODUCT_CATEGORY_ACTION_TYPES.RESET_FORM:
47
+ return __assign(__assign({}, state), { description: '', disableSaveButton: false, errors: {}, name: '' });
48
+ case actions_1.PRODUCT_CATEGORY_ACTION_TYPES.SET_DISABLE_SAVE_BUTTON:
49
+ return __assign(__assign({}, state), { disableSaveButton: action.payload.disableSaveButton });
50
+ case actions_1.PRODUCT_CATEGORY_ACTION_TYPES.SET_CURRENT_PAGE:
51
+ return __assign(__assign({}, state), { currentPage: action.payload.currentPage });
52
+ case actions_1.PRODUCT_CATEGORY_ACTION_TYPES.SET_COUNT:
53
+ return __assign(__assign({}, state), { count: action.payload.count });
54
+ case actions_1.PRODUCT_CATEGORY_ACTION_TYPES.SET_ERRORS:
55
+ return __assign(__assign({}, state), { disableSaveButton: false, errors: __assign({}, action.payload) });
56
+ case actions_1.PRODUCT_CATEGORY_ACTION_TYPES.SET_INPUT_FIELD:
57
+ return __assign(__assign({}, state), (_a = {}, _a[action.payload.key] = action.payload.value, _a));
58
+ case actions_1.PRODUCT_CATEGORY_ACTION_TYPES.SET_PAGE_LIMIT:
59
+ return __assign(__assign({}, state), { pageLimit: action.payload.pageLimit });
60
+ case actions_1.PRODUCT_CATEGORY_ACTION_TYPES.SET_PRODUCT_CATEGORIES:
61
+ return __assign(__assign({}, state), { productCategories: __spreadArray([], action.payload.productCategories, true) });
62
+ case actions_1.PRODUCT_CATEGORY_ACTION_TYPES.SET_SEARCH_QUERY:
63
+ return __assign(__assign({}, state), { searchQuery: action.payload.searchQuery });
64
+ case actions_1.PRODUCT_CATEGORY_ACTION_TYPES.SET_FORM:
65
+ return __assign(__assign({}, state), action.payload.form);
66
+ case actions_1.PRODUCT_CATEGORY_ACTION_TYPES.SET_DRAWER:
67
+ return __assign(__assign({}, state), { drawer: action.payload.drawer });
68
+ case actions_1.PRODUCT_CATEGORY_ACTION_TYPES.SET_MODAL:
69
+ return __assign(__assign({}, state), { modal: action.payload.modal });
70
+ default:
71
+ return state;
72
+ }
73
+ }
@@ -0,0 +1,59 @@
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 { ProductCategoryActions } from './actions';
6
+ export interface ProductCategoryContextType {
7
+ byIdError?: Error;
8
+ byIdLoading: boolean;
9
+ clearSearch: () => void;
10
+ closeDrawer: () => void;
11
+ deleteError?: Error;
12
+ deleteLoading: boolean;
13
+ dispatch: Dispatch<ProductCategoryActions>;
14
+ dynamicFormElements: VistaFormElements;
15
+ handleChange: (field: string, value: string | number | number[]) => void;
16
+ handleNextClick: () => void;
17
+ handlePageLimit: (node: string, value: string | any) => void;
18
+ handlePreviousClick: () => void;
19
+ handleSubmit: () => void;
20
+ headerActions: VistaTableHeaderActionItem[];
21
+ listError?: Error;
22
+ listFetchNow: () => void;
23
+ listLoading: boolean;
24
+ rowActions: RowActionItem[];
25
+ searchOnChange: (k: string, v: string) => void;
26
+ updateError?: Error;
27
+ updateLoading: boolean;
28
+ }
29
+ export interface ProductCategoryTypeBE {
30
+ createdAt: string;
31
+ description: string;
32
+ id: string;
33
+ name: string;
34
+ updatedAt: string;
35
+ }
36
+ export interface ProductCategoryState extends Omit<ProductCategoryTypeBE, 'createdAt' | 'updatedAt'> {
37
+ count: number;
38
+ currentPage: number;
39
+ disableSaveButton: boolean;
40
+ drawer: null | PRODUCT_CATEGORY_DRAWER;
41
+ errors: {
42
+ [key: string]: string;
43
+ };
44
+ modal: null | PRODUCT_CATEGORY_MODAL;
45
+ pageLimit: number;
46
+ productCategories: ProductCategoryTypeBE[];
47
+ searchQuery: string;
48
+ }
49
+ export interface FetchProductCategoriesArgs {
50
+ currentPage: number;
51
+ pageLimit: number;
52
+ searchQuery?: string;
53
+ }
54
+ export declare enum PRODUCT_CATEGORY_DRAWER {
55
+ PRODUCT_CATEGORY_FORM_DRAWER = "PRODUCT_CATEGORY_FORM_DRAWER"
56
+ }
57
+ export declare enum PRODUCT_CATEGORY_MODAL {
58
+ DUMMY = "DUMMY"
59
+ }
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PRODUCT_CATEGORY_MODAL = exports.PRODUCT_CATEGORY_DRAWER = void 0;
4
+ var PRODUCT_CATEGORY_DRAWER;
5
+ (function (PRODUCT_CATEGORY_DRAWER) {
6
+ PRODUCT_CATEGORY_DRAWER["PRODUCT_CATEGORY_FORM_DRAWER"] = "PRODUCT_CATEGORY_FORM_DRAWER";
7
+ })(PRODUCT_CATEGORY_DRAWER || (exports.PRODUCT_CATEGORY_DRAWER = PRODUCT_CATEGORY_DRAWER = {}));
8
+ var PRODUCT_CATEGORY_MODAL;
9
+ (function (PRODUCT_CATEGORY_MODAL) {
10
+ PRODUCT_CATEGORY_MODAL["DUMMY"] = "DUMMY";
11
+ })(PRODUCT_CATEGORY_MODAL || (exports.PRODUCT_CATEGORY_MODAL = PRODUCT_CATEGORY_MODAL = {}));
@@ -0,0 +1,12 @@
1
+ import { z } from 'zod';
2
+ export declare const formValidation: z.ZodObject<{
3
+ name: z.ZodString;
4
+ description: z.ZodOptional<z.ZodString>;
5
+ }, "strip", z.ZodTypeAny, {
6
+ name: string;
7
+ description?: string | undefined;
8
+ }, {
9
+ name: string;
10
+ description?: string | undefined;
11
+ }>;
12
+ export type ProductCategoryFormValidate = z.infer<typeof formValidation>;
@@ -0,0 +1,11 @@
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
+ name: zod_1.z
8
+ .string()
9
+ .nonempty(constants_1.messages.name),
10
+ description: zod_1.z.string().optional(),
11
+ });
package/package.json ADDED
@@ -0,0 +1,60 @@
1
+ {
2
+ "name": "@appcorp/stellar-solutions-invoice-module",
3
+ "version": "0.1.1",
4
+ "scripts": {
5
+ "build": "yarn clean && yarn build:ts && cp package.json lib && cp README.md lib",
6
+ "build:next": "next build",
7
+ "build:ts": "tsc --project tsconfig.build.json",
8
+ "clean": "yarn rimraf ./lib",
9
+ "dev": "next dev",
10
+ "lint": "next lint",
11
+ "major": "npm version major",
12
+ "minor": "npm version minor",
13
+ "patch": "npm version patch",
14
+ "prepare": "husky",
15
+ "publish:npm": "yarn build && cd lib/ && npm publish --access public && cd ..",
16
+ "start": "next start",
17
+ "upgrade": "ncu -u"
18
+ },
19
+ "dependencies": {
20
+ "@appcorp/stellar-solutions-company-module": "^0.1.16",
21
+ "@appcorp/stellar-solutions-product-module": "^0.1.84",
22
+ "date-fns": "^4.1.0"
23
+ },
24
+ "devDependencies": {
25
+ "@appcorp/app-corp-designs": "^0.4.79",
26
+ "@appcorp/app-corp-vista": "^0.1.95",
27
+ "@appcorp/stellar-solutions-modules": "^0.1.5",
28
+ "@eslint/eslintrc": "^3",
29
+ "@headlessui/react": "^2.2.0",
30
+ "@heroicons/react": "^2.2.0",
31
+ "@react-pakistan/util-functions": "^1.24.10",
32
+ "@supabase/supabase-js": "^2.50.0",
33
+ "@tailwindcss/forms": "^0.5.10",
34
+ "@tailwindcss/postcss": "^4",
35
+ "@types/node": "^22",
36
+ "@types/react": "^19",
37
+ "@types/react-dom": "^19",
38
+ "@types/react-slick": "^0",
39
+ "dayjs": "^1.11.13",
40
+ "eslint": "^9",
41
+ "eslint-config-next": "15",
42
+ "husky": "^9",
43
+ "next": "^15",
44
+ "next-intl": "^4",
45
+ "react": "^19",
46
+ "react-copy-to-clipboard": "^5",
47
+ "react-dom": "^19",
48
+ "react-hot-toast": "^2",
49
+ "react-photo-view": "^1.2.7",
50
+ "react-slick": "^0",
51
+ "react-tooltip": "^5",
52
+ "rimraf": "^6.0.1",
53
+ "slick-carousel": "^1",
54
+ "tailwindcss": "^4",
55
+ "typescript": "^5",
56
+ "uuid": "^11.1.0",
57
+ "webp-converter-browser": "^1.0.4",
58
+ "zod": "^3"
59
+ }
60
+ }