@banch0u/core-project-test-repository 2.2.20 → 2.3.0

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.
@@ -0,0 +1,118 @@
1
+ import React, { useMemo } from "react";
2
+ var LicenseWatermark = function LicenseWatermark(_ref) {
3
+ var companyInfo = _ref.companyInfo,
4
+ pathname = _ref.pathname;
5
+ // ----------------------------
6
+ // URL → project mapping
7
+ // ----------------------------
8
+ var projectCodeFromUrl = useMemo(function () {
9
+ var path = (pathname || "").toLowerCase();
10
+ if (path.startsWith("/docflow")) return "docflow-api";
11
+ if (path.startsWith("/hr")) return "hr-api";
12
+ if (path.startsWith("/contracts")) return "contracts-api";
13
+ if (path.startsWith("/accounts")) return "accounts-api";
14
+ if (path.startsWith("/archive")) return "archive-api";
15
+ if (path.startsWith("/transport")) return "transport-api";
16
+ if (path.startsWith("/laboratory")) return "laboratory-api";
17
+ return null;
18
+ }, [pathname]);
19
+
20
+ // ----------------------------
21
+ // normalize company info
22
+ // ----------------------------
23
+ var rawProjects = useMemo(function () {
24
+ if (Array.isArray(companyInfo)) {
25
+ var _companyInfo$;
26
+ return companyInfo === null || companyInfo === void 0 || (_companyInfo$ = companyInfo[0]) === null || _companyInfo$ === void 0 ? void 0 : _companyInfo$.projects;
27
+ }
28
+ return companyInfo === null || companyInfo === void 0 ? void 0 : companyInfo.projects;
29
+ }, [companyInfo]);
30
+
31
+ // ----------------------------
32
+ // parse projects safely
33
+ // ----------------------------
34
+ var parseProjects = function parseProjects(raw) {
35
+ if (!raw || typeof raw !== "string") return [];
36
+ try {
37
+ var cleaned = raw.trim();
38
+ cleaned = cleaned.replace(/^.*?\[/, "[");
39
+ cleaned = cleaned.replace(/\}\}\\"?$/, "");
40
+ cleaned = cleaned.replace(/\}\}$/, "");
41
+ if (!cleaned.endsWith("]")) {
42
+ cleaned += "]";
43
+ }
44
+ return JSON.parse(cleaned);
45
+ } catch (err) {
46
+ console.error("Failed to parse projects:", err);
47
+ return [];
48
+ }
49
+ };
50
+ var projects = useMemo(function () {
51
+ return parseProjects(rawProjects);
52
+ }, [rawProjects]);
53
+
54
+ // ----------------------------
55
+ // find current project
56
+ // ----------------------------
57
+ var currentProject = useMemo(function () {
58
+ if (!Array.isArray(projects) || !projectCodeFromUrl) return null;
59
+ return projects.find(function (p) {
60
+ var _p$Code;
61
+ return (p === null || p === void 0 || (_p$Code = p.Code) === null || _p$Code === void 0 ? void 0 : _p$Code.toLowerCase().trim()) === projectCodeFromUrl.toLowerCase().trim();
62
+ });
63
+ }, [projects, projectCodeFromUrl]);
64
+
65
+ // ----------------------------
66
+ // license logic
67
+ // ----------------------------
68
+ var licenseStatus = useMemo(function () {
69
+ if (!(currentProject !== null && currentProject !== void 0 && currentProject.EndDate)) {
70
+ return {
71
+ status: "unknown"
72
+ };
73
+ }
74
+ var endDate = new Date(currentProject.EndDate);
75
+ var today = new Date();
76
+ var end = new Date(endDate.getFullYear(), endDate.getMonth(), endDate.getDate());
77
+ var now = new Date(today.getFullYear(), today.getMonth(), today.getDate());
78
+ var diffDays = Math.ceil((end - now) / (1000 * 60 * 60 * 24));
79
+ if (diffDays <= 0) {
80
+ return {
81
+ status: "expired",
82
+ text: "Lisenziya müddəti bitib",
83
+ color: "red"
84
+ };
85
+ }
86
+ if (diffDays <= 30) {
87
+ return {
88
+ status: "warning",
89
+ text: "Lisenziya m\xFCdd\u0259tinin bitm\u0259sin\u0259 ".concat(diffDays, " g\xFCn qal\u0131b"),
90
+ color: "yellow"
91
+ };
92
+ }
93
+ return {
94
+ status: "valid"
95
+ };
96
+ }, [currentProject]);
97
+
98
+ // ----------------------------
99
+ // render
100
+ // ----------------------------
101
+ if (licenseStatus.status === "valid") return null;
102
+ return /*#__PURE__*/React.createElement("div", {
103
+ style: {
104
+ position: "absolute",
105
+ top: 0,
106
+ left: 0,
107
+ background: licenseStatus.color,
108
+ fontSize: 18,
109
+ color: "#000",
110
+ width: "100%",
111
+ zIndex: 9999,
112
+ display: "flex",
113
+ justifyContent: "center",
114
+ alignItems: "center"
115
+ }
116
+ }, licenseStatus.status === "expired" ? "Lisenziya müddəti bitib" : licenseStatus.text);
117
+ };
118
+ export default LicenseWatermark;
@@ -3,10 +3,10 @@ import React, { useEffect, useState } from "react";
3
3
  import style from "./index.module.scss";
