spotlibs-components 0.1.10 → 0.1.12

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 (120) hide show
  1. package/dist/{chunk-OGJBPTUP.mjs → chunk-F6KSEYVB.mjs} +3 -3
  2. package/dist/{chunk-OGJBPTUP.mjs.map → chunk-F6KSEYVB.mjs.map} +1 -1
  3. package/dist/chunk-UFE7HFT2.mjs +60 -0
  4. package/dist/chunk-UFE7HFT2.mjs.map +1 -0
  5. package/dist/{chunk-NXFLMH2Q.mjs → chunk-YOSPWY5K.mjs} +3 -4
  6. package/dist/{chunk-NXFLMH2Q.mjs.map → chunk-YOSPWY5K.mjs.map} +1 -1
  7. package/dist/{atoms → components/atoms}/icons/index.mjs +2 -2
  8. package/dist/components/index.d.mts +449 -0
  9. package/dist/components/index.mjs +7053 -0
  10. package/dist/components/index.mjs.map +1 -0
  11. package/dist/{mui → components/mui}/index.mjs +1 -1
  12. package/dist/components/types.d.mts +4 -0
  13. package/dist/{types-B0iF5xX8.d.mts → types-D1akE7ak.d.mts} +334 -245
  14. package/dist/utils/index.d.mts +106 -0
  15. package/dist/utils/index.mjs +477 -0
  16. package/dist/utils/index.mjs.map +1 -0
  17. package/package.json +13 -2
  18. package/src/utils/admin-kuota-nasional/constant.d.ts +23 -0
  19. package/src/utils/admin-kuota-nasional/constant.js +95 -0
  20. package/src/utils/asset.d.ts +1 -0
  21. package/src/utils/asset.js +10 -0
  22. package/src/utils/booleanUtils.d.ts +2 -0
  23. package/src/utils/booleanUtils.js +19 -0
  24. package/src/utils/briguna-digital/constant.d.ts +2 -0
  25. package/src/utils/briguna-digital/constant.js +12 -0
  26. package/src/utils/compress.d.ts +2 -0
  27. package/src/utils/compress.js +24 -0
  28. package/src/utils/compressImage.d.ts +6 -0
  29. package/src/utils/compressImage.js +20 -0
  30. package/src/utils/constants.d.ts +5 -0
  31. package/src/utils/constants.js +20 -0
  32. package/src/utils/cookies.d.ts +19 -0
  33. package/src/utils/cookies.js +102 -0
  34. package/src/utils/crypto.d.ts +5 -0
  35. package/src/utils/crypto.js +104 -0
  36. package/src/utils/decodeString.d.ts +1 -0
  37. package/src/utils/decodeString.js +17 -0
  38. package/src/utils/disableFormElements.d.ts +5 -0
  39. package/src/utils/disableFormElements.js +19 -0
  40. package/src/utils/excelUtils.d.ts +25 -0
  41. package/src/utils/excelUtils.js +60 -0
  42. package/src/utils/exception.d.ts +19 -0
  43. package/src/utils/exception.js +86 -0
  44. package/src/utils/formatString.d.ts +25 -0
  45. package/src/utils/formatString.js +151 -0
  46. package/src/utils/formatters/account.d.ts +2 -0
  47. package/src/utils/formatters/account.js +98 -0
  48. package/src/utils/formatters/currency.d.ts +20 -0
  49. package/src/utils/formatters/currency.js +125 -0
  50. package/src/utils/formatters/date.d.ts +12 -0
  51. package/src/utils/formatters/date.js +219 -0
  52. package/src/utils/formatters/index.d.ts +47 -0
  53. package/src/utils/formatters/index.js +47 -0
  54. package/src/utils/formatters/string.d.ts +6 -0
  55. package/src/utils/formatters/string.js +114 -0
  56. package/src/utils/generateImportExcel.d.ts +35 -0
  57. package/src/utils/generateImportExcel.js +546 -0
  58. package/src/utils/generateTimestamp.d.ts +1 -0
  59. package/src/utils/generateTimestamp.js +4 -0
  60. package/src/utils/handleApiError.d.ts +1 -0
  61. package/src/utils/handleApiError.js +17 -0
  62. package/src/utils/index.d.ts +104 -0
  63. package/src/utils/index.js +92 -0
  64. package/src/utils/json.d.ts +4 -0
  65. package/src/utils/json.js +55 -0
  66. package/src/utils/localStorage.d.ts +1 -0
  67. package/src/utils/localStorage.js +8 -0
  68. package/src/utils/logger.d.ts +4 -0
  69. package/src/utils/logger.js +46 -0
  70. package/src/utils/schema/globalSchema.d.ts +8 -0
  71. package/src/utils/schema/globalSchema.js +10 -0
  72. package/src/utils/signature.d.ts +10 -0
  73. package/src/utils/signature.js +75 -0
  74. package/src/utils/specifics/korporasi/prakarsaKorporasiUtils.d.ts +5 -0
  75. package/src/utils/specifics/korporasi/prakarsaKorporasiUtils.js +87 -0
  76. package/src/utils/specifics/mikro/validationMaintenanceAgunanUtils.d.ts +2 -0
  77. package/src/utils/specifics/mikro/validationMaintenanceAgunanUtils.js +214 -0
  78. package/src/utils/static-data/korporasi/prakarsa/analisa-risiko-kredit-nasabah/analisa-kinerja-keuangan/listStaticData.js +290 -0
  79. package/src/utils/static-data/korporasi/prakarsa/appendix/proyeksi-laporan-arus-kas/listStaticData.js +7 -0
  80. package/src/utils/static-data/korporasi/prakarsa/appendix/proyeksi-laporan-keuangan/listStaticData.js +75 -0
  81. package/src/utils/static-data/korporasi/prakarsa/appendix/total-exposure-group/listStaticData.js +7 -0
  82. package/src/utils/static-data/korporasi/prakarsa/create/listStaticData.js +21 -0
  83. package/src/utils/static-data/korporasi/prakarsa/generals/listExcelConfigData.js +11 -0
  84. package/src/utils/static-data/korporasi/prakarsa/pengajuan-fasilitas-kredit/fasilitas-kredit/listStaticData.js +69 -0
  85. package/src/utils/static-data/korporasi-internasional/eksternal/listStaticData.js +193 -0
  86. package/src/utils/static-data/korporasi-internasional/master/listStaticData.js +24 -0
  87. package/src/utils/static-data/korporasi-internasional/uji-kepatuhan/listStaticData.js +250 -0
  88. package/src/utils/status.d.ts +37 -0
  89. package/src/utils/status.js +160 -0
  90. package/src/utils/store/adminKuotaNasional.js +7 -0
  91. package/src/utils/store/authStore.js +13 -0
  92. package/src/utils/store/bankGaransiStore.js +10 -0
  93. package/src/utils/store/korporasi/approval/interface/interfaceStore.js +10 -0
  94. package/src/utils/store/korporasi/general/generalKorporasiStore.js +13 -0
  95. package/src/utils/store/korporasi/loan-disbursement/loanDisbursementStore.js +77 -0
  96. package/src/utils/store/korporasi/prakarsa/fasilitas-kredit/fasilitasKreditStore.js +141 -0
  97. package/src/utils/store/migrasi-mandiri/migrasiMandiriStore.js +53 -0
  98. package/src/utils/store/monitoring-konsumer/monitoring-leads-KPP/monitoring-leads-kpp-internal.js +34 -0
  99. package/src/utils/store/prakarsaBankGaransiStore.js +21 -0
  100. package/src/utils/store/prognosa-crr/settingPrognosaROStore.js +9 -0
  101. package/src/utils/store/prognosaRMStore.js +30 -0
  102. package/src/utils/store/restrukStore.js +26 -0
  103. package/src/utils/store/verificationAccessLink.js +11 -0
  104. package/src/utils/store/warkat-bg-wholesale/warkatBgWholesaleStore.js +22 -0
  105. package/src/utils/stringUtils.d.ts +22 -0
  106. package/src/utils/stringUtils.js +226 -0
  107. package/src/utils/tipeBank.d.ts +3 -0
  108. package/src/utils/tipeBank.js +14 -0
  109. package/dist/index.css +0 -32
  110. package/dist/index.css.map +0 -1
  111. package/dist/index.d.mts +0 -1726
  112. package/dist/index.mjs +0 -18560
  113. package/dist/index.mjs.map +0 -1
  114. package/dist/types.d.mts +0 -4
  115. /package/dist/{atoms → components/atoms}/icons/index.d.mts +0 -0
  116. /package/dist/{atoms → components/atoms}/icons/index.mjs.map +0 -0
  117. /package/dist/{mui → components/mui}/index.d.mts +0 -0
  118. /package/dist/{mui → components/mui}/index.mjs.map +0 -0
  119. /package/dist/{types.mjs → components/types.mjs} +0 -0
  120. /package/dist/{types.mjs.map → components/types.mjs.map} +0 -0
