diff --git a/cope2n-fe/package-lock.json b/cope2n-fe/package-lock.json index fe10c5d..0991e8f 100644 --- a/cope2n-fe/package-lock.json +++ b/cope2n-fe/package-lock.json @@ -20,6 +20,7 @@ "history": "^5.3.0", "lodash-es": "^4.17.21", "mousetrap": "^1.6.5", + "process": "^0.11.10", "react": "^18.2.0", "react-chartjs-2": "^5.2.0", "react-dom": "^18.2.0", @@ -41,7 +42,7 @@ "@tanstack/react-query-devtools": "^4.20.4", "@types/babel-plugin-macros": "^2.8.4", "@types/lodash-es": "^4.17.6", - "@types/node": "^18.11.18", + "@types/node": "^18.19.12", "@types/react": "^18.0.20", "@types/react-dom": "^18.0.10", "@types/uuid": "^9.0.1", @@ -4418,9 +4419,9 @@ } }, "node_modules/@types/node": { - "version": "18.19.11", - "resolved": "https://registry.npmjs.org/@types/node/-/node-18.19.11.tgz", - "integrity": "sha512-hzdHPKpDdp5bEcRq1XTlZ2ntVjLcHCTV73dEcGg02eSY/+9AZ+jlfz6i00+zOrunMWenjHuI49J8J7Y9uz50JQ==", + "version": "18.19.12", + "resolved": "https://registry.npmjs.org/@types/node/-/node-18.19.12.tgz", + "integrity": "sha512-uLcpWEAvatBEubmgCMzWforZbAu1dT9syweWnU3/DNwbeUBq2miP5nG8Y4JL9MDMKWt+7Yv1CSvA8xELdEl54w==", "dev": true, "dependencies": { "undici-types": "~5.26.4" @@ -9491,6 +9492,14 @@ "integrity": "sha512-w2GsyukL62IJnlaff/nRegPQR94C/XXamvMWmSHRJ4y7Ts/4ocGRmTHvOs8PSE6pB3dWOrD/nueuU5sduBsQ4w==", "dev": true }, + "node_modules/process": { + "version": "0.11.10", + "resolved": "https://registry.npmjs.org/process/-/process-0.11.10.tgz", + "integrity": "sha512-cdGef/drWFoydD1JsMzuFf8100nZl+GT+yacc2bEced5f9Rjk4z+WtFUTBu9PhOi9j/jfmBPu0mMEY4wIdAF8A==", + "engines": { + "node": ">= 0.6.0" + } + }, "node_modules/prop-types": { "version": "15.8.1", "resolved": "https://registry.npmjs.org/prop-types/-/prop-types-15.8.1.tgz", diff --git a/cope2n-fe/package.json b/cope2n-fe/package.json index 2c00a6a..4054fdc 100644 --- a/cope2n-fe/package.json +++ b/cope2n-fe/package.json @@ -2,8 +2,8 @@ "name": "sbt-ui", "version": "0.1.0", "scripts": { - "start": "npm run extract && npm run compile && vite --host", - "build": "npm run extract && npm run compile && tsc && vite build", + "start": "NODE_ENV=development npm run extract && npm run compile && vite --host", + "build": "NODE_ENV=production npm run extract && npm run compile && tsc && vite build", "serve": "vite preview", "extract": "lingui extract --clean", "compile": "lingui compile", @@ -38,6 +38,7 @@ "history": "^5.3.0", "lodash-es": "^4.17.21", "mousetrap": "^1.6.5", + "process": "^0.11.10", "react": "^18.2.0", "react-chartjs-2": "^5.2.0", "react-dom": "^18.2.0", @@ -59,7 +60,7 @@ "@tanstack/react-query-devtools": "^4.20.4", "@types/babel-plugin-macros": "^2.8.4", "@types/lodash-es": "^4.17.6", - "@types/node": "^18.11.18", + "@types/node": "^18.19.12", "@types/react": "^18.0.20", "@types/react-dom": "^18.0.10", "@types/uuid": "^9.0.1", diff --git a/cope2n-fe/src/components/report-detail/report-overview-table.tsx b/cope2n-fe/src/components/report-detail/report-overview-table.tsx index 2102e35..3f5f813 100644 --- a/cope2n-fe/src/components/report-detail/report-overview-table.tsx +++ b/cope2n-fe/src/components/report-detail/report-overview-table.tsx @@ -108,10 +108,10 @@ const columns: TableColumnsType = [ key: 'snImeiAAR', width: '130px', render: (_, record) => { - const isAbnormal = record.snImeiAAR < 98; + const isAbnormal = record.snImeiAAR * 100 < 98; return ( - {record.snImeiAAR.toFixed(2)} + {(record.snImeiAAR * 100).toFixed(2)} ); }, @@ -122,10 +122,10 @@ const columns: TableColumnsType = [ key: 'purchaseDateAAR', width: '130px', render: (_, record) => { - const isAbnormal = record.purchaseDateAAR < 98; + const isAbnormal = record.purchaseDateAAR * 100 < 98; return ( - {record.purchaseDateAAR.toFixed(2)} + {(record.purchaseDateAAR * 100).toFixed(2)} ); }, @@ -136,10 +136,10 @@ const columns: TableColumnsType = [ key: 'retailerNameAAR', width: '130px', render: (_, record) => { - const isAbnormal = record.retailerNameAAR < 98; + const isAbnormal = record.retailerNameAAR * 100 < 98; return ( - {record.retailerNameAAR.toFixed(2)} + {(record.retailerNameAAR * 100).toFixed(2)} ); }, @@ -356,10 +356,10 @@ const ReportOverViewTable: React.FC = ({ key: 'snImeiAAR', width: '130px', render: (_, record) => { - const isAbnormal = record.snImeiAAR < 98; + const isAbnormal = record.snImeiAAR * 100 < 98; return ( - {record.snImeiAAR.toFixed(2)} + {(record.snImeiAAR * 100).toFixed(2)} ); }, @@ -370,10 +370,10 @@ const ReportOverViewTable: React.FC = ({ key: 'purchaseDateAAR', width: '130px', render: (_, record) => { - const isAbnormal = record.purchaseDateAAR < 98; + const isAbnormal = record.purchaseDateAAR * 100 < 98; return ( - {record.purchaseDateAAR.toFixed(2)} + {(record.purchaseDateAAR * 100).toFixed(2)} ); }, @@ -384,10 +384,10 @@ const ReportOverViewTable: React.FC = ({ key: 'retailerNameAAR', width: '130px', render: (_, record) => { - const isAbnormal = record.retailerNameAAR < 98; + const isAbnormal = record.retailerNameAAR * 100 < 98; return ( - {record.retailerNameAAR.toFixed(2)} + {(record.retailerNameAAR * 100).toFixed(2)} ); }, diff --git a/cope2n-fe/src/locales/en/messages.json b/cope2n-fe/src/locales/en/messages.json index 958b243..b0999d4 100644 --- a/cope2n-fe/src/locales/en/messages.json +++ b/cope2n-fe/src/locales/en/messages.json @@ -7,7 +7,6 @@ "Download Report": "Download Report", "Email format is not correct": "Email format is not correct", "English": "English", - "Go to Report page": "Go to Report page", "Language": "Language", "Login": "Login", "Logout": "Logout", diff --git a/cope2n-fe/src/locales/vi/messages.json b/cope2n-fe/src/locales/vi/messages.json index 912f6b4..25d7426 100644 --- a/cope2n-fe/src/locales/vi/messages.json +++ b/cope2n-fe/src/locales/vi/messages.json @@ -7,7 +7,6 @@ "Download Report": "", "Email format is not correct": "Định dạng email không hợp lệ", "English": "Tiếng Anh", - "Go to Report page": "", "Language": "Ngôn ngữ", "Login": "Đăng nhập", "Logout": "Đăng xuất", diff --git a/cope2n-fe/src/pages/reports/report_detail/index.tsx b/cope2n-fe/src/pages/reports/report_detail/index.tsx index 589d33a..443cf51 100644 --- a/cope2n-fe/src/pages/reports/report_detail/index.tsx +++ b/cope2n-fe/src/pages/reports/report_detail/index.tsx @@ -81,11 +81,11 @@ const columns: TableColumnsType = [ dataIndex: 'IMEI1 Accuracy', key: 'IMEI1 Accuracy', render: (_, record) => { - const isAbnormal = Number(record['IMEI1 Accuracy']) < 25; + const isAbnormal = Number(record['IMEI1 Accuracy']) * 100 < 25; return ( {record['IMEI1 Accuracy'] && - Number(record['IMEI1 Accuracy']).toFixed(2)} + (Number(record['IMEI1 Accuracy']) * 100).toFixed(2)} ); }, @@ -106,11 +106,12 @@ const columns: TableColumnsType = [ dataIndex: 'Invoice_Purchase Date Accuracy', key: 'Invoice_Purchase Date Accuracy', render: (_, record) => { - const isAbnormal = Number(record['Invoice_Purchase Date Accuracy']) < 25; + const isAbnormal = + Number(record['Invoice_Purchase Date Accuracy']) * 100 < 25; return ( {record['Invoice_Purchase Date Accuracy'] && - Number(record['Invoice_Purchase Date Accuracy']).toFixed(2)} + (Number(record['Invoice_Purchase Date Accuracy']) * 100).toFixed(2)} ); }, @@ -131,11 +132,11 @@ const columns: TableColumnsType = [ dataIndex: 'Invoice_Retailer Accuracy', key: 'Invoice_Retailer Accuracy', render: (_, record) => { - const isAbnormal = Number(record['Invoice_Retailer Accuracy']) < 25; + const isAbnormal = Number(record['Invoice_Retailer Accuracy']) * 100 < 25; return ( {record['Invoice_Retailer Accuracy'] && - Number(record['Invoice_Retailer Accuracy']).toFixed(2)} + (Number(record['Invoice_Retailer Accuracy']) * 100).toFixed(2)} ); }, @@ -145,11 +146,11 @@ const columns: TableColumnsType = [ dataIndex: 'Retailer_Revised Accuracy', key: 'Retailer_Revised Accuracy', render: (_, record) => { - const isAbnormal = Number(record['Retailer_Revised Accuracy']) < 25; + const isAbnormal = Number(record['Retailer_Revised Accuracy']) * 100 < 25; return ( {record['Retailer_Revised Accuracy'] && - Number(record['Retailer_Revised Accuracy']).toFixed(2)} + (Number(record['Retailer_Revised Accuracy']) * 100).toFixed(2)} ); }, @@ -159,11 +160,11 @@ const columns: TableColumnsType = [ dataIndex: 'OCR Image Accuracy', key: 'OCR Image Accuracy', render: (_, record) => { - const isAbnormal = Number(record['OCR Image Accuracy']) < 25; + const isAbnormal = Number(record['OCR Image Accuracy']) * 100 < 25; return ( {record['OCR Image Accuracy'] && - Number(record['OCR Image Accuracy']).toFixed(2)} + (Number(record['OCR Image Accuracy']) * 100).toFixed(2)} ); }, diff --git a/cope2n-fe/src/request/api.ts b/cope2n-fe/src/request/api.ts index cb721f2..dbe3a29 100644 --- a/cope2n-fe/src/request/api.ts +++ b/cope2n-fe/src/request/api.ts @@ -3,22 +3,26 @@ import { t } from '@lingui/macro'; import { notification } from 'antd'; import axios, { AxiosError, HttpStatusCode } from 'axios'; import { getLocale } from 'i18n'; +import process from 'process'; import { queryClient } from 'queries'; import { ErrorData } from 'utils/error-handler'; +const environment = process.env.NODE_ENV; const AXIOS_TIMEOUT_MS = 30 * 60 * 1000; // This config sastified long-live upload file request const EXPIRED_PASSWORD_SIGNAL = 'expired_password'; export const API = axios.create({ timeout: AXIOS_TIMEOUT_MS, - baseURL: 'http://42.96.42.13:9000/api', + baseURL: + environment === 'development' ? 'http://42.96.42.13:9000/api' : '/api', maxContentLength: Number.MAX_SAFE_INTEGER, maxBodyLength: Number.MAX_SAFE_INTEGER, }); export const PublicAPI = axios.create({ timeout: AXIOS_TIMEOUT_MS, - baseURL: 'http://42.96.42.13:9000/api', + baseURL: + environment === 'development' ? 'http://42.96.42.13:9000/api' : '/api', }); // interceptor to handle locale header diff --git a/node_modules/.package-lock.json b/node_modules/.package-lock.json new file mode 100644 index 0000000..d2d5a1f --- /dev/null +++ b/node_modules/.package-lock.json @@ -0,0 +1,6 @@ +{ + "name": "sbt-idp", + "lockfileVersion": 3, + "requires": true, + "packages": {} +}