4
4
  import ProfileOptions from "../../components/ProfileOptions";
5
5
  import AppSelect from "./AppSelect";
6
- import { useDispatch } from "react-redux";
6
+ import { useDispatch, useSelector } from "react-redux";
7
7
  import { getLoginType } from "../../store/slices/auth";
8
8
  import { getCompanyInfo } from "../../store/slices/companyInfo";
9
- import { useSelector } from "react-redux";
9
+ import LicenseWatermark from "../../components/LicenseWatermark/LicenseWatermark";
10
10
  var Header = function Header() {
11
11
  var _companyInfo$;
12
12
  var _useState = useState(localStorage.getItem("theme") || "light"),
@@ -17,14 +17,14 @@ var Header = function Header() {
17
17
  var companyInfo = useSelector(function (state) {
18
18
  return state.companyInfo.companyInfo;
19
19
  });
20
- var updateTheme = function updateTheme() {
21
- var newTheme = localStorage.getItem("theme") || "light";
22
- setTheme(newTheme);
23
- };
20
+ var pathname = window.location.pathname;
24
21
  useEffect(function () {
25
- window.addEventListener("themeChange", updateTheme);
22
+ var handler = function handler() {
23
+ return setTheme(localStorage.getItem("theme") || "light");
24
+ };
25
+ window.addEventListener("themeChange", handler);
26
26
  return function () {
27
- return window.removeEventListener("themeChange", updateTheme);
27
+ return window.removeEventListener("themeChange", handler);
28
28
  };
29
29
  }, []);
30
30
  useEffect(function () {
@@ -34,7 +34,10 @@ var Header = function Header() {
34
34
  return /*#__PURE__*/React.createElement("header", {
35
35
  className: style.header,
36
36
  "data-no-invert": true
37
- }, /*#__PURE__*/React.createElement(AppSelect, {
37
+ }, /*#__PURE__*/React.createElement(LicenseWatermark, {
38
+ companyInfo: companyInfo,
39
+ pathname: pathname
40
+ }), /*#__PURE__*/React.createElement(AppSelect, {
38
41
  mainPage: companyInfo === null || companyInfo === void 0 || (_companyInfo$ = companyInfo[0]) === null || _companyInfo$ === void 0 ? void 0 : _companyInfo$.mainPage
39
42
  }), /*#__PURE__*/React.createElement(ProfileOptions, null));
40
43
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@banch0u/core-project-test-repository",
3
- "version": "2.2.20",
3
+ "version": "2.3.0",
4
4
  "description": "Shared core features for all projects",
5
5
  "main": "dist/index.js",
6
6
  "files": [
@@ -15,18 +15,18 @@
15
15
  "license": "MIT",
16
16
  "scripts": {
17
17
  "clean": "rimraf dist",
18
- "build": "npm run precheck && npm run clean && babel src --out-dir dist --copy-files",
19
- "watch": "chokidar \"src\" -i 'dist' -c \"npm run build && yalc push --force\"",
18
+ "build": "babel src --out-dir dist --copy-files",
19
+ "watch": "babel src --out-dir dist --copy-files --watch",
20
+ "watch:push": "chokidar \"dist/**/*\" -c \"yalc push --changed --verbose\"",
20
21
  "pull": "git pull",
21
- "dev": "npm run pull && npm run precheck && npm run watch",
22
- "precheck": "node compiler-checks.js",
23
- "publish:patch": "npm run build && npm version patch && npm publish",
24
- "publish:minor": "npm run build && npm version minor && npm publish",
25
- "publish:major": "npm run build && npm version major && npm publish"
22
+ "dev": "npm run pull && concurrently \"npm run watch\" \"npm run watch:push\"",
23
+ "push": "yalc push --changed --verbose",
24
+ "publish:patch": "npm run clean && npm run build && npm version patch && npm publish",
25
+ "publish:minor": "npm run clean && npm run build && npm version minor && npm publish",
26
+ "publish:major": "npm run clean && npm run build && npm version major && npm publish"
26
27
  },
27
28
  "dependencies": {
28
29
  "@ant-design/icons": "^6.0.0",
29
- "@banch0u/core-project-test-repository": "file:.yalc/@banch0u/core-project-test-repository",
30
30
  "@microsoft/signalr": "^8.0.7",
31
31
  "@pdftron/webviewer": "^11.2.0",
32
32
  "@reduxjs/toolkit": "^2.6.1",
@@ -56,6 +56,7 @@
56
56
  "@babel/preset-react": "^7.26.3",
57
57
  "babel-loader": "^9.2.1",
58
58
  "chokidar-cli": "^3.0.0",
59
+ "concurrently": "^9.2.1",
59
60
  "eslint": "^8.57.1",
60
61
  "eslint-import-resolver-node": "^0.3.9",
61
62
  "eslint-plugin-import": "^2.31.0",