@@ -0,0 +1,92 @@
1
+ /**
2
+ * Utils Entry Point
3
+ *
4
+ * Export semua utility functions yang bisa dipakai oleh microfrontend apps.
5
+ * Import di microfrontend: import { formatCurrency, formatAccountNumber } from "spotlibs-components/utils";
6
+ */
7
+
8
+ // Formatters (consolidated)
9
+ export {
10
+ formatAccountNumber,
11
+ formatNPWP,
12
+ formatCurrency,
13
+ formatRupiah,
14
+ formatNominal,
15
+ formatDigit,
16
+ toYearFirstDash,
17
+ toDateFirstSlash,
18
+ formatDateToDDSlashMMSlashYYYY,
19
+ formatDateToDDMMYYYY,
20
+ yearFirstDashToDateFirstDash,
21
+ yearFirstDashToDateFirstSlash,
22
+ dateFirstSlashToYearFirstDash,
23
+ sevenDigitToDateFirstSlash,
24
+ sevenDigitToYearFirstDash,
25
+ sevenDigitToDateFirstDash,
26
+ toDateTimeHourMinute,
27
+ ddmmyyToSlashDate,
28
+ formatResponseDesc,
29
+ titleCase,
30
+ snakeToCamelWithSpace,
31
+ stringToBoolean,
32
+ matchWiths,
33
+ maskString,
34
+ } from "./formatters";
35
+
36
+ // JSON utilities
37
+ export { parseJSON, jsonToStringLimiter, errorState, ascendingStringify } from "./json";
38
+
39
+ // Asset utility
40
+ export { callAsset } from "./asset";
41
+
42
+ // Boolean utilities
43
+ export { checkRoleUser, toggleUsingDummyWbenchEndpoint } from "./booleanUtils";
44
+
45
+ // Constants
46
+ export {
47
+ NOT_AUTHORIZE_RESPONSE_CODE,
48
+ PUBLIC_PATHS,
49
+ COOKIE_MAX_SIZE,
50
+ CLIENT_PUBLIC_API_ROUTES,
51
+ CLIENT_ALLOWED_ORIGINS,
52
+ } from "./constants";
53
+
54
+ // Disable form utilities
55
+ export { disableFormElements, disableFormBuilder } from "./disableFormElements";
56
+
57
+ // Generate timestamp
58
+ export { generateVcifId } from "./generateTimestamp";
59
+
60
+ // LocalStorage
61
+ export { getLocalStorageItem } from "./localStorage";
62
+
63
+ // Tipe Bank
64
+ export { getTipeBankKorporasi } from "./tipeBank";
65
+
66
+ // Exception
67
+ export {
68
+ HEADER_EXCEPTION,
69
+ ACCESS_EXCEPTION,
70
+ PARAMETER_EXCEPTION,
71
+ NOTFOUND_EXCEPTION,
72
+ INVALIDRULE_EXCEPTION,
73
+ THIRDPARTY_EXCEPTION,
74
+ WAITING_EXCEPTION,
75
+ UNSUPPORTED_EXCEPTION,
76
+ RUNTIME_EXCEPTION,
77
+ EXCEPTION_MESSAGES,
78
+ ApiException,
79
+ isExceptionCode,
80
+ getExceptionMessage,
81
+ } from "./exception";
82
+
83
+ // Format String (legacy exports - for backward compatibility)
84
+ export {
85
+ formatCurrency as formatCurrencyLegacy,
86
+ formatNominal as formatNominalLegacy,
87
+ dashedAccount,
88
+ dashedNPWP,
89
+ formatResponseDesc as formatResponseDescLegacy,
90
+ titleCase as titleCaseLegacy,
91
+ stringToBoolean as stringToBooleanLegacy,
92
+ } from "./formatString";
@@ -0,0 +1,4 @@
1
+ export declare function parseJSON(value: string): unknown;
2
+ export declare function jsonToStringLimiter(value?: unknown): string | null;
3
+ export declare function errorState(name: string, errors: unknown): unknown;
4
+ export declare function ascendingStringify(obj: unknown): string;
@@ -0,0 +1,55 @@
1
+ export function parseJSON(value) {
2
+ try {
3
+ return JSON.parse(value);
4
+ } catch (err) {
5
+ return value;
6
+ }
7
+ }
8
+
9
+ export function jsonToStringLimiter(value = null) {
10
+ try {
11
+ if (value) {
12
+ const convertData = JSON.stringify(value);
13
+ let newData = "";
14
+
15
+ if (convertData.length > 200) {
16
+ newData = convertData.substring(0, 200) + "***}";
17
+ } else {
18
+ newData = convertData;
19
+ }
20
+
21
+ return newData;
22
+ }
23
+
24
+ return null;
25
+ } catch (e) {
26
+ return e;
27
+ }
28
+ }
29
+
30
+ export function errorState(name, errors) {
31
+ const parts = name.split(".");
32
+ let value = errors;
33
+ for (let part of parts) {
34
+ if (!value) {
35
+ break;
36
+ }
37
+
38
+ const index = Number(part);
39
+ value = !isNaN(index) ? value[index] : value[part];
40
+ }
41
+
42
+ return value;
43
+ }
44
+
45
+ export function ascendingStringify(obj) {
46
+ if (Array.isArray(obj)) {
47
+ return '[' + obj.map(ascendingStringify).join(',') + ']';
48
+ } else if (obj && typeof obj === 'object') {
49
+ return '{' + Object.keys(obj).sort().map(
50
+ key => JSON.stringify(key) + ':' + ascendingStringify(obj[key])
51
+ ).join(',') + '}';
52
+ } else {
53
+ return JSON.stringify(obj);
54
+ }
55
+ }
@@ -0,0 +1 @@
1
+ export declare function getLocalStorageItem(key: string): unknown;
@@ -0,0 +1,8 @@
1
+ export function getLocalStorageItem(key) {
2
+ const value = localStorage.getItem(key);
3
+ try {
4
+ return JSON.parse(value);
5
+ } catch (err) {
6
+ return value;
7
+ }
8
+ }
@@ -0,0 +1,4 @@
1
+ export declare const loggerAPI: {
2
+ info(logData: Record<string, unknown>): void;
3
+ error(logData: Record<string, unknown>): void;
4
+ };
@@ -0,0 +1,46 @@
1
+ import fs from "fs";
2
+ import path from "path";
3
+ import dayjs from "dayjs";
4
+ import utc from "dayjs/plugin/utc";
5
+ import timezone from "dayjs/plugin/timezone";
6
+
7
+ dayjs.extend(utc);
8
+ dayjs.extend(timezone);
9
+
10
+ // Use process.cwd() for development, or /var/log for standalone production
11
+ const logDir = path.join(process.cwd(), "storage/logs");
12
+ const apiLogFilePath = path.join(logDir, "api.log");
13
+
14
+ // Ensure log directory exists
15
+ if (!fs.existsSync(logDir)) {
16
+ fs.mkdirSync(logDir, { recursive: true });
17
+ }
18
+
19
+ const formatLogMessage = (messageObject, type) => {
20
+ const now = dayjs().tz('Asia/Jakarta').format("YYYY-MM-DDTHH:mm:ss.SSSZ");
21
+ const data = { ...messageObject, time_stamp: now };
22
+ const structured = JSON.stringify(data);
23
+
24
+ return `[${now}] ::BrispotWebapp.${process.env.API_ENVIRONTMENT}.${type}:: ${structured}\n`;
25
+ };
26
+
27
+ const loggerAPI = {
28
+ info: (logData) => {
29
+ try {
30
+ const formatted = formatLogMessage(logData, "INFO");
31
+ fs.appendFileSync(apiLogFilePath, formatted, { encoding: "utf8" });
32
+ } catch (err) {
33
+ console.log("Failed to write log ", err);
34
+ }
35
+ },
36
+ error: (logData) => {
37
+ try {
38
+ const formatted = formatLogMessage(logData, "ERROR");
39
+ fs.appendFileSync(apiLogFilePath, formatted, { encoding: "utf8" });
40
+ } catch (err) {
41
+ console.log("Failed to write log ", err);
42
+ }
43
+ },
44
+ };
45
+
46
+ export { loggerAPI };
@@ -0,0 +1,8 @@
1
+ import type { ObjectSchema, NumberSchema } from 'yup';
2
+
3
+ export declare function createFieldOptionSchema(
4
+ fieldName: string,
5
+ labels: string
6
+ ): ObjectSchema<{ label: string; value: string }>;
7
+
8
+ export declare const norekSchema: NumberSchema;
@@ -0,0 +1,10 @@
1
+ import * as Yup from "yup";
2
+
3
+ export const createFieldOptionSchema = (fieldName, labels) => {
4
+ return Yup.object().shape({
5
+ label: Yup.string().required(`${labels} Label harus di isi!`), // Label harus di isi!
6
+ value: Yup.string().required(`${labels} Value harus di isi!`), // Value harus di isi!
7
+ }).nullable(true).typeError(`${labels} harus di isi!`); // Custom error message
8
+ };
9
+
10
+ export const norekSchema = Yup.number().test('len', 'No Rekening harus 15 digit', val => val?.toString()?.length === 15).required("No Rekening harus di isi!").nullable(true).typeError("No Rekening harus di isi!");
@@ -0,0 +1,10 @@
1
+ export declare function sumNumeric(str: string): number;
2
+ export declare function generateSignature(config: {
3
+ signConfigToken: string;
4
+ token: string;
5
+ body: unknown;
6
+ app: string;
7
+ contentType?: string;
8
+ buffer?: Buffer;
9
+ endpoint: string;
10
+ }): Promise<string>;
@@ -0,0 +1,75 @@
1
+ import CryptoJS from "crypto-js";
2
+
3
+ export function sumNumeric(str) {
4
+ let sum = 0;
5
+ for (let i = 0; i < str.length; i++) {
6
+ if (str[i] >= "0" && str[i] <= "9") {
7
+ sum += parseInt(str[i]);
8
+ }
9
+ }
10
+ return sum;
11
+ }
12
+
13
+ export async function generateSignature({ signConfigToken, token, body, app, contentType, buffer, endpoint }) {
14
+ let bodyString;
15
+
16
+ if(contentType?.includes('multipart/form-data')){
17
+ const boundaryMatch = contentType.match(/boundary=(.+)$/);
18
+
19
+ if (!boundaryMatch) {
20
+ throw new Error("No boundary in Content-Type");
21
+ }
22
+
23
+ const boundary = `--${boundaryMatch[1]}`;
24
+ const parts = buffer.toString().split(boundary).filter(Boolean);
25
+ const fields = {};
26
+
27
+ for (let part of parts) {
28
+ if (part === '--\r\n' || part === '--') continue;
29
+ const [rawHeaders, ...bodyParts] = part.split('\r\n\r\n');
30
+ const body = bodyParts.join('\r\n\r\n').trim();
31
+ if (!rawHeaders.includes('filename=')) {
32
+ const nameMatch = rawHeaders.match(/name="([^"]+)"/);
33
+ if (nameMatch) {
34
+ const name = nameMatch[1];
35
+ fields[name] = body;
36
+ }
37
+ }
38
+ }
39
+ bodyString = JSON.stringify(fields);
40
+ } else {
41
+ bodyString = (
42
+ body === undefined ||
43
+ body === null ||
44
+ body === '' ||
45
+ (Array.isArray(body) && body.length === 0)
46
+ )
47
+ ? JSON.stringify({})
48
+ : (typeof body === 'string' ? body : JSON.stringify(body));
49
+ }
50
+
51
+ const base64Timestamp = btoa(Date.now().toString());
52
+ const characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
53
+ let generateString = '';
54
+
55
+ const charactersLength = characters.length;
56
+ for (let i = 0; i < 10; i++) {
57
+ generateString += characters.charAt(Math.floor(Math.random() * charactersLength));
58
+ }
59
+ const randomString = btoa(generateString);
60
+ // eslint-disable-next-line no-control-regex
61
+ const replaceBodyString = /\\u[0-9a-fA-F]{4}|[^\x00-\x7F]|\\|\s+/g.test(bodyString) ? bodyString.replace(/\\u[0-9a-fA-F]{4}|[^\x00-\x7F]|\\|\s+/g, '') : bodyString;
62
+
63
+ const plaintext = signConfigToken + token + replaceBodyString + app + endpoint + base64Timestamp + randomString.replace(/=/g, "");
64
+ const numericSum = sumNumeric(btoa(replaceBodyString));
65
+ const tsIndex = numericSum % 40;
66
+
67
+ let signature = btoa(CryptoJS.SHA256(plaintext).toString(CryptoJS.enc.Hex));
68
+ signature = signature.substring(0, 40);
69
+ signature =
70
+ signature.substring(0, tsIndex) +
71
+ base64Timestamp.replace(/=/g, "") +
72
+ signature.substring(tsIndex) + randomString.replace(/=/g, "");
73
+
74
+ return signature;
75
+ }
@@ -0,0 +1,5 @@
1
+ export declare function getMirroringBasePath(router: string): string;
2
+ export declare function mappingMenuPencairan(asPath?: string): string | null;
3
+ export declare function scrollToTop(): void;
4
+ export declare function mappingProsesDisbursement(proses: string): string;
5
+ export declare function mappingLabelNorek(proses: string): string;
@@ -0,0 +1,87 @@
1
+ export const getMirroringBasePath = (router) => {
2
+
3
+ const listBaseRoute = ['monitoring', 'approval']
4
+
5
+ let routerSplit = router.split('/').filter(Boolean)
6
+ let basePath = routerSplit.slice(0, 2).join('/')
7
+ let categoryPath = listBaseRoute.includes(routerSplit[0]) ? `${basePath}/korporasi` : basePath
8
+ return categoryPath
9
+
10
+ }
11
+
12
+ function normalizePath(asPath = "") {
13
+ const queryIndex = asPath.indexOf("?");
14
+ const hashIndex = asPath.indexOf("#");
15
+ const cutIndex = Math.min(
16
+ queryIndex === -1 ? asPath.length : queryIndex,
17
+ hashIndex === -1 ? asPath.length : hashIndex
18
+ );
19
+
20
+ let cleanPath = asPath.slice(0, cutIndex);
21
+
22
+ if (!cleanPath.startsWith("/")) {
23
+ cleanPath = "/" + cleanPath;
24
+ }
25
+
26
+ let firstNonSlashPos = 1;
27
+ while (firstNonSlashPos < cleanPath.length && cleanPath[firstNonSlashPos] === "/") {
28
+ firstNonSlashPos++;
29
+ }
30
+ if (firstNonSlashPos > 1) {
31
+ cleanPath = "/" + cleanPath.slice(firstNonSlashPos);
32
+ }
33
+
34
+ let lastNonSlashPos = cleanPath.length - 1;
35
+ while (lastNonSlashPos > 0 && cleanPath[lastNonSlashPos] === "/") {
36
+ lastNonSlashPos--;
37
+ }
38
+ cleanPath = cleanPath.slice(0, lastNonSlashPos + 1);
39
+
40
+ return cleanPath.toLowerCase();
41
+ }
42
+
43
+ export const mappingMenuPencairan = (asPath = "/") => {
44
+ const normalizedPath = normalizePath(asPath ?? "/");
45
+
46
+ const routeMap = {
47
+ permohonan_pencairan: "/loan-disbursement/cash-loan",
48
+ approval_permohonan_pencairan: "/loan-disbursement/approval-cash-loan",
49
+ verifikasi_pencairan: "/review/verifikasi-pencairan",
50
+ approval_verifikasi_pencairan: "/approval/instruksi-pencairan",
51
+ verifikasi_LD: "/review/verifikasi-loan-disbursement",
52
+ approval_verifikasi_LD: "/approval/loan-disbursement",
53
+ };
54
+
55
+ for (const [menuKey, routePattern] of Object.entries(routeMap)) {
56
+ const normalizedPattern = normalizePath(routePattern);
57
+ if (
58
+ normalizedPath === normalizedPattern ||
59
+ normalizedPath.startsWith(normalizedPattern + "/")
60
+ ) {
61
+ return menuKey;
62
+ }
63
+ }
64
+ return null;
65
+ };
66
+
67
+ export const scrollToTop = () => {
68
+ if (typeof window === 'undefined') return;
69
+ window.scrollTo({ top: 0, behavior: 'smooth' });
70
+ };
71
+
72
+ const prosesDisbursementLabel = {
73
+ rekening_created: { title: "rekening sudah ada sebelumnya", rekening: "No. rekening pinjaman" },
74
+ create_rekening: { title: "membuat rekening pinjaman", rekening: "No. rekening pinjaman" },
75
+ activation_loan_account: { title: "Aktivasi rekening pinjaman", rekening: "No. rekening pinjaman" },
76
+ transfer_lrk_to_casa: { title: "kirim dari rekening pinjaman ke rekening debitur/vendor", rekening: "No. rekening vendor / supplier" },
77
+ transfer_lrk_to_ia: { title: "kirim dari rekening pinjaman ke rekening IA", rekening: "No. rekening IA" },
78
+ transfer_lrk_to_ca: { title: "kirim dari rekening pinjaman ke rekening escrow", rekening: "No. rekening escrow" },
79
+ transfer_ca_to_casa: { title: "kirim dari rekening escrow ke rekening debitur/vendor", rekening: "No. rekening vendor / supplier" },
80
+ transfer_ca_to_ia: { title: "kirim dari rekening escrow ke rekening IA", rekening: "No. rekening IA" },
81
+ };
82
+
83
+ export const mappingProsesDisbursement = (proses) =>
84
+ prosesDisbursementLabel?.[proses]?.title ?? "-";
85
+
86
+ export const mappingLabelNorek = (proses) =>
87
+ prosesDisbursementLabel?.[proses]?.rekening ?? "-";
@@ -0,0 +1,2 @@
1
+ export declare function validateFormAgunanInput(data: unknown, res: unknown): boolean;
2
+ export declare function validateInquirySA(data: unknown, res: unknown): boolean | undefined;
@@ -0,0 +1,214 @@
1
+ export function validateFormAgunanInput(data,res) {
2
+
3
+ if (!['tambah_data', 'ubah_data', 'hapus_data'].includes(data?.jenis_pengajuan)){
4
+ res.status(400).json({ message: "Jenis Pengajuan tidak Valid" });
5
+ return true;
6
+ }
7
+
8
+ if(data?.norek_pinjaman && !/^\d+$/.test(data?.norek_pinjaman) || data?.norek_pinjaman.length !== 15){
9
+ res.status(400).json({ message: "No Rekening Pinjaman harus berupa angka dengan panjang 15 digit" });
10
+ return true;
11
+ }
12
+
13
+ if(data?.branch && !/^\d+$/.test(data?.branch)){
14
+ res.status(400).json({ message: "Branch harus berupa angka dan harus sesuai dengan cabang anda" });
15
+ return true;
16
+ }
17
+
18
+ if(data?.klasifikasi_agunan && !['Pokok','Tambahan'].includes(data?.klasifikasi_agunan) || !/^[a-zA-Z]+$/.test(data?.klasifikasi_agunan)){
19
+ res.status(400).json({ message: "Klasifikasi Agunan tidak Valid" });
20
+ return true;
21
+ }
22
+
23
+ if(data?.jenis_agunan && !/^[a-zA-Z]+$/.test(data?.jenis_agunan)){
24
+ res.status(400).json({ message: "Jenis Agunan tidak Valid" });
25
+ return true;
26
+ }
27
+
28
+ if(data?.id_aplikasi && !/^\d+$/.test(data?.id_aplikasi)){
29
+ res.status(400).json({ message: "ID Aplikasi Tidak Valid" });
30
+ return true;
31
+ }
32
+
33
+ if(data?.id_jenis_agunan && !/^\d+$/.test(data?.id_jenis_agunan)){
34
+ res.status(400).json({ message: "ID Jenis Agunan Tidak Valid" });
35
+ return true;
36
+ }
37
+
38
+ if (data?.id_jenis_agunan && typeof data?.id_jenis_agunan !== 'number') {
39
+ res.status(400).json({ message: "ID Jenis Agunan Tidak Valid" });
40
+ return true;
41
+ }
42
+
43
+ if(data?.cif_las && !/^\d+$/.test(data?.cif_las)){
44
+ res.status(400).json({ message: "CIF LAS Tidak Valid" });
45
+ return true;
46
+ }
47
+
48
+ if(data?.id_kredit && typeof data?.id_kredit !== 'number'){
49
+ res.status(400).json({ message: "ID Kredit Tidak Valid" });
50
+ return true;
51
+ }
52
+
53
+ const detail_agunan = data?.detail_agunan;
54
+
55
+ if (detail_agunan?.norek_simpanan !== undefined && detail_agunan?.norek_simpanan !== null) {
56
+ if (!/^\d+$/.test(detail_agunan?.norek_simpanan) || detail_agunan?.norek_simpanan.length !== 15) {
57
+ res.status(400).json({ message: "No Rekening Simpanan harus berupa angka dengan panjang 15 digit" });
58
+ return true;
59
+ }
60
+ }
61
+
62
+
63
+ if(detail_agunan?.deskripsi_agunan && !/^[a-zA-Z0-9\s]+$/.test(detail_agunan?.deskripsi_agunan)){
64
+ res.status(400).json({ message: "Deskripsi Agunan tidak Valid" });
65
+ return true;
66
+ }
67
+
68
+ if (detail_agunan?.tipe_kas !== undefined && typeof detail_agunan?.tipe_kas !== "string") {
69
+ res.status(400).json({ message: "Tipe Kas harus berupa string" });
70
+ return true;
71
+ }
72
+
73
+ if(detail_agunan?.mata_uang && !['IDR','USD','JPY','SGD','EUR'].includes(detail_agunan?.mata_uang) || !/^[a-zA-Z]+$/.test(detail_agunan?.mata_uang)){
74
+ res.status(400).json({ message: "Mata Uang tidak Valid" });
75
+ return true;
76
+ }
77
+
78
+ if(detail_agunan?.nomor_bukti_kepemilikan && !/^\d+$/.test(detail_agunan?.nomor_bukti_kepemilikan)){
79
+ res.status(400).json({ message: "Nomor Bukti Kepemilikan Tidak Valid" });
80
+ return true;
81
+ }
82
+
83
+ if(detail_agunan?.tgl_bukti_kepemilikan && !/^[\d-]+$/.test(detail_agunan?.tgl_bukti_kepemilikan)){
84
+ res.status(400).json({ message: "Tanggal Bukti Kepemilikan Tidak Valid" });
85
+ return true;
86
+ }
87
+
88
+ if(detail_agunan?.jangka_waktu && !/^\d+$/.test(detail_agunan?.jangka_waktu)){
89
+ res.status(400).json({ message: "Jangka Waktu Tidak Valid" });
90
+ return true;
91
+ }
92
+
93
+ if(detail_agunan?.tgl_jatuh_tempo && !/^[\d-]+$/.test(detail_agunan?.tgl_jatuh_tempo)){
94
+ res.status(400).json({ message: "Tanggal Jatuh Tempo Tidak Valid" });
95
+ return true;
96
+ }
97
+
98
+ if(detail_agunan?.perpanjangan && !['Y','N'].includes(detail_agunan?.perpanjangan)){
99
+ res.status(400).json({ message: "Perpanjangan tidak Valid" });
100
+ return true;
101
+ }
102
+
103
+
104
+ if (detail_agunan?.nominal_agunan && !/^[\d.,]+$/.test(detail_agunan?.nominal_agunan)) {
105
+ res.status(400).json({ message: "Nominal Agunan Tidak Valid" });
106
+ return true;
107
+ }
108
+
109
+ if( detail_agunan?.atas_nama_pemilik && !/^[a-zA-Z\s]+$/.test(detail_agunan?.atas_nama_pemilik)){
110
+ res.status(400).json({ message: "Atas Nama Pemilik tidak Valid" });
111
+ return true;
112
+ }
113
+
114
+ const detail_pengikatan = data?.detail_pengikatan;
115
+
116
+ if( detail_pengikatan?.penilai_agunan && !['bank','independent'].includes(detail_pengikatan?.penilai_agunan) || !/^[a-zA-Z]+$/.test(detail_pengikatan?.penilai_agunan)){
117
+ res.status(400).json({ message: "Penilai Agunan tidak Valid" });
118
+ return true;
119
+ }
120
+
121
+ if (
122
+ typeof detail_pengikatan?.status_kepemilikan_agunan !== "string" ||
123
+ detail_pengikatan?.status_kepemilikan_agunan.trim() === ""
124
+ ) {
125
+ res.status(400).json({ message: "Status Kepemilikan harus berupa string dan tidak boleh kosong" });
126
+ return true;
127
+ }
128
+
129
+ if(detail_pengikatan?.bank_penerbit && !/^[0-9]+$/.test(detail_pengikatan?.bank_penerbit)){
130
+ res.status(400).json({ message: "Bank Penerbit Tidak Valid" });
131
+ return true;
132
+ }
133
+
134
+ if(detail_pengikatan?.bank_penerbit_desc && !/^[a-zA-Z\s]+$/.test(detail_pengikatan?.bank_penerbit_desc)){
135
+ res.status(400).json({ message: "Bank Penerbit Deskripsi Tidak Valid" });
136
+ return true;
137
+ }
138
+
139
+ if(detail_pengikatan?.jenis_pengikatan && !/^[0-9]+$/.test(detail_pengikatan?.jenis_pengikatan)){
140
+ res.status(400).json({ message: "Jenis Pengikatan Tidak Valid" });
141
+ return true;
142
+ }
143
+
144
+ if (detail_pengikatan?.jenis_pengikatan_desc && !/^[a-zA-Z\s]+$/.test(detail_pengikatan?.jenis_pengikatan_desc)) {
145
+ res.status(400).json({ message: "Jenis Pengikatan Deskripsi Tidak Valid" });
146
+ return true;
147
+ }
148
+
149
+ if (detail_pengikatan?.nilai_pengikatan_baru && !/^\d+$/.test(detail_pengikatan?.nilai_pengikatan_baru)) {
150
+ res.status(400).json({ message: "Nilai Pengikatan Baru Tidak Valid" });
151
+ return true;
152
+ }
153
+
154
+ if (detail_pengikatan?.no_bukti_pengikatan && !/^\d+$/.test(detail_pengikatan?.no_bukti_pengikatan)) {
155
+ res.status(400).json({ message: "No Bukti Pengikatan Tidak Valid" });
156
+ return true;
157
+ }
158
+
159
+ if (detail_pengikatan?.tgl_bukti_pengikatan && !/^[\d-]+$/.test(detail_pengikatan?.tgl_bukti_pengikatan)) {
160
+ res.status(400).json({ message: "Tanggal Bukti Pengikatan Tidak Valid" });
161
+ return true;
162
+ }
163
+
164
+ const detail_alamat = data?.detail_alamat;
165
+
166
+ if (detail_alamat?.alamat_pemilik && !/^[a-zA-Z0-9\s.,-]+$/.test(detail_alamat?.alamat_pemilik)) {
167
+ res.status(400).json({ message: "Alamat Pemilik tidak Valid" });
168
+ return true;
169
+ }
170
+
171
+ if (detail_alamat?.kel_desa && !/^[a-zA-Z\s]+$/.test(detail_alamat?.kel_desa)) {
172
+ res.status(400).json({ message: "Kelurahan/Desa tidak Valid" });
173
+ return true;
174
+ }
175
+
176
+ if ( detail_alamat?.kecamatan && !/^[a-zA-Z\s]+$/.test(detail_alamat?.kecamatan)) {
177
+ res.status(400).json({ message: "Kecamatan tidak Valid" });
178
+ return true;
179
+ }
180
+
181
+ if (detail_alamat?.lokasi_dati2 &&!/^[a-zA-Z\s.,]+$/.test(detail_alamat?.lokasi_dati2)) {
182
+ res.status(400).json({ message: "Lokasi DATI2 tidak Valid" });
183
+ return true;
184
+ }
185
+
186
+ if ( detail_alamat?.kode_dati2 && !/^\d+$/.test(detail_alamat?.kode_dati2)) {
187
+ res.status(400).json({ message: "Kode DATI2 tidak Valid" });
188
+ return true;
189
+ }
190
+
191
+ if ( detail_alamat?.paripasu && !['true', 'false'].includes(detail_alamat?.paripasu)) {
192
+ res.status(400).json({ message: "Paripasu tidak Valid" });
193
+ return true;
194
+ }
195
+
196
+ if (detail_alamat?.nilai_paripasu_agunan_bank && !/^\d+$/.test(detail_alamat?.nilai_paripasu_agunan_bank)) {
197
+ res.status(400).json({ message: "Nilai Paripasu tidak Valid" });
198
+ return true;
199
+ }
200
+
201
+ if ( detail_alamat?.eligibility && !['Eligible', 'Non Eligible'].includes(detail_alamat?.eligibility)) {
202
+ res.status(400).json({ message: "Eligibility tidak Valid" });
203
+ return true;
204
+ }
205
+
206
+ return false;
207
+ }
208
+
209
+ export function validateInquirySA(data, res) {
210
+ if( data?.remark2 && !/^[a-zA-Z]+$/.test(data?.remark2)){
211
+ res.status(400).json({ message: "Remark 2 tidak Valid" });
212
+ return true;
213
+ }
214
+ }