perf(logs): remove console.log

This commit is contained in:
Tran Anh Tuan
2025-11-21 14:27:00 +07:00
parent 46aaf67a71
commit 38c9639fcc
16 changed files with 54 additions and 53 deletions

View File

@@ -27,7 +27,9 @@ NODE_ENV=production REACT_APP_ENV=test pnpm run build
```
- `config/proxy_prod.ts` resolves targets dynamically based on the current hostname; adjust rules there if deployment hosts change.
- `config/request_prod.ts` prepends the API base URL from `ApiConfigService`, while the dev file leaves relative paths untouched.
- Request pipelines differ per mode:
- `config/request_dev.ts` keeps relative URLs so calls pass through the dev proxy setup (use when mocking/pointing to LAN services).
- `config/request_prod.ts` builds absolute URLs from `ApiConfigService` so static builds call the correct host without relying on the proxy.
## Verifying Builds

View File

@@ -8,7 +8,7 @@ const getCurrentIP = () => {
hostname.startsWith('192.168.') ||
hostname.startsWith('10.')
) {
console.log('Host name: ', hostname);
// console.log('Host name: ', hostname);
return hostname;
}

View File

@@ -47,7 +47,7 @@ export const handleRequestConfig: RequestConfig = {
errorConfig: {
// Error throwing
errorThrower: (res: any) => {
console.log('Response from backend:', res);
// console.log('Response from backend:', res);
const { success, data, errorCode, errorMessage, showType } = res;
if (!success) {
const error: any = new Error(errorMessage);

View File

@@ -31,7 +31,7 @@ export const handleRequestConfig: RequestConfig = {
errorConfig: {
// Error throwing
errorThrower: (res: any) => {
console.log('Response from backend:', res);
// console.log('Response from backend:', res);
const { success, data, errorCode, errorMessage, showType } = res;
if (!success) {
const error: any = new Error(errorMessage);
@@ -68,7 +68,7 @@ export const handleRequestConfig: RequestConfig = {
// Request interceptors
requestInterceptors: [
(url: string, options: any) => {
console.log('URL Request:', url, options);
// console.log('URL Request:', url, options);
// Nếu URL không phải absolute URL, thêm base URL
let finalUrl = url;

View File

@@ -8,7 +8,7 @@ export default function useAlarmModel() {
setLoading(true);
try {
const res = await queryAlarms(); // đổi URL cho phù hợp
console.log('Alarm Data fetched:', res);
// console.log('Alarm Data fetched:', res);
setAlarmData(res || []);
} catch (err) {

View File

@@ -163,10 +163,10 @@ class MapManager {
this.initZoomListener();
this.isInitialized = true;
console.log(
'Map initialized successfully at',
new Date().toLocaleTimeString(),
);
// console.log(
// 'Map initialized successfully at',
// new Date().toLocaleTimeString(),
// );
this.map.on('singleclick', (evt: any) => {
const featuresAtPixel: {
@@ -188,12 +188,12 @@ class MapManager {
if (this.features.includes(feature)) {
this.onFeatureClick(feature);
this.onFeatureSelect(feature, evt.pixel);
console.log(
'Feature clicked at',
new Date().toLocaleTimeString(),
':',
feature.getProperties(),
);
// console.log(
// 'Feature clicked at',
// new Date().toLocaleTimeString(),
// ':',
// feature.getProperties(),
// );
}
} else {
this.onFeaturesClick(featuresAtPixel.map((f) => f.feature));
@@ -366,7 +366,7 @@ class MapManager {
strokeColor = 'rgba(255, 0, 0, 0.8)',
strokeWidthBase = 0.25,
} = config;
console.log('Starting animatedMarker with config:', config);
// console.log('Starting animatedMarker with config:', config);
const flashGeom = feature.getGeometry()?.clone() as Point | undefined;
if (!flashGeom || !this.featureLayer) {

View File

@@ -36,7 +36,7 @@ const ShipInfo: React.FC<ShipInfoProps> = ({ isOpen, setIsOpen }) => {
const fetchShipData = async () => {
try {
const resp = await getShipInfo();
console.log('Ship Info Response:', resp);
// console.log('Ship Info Response:', resp);
return resp;
} catch (error) {
console.error('Error fetching ship data:', error);

View File

@@ -67,7 +67,7 @@ const SosButton: React.FC<SosButtonProps> = ({ onRefresh }) => {
console.error('Failed to delete SOS:', error);
message.error(t('sos.cancelError'));
}
console.log('Sending SOS without message');
// console.log('Sending SOS without message');
}
};
@@ -116,7 +116,7 @@ const SosButton: React.FC<SosButtonProps> = ({ onRefresh }) => {
</Button>
}
onFinish={async (values) => {
console.log('Form Values: ', values);
// console.log('Form Values: ', values);
// Nếu chọn "Khác" thì lấy messageOther, ngược lại lấy message
const finalMessage =

View File

@@ -22,7 +22,7 @@ const VietNamMap: React.FC<VietNamMapProps> = React.memo(
const mapRef = useRef<HTMLDivElement>(null);
useEffect(() => {
console.log('useEffect in VietNamMap triggered');
// console.log('useEffect in VietNamMap triggered');
let manager = mapManager;
if (!manager) {
@@ -38,10 +38,10 @@ const VietNamMap: React.FC<VietNamMapProps> = React.memo(
manager!.mapRef = mapRef;
if (!manager!.map) {
manager!.initializeMap();
console.log(
'Initialized new MapManager instance at',
new Date().toLocaleTimeString(),
);
// console.log(
// 'Initialized new MapManager instance at',
// new Date().toLocaleTimeString(),
// );
}
} else if (retryCount < maxRetries) {
console.error('mapRef.current is not ready, retrying...');
@@ -55,7 +55,7 @@ const VietNamMap: React.FC<VietNamMapProps> = React.memo(
initialize();
return () => {
console.log('Cleanup in VietNamMap triggered');
// console.log('Cleanup in VietNamMap triggered');
// Không gọi destroy ở đây để tránh phá hủy bản đồ không cần thiết
};
}, [mapManager, onFeatureClick, onFeatureSelect, onFeaturesClick, onError]);

View File

@@ -63,12 +63,12 @@ const HomePage: React.FC = () => {
const hasCenteredRef = useRef(false);
const onFeatureClick = useCallback((feature: any) => {
console.log('OnClick Feature: ', feature);
console.log(
'Clicked ship at',
new Date().toLocaleTimeString(),
'Properties:',
feature.getProperties(),
);
// console.log(
// 'Clicked ship at',
// new Date().toLocaleTimeString(),
// 'Properties:',
// feature.getProperties(),
// );
}, []);
const intl = useIntl();
const onFeaturesClick = useCallback((features: any[]) => {

View File

@@ -38,7 +38,7 @@ const CreateNewHaulOrTrip: React.FC<CreateNewHaulOrTripProps> = ({
try {
const gpsData = await getGPS();
console.log('GPS Data:', gpsData);
// console.log('GPS Data:', gpsData);
const body: API.NewFishingLogRequest = {
trip_id: trips?.id || '',

View File

@@ -40,7 +40,7 @@ const CreateOrUpdateFishingLog: React.FC<CreateOrUpdateFishingLogProps> = ({
try {
const resp = await getFishSpecies();
setFishDatas(resp);
console.log('Fetched fish species:', resp);
// console.log('Fetched fish species:', resp);
} catch (error) {
console.error('Error fetching fish species:', error);
}
@@ -48,7 +48,7 @@ const CreateOrUpdateFishingLog: React.FC<CreateOrUpdateFishingLogProps> = ({
useEffect(() => {
getAllFish();
if (isOpen) {
console.log('Modal opened with fishingLogs:', fishingLogs);
// console.log('Modal opened with fishingLogs:', fishingLogs);
if (fishingLogs?.info && fishingLogs.info.length > 0) {
const dataWithKeys: FishingLogInfoWithKey[] = fishingLogs.info.map(
@@ -158,8 +158,8 @@ const CreateOrUpdateFishingLog: React.FC<CreateOrUpdateFishingLogProps> = ({
async function createOrCreateOrUpdateFishingLog(
fishingLog: FishingLogInfoWithKey[],
) {
console.log('Is finished:', isFinished);
console.log('Trip:', trip);
// console.log('Is finished:', isFinished);
// console.log('Trip:', trip);
try {
const gpsData = await getGPS();
@@ -167,8 +167,8 @@ const CreateOrUpdateFishingLog: React.FC<CreateOrUpdateFishingLogProps> = ({
if (isFinished === false) {
// Tạo mẻ mới
const logStatus0 = trip.fishing_logs?.find((log) => log.status === 0);
console.log('ok', logStatus0);
console.log('ok', fishingLog);
// console.log('ok', logStatus0);
// console.log('ok', fishingLog);
const body: API.FishingLog = {
fishing_log_id: logStatus0?.fishing_log_id || '',
trip_id: trip.id,
@@ -192,8 +192,8 @@ const CreateOrUpdateFishingLog: React.FC<CreateOrUpdateFishingLogProps> = ({
})),
sync: true,
};
const resp = await updateFishingLogs(body);
console.log('Resp', resp);
await updateFishingLogs(body);
// console.log('Resp', resp);
onFinished?.(true);
onOpenChange(false);
@@ -223,8 +223,8 @@ const CreateOrUpdateFishingLog: React.FC<CreateOrUpdateFishingLogProps> = ({
};
// console.log('Update body:', body);
const resp = await updateFishingLogs(body);
console.log('Resp', resp);
await updateFishingLogs(body);
// console.log('Resp', resp);
onFinished?.(true);
onOpenChange(false);

View File

@@ -122,7 +122,7 @@ const HaulTable: React.FC<HaulTableProps> = ({ hauls, trip }) => {
align: 'center',
hideInSearch: true,
render: (_, record) => {
console.log('Rendering action column for record:', record);
// console.log('Rendering action column for record:', record);
return (
<Flex align="center" justify="center" gap={5}>
{/* Nút Edit */}

View File

@@ -15,6 +15,7 @@ const TripCostTable: React.FC<TripCostTableProps> = ({ tripCosts }) => {
);
const trip_cost_columns: ProColumns<API.TripCost>[] = [
{
key: 'type',
title: (
<div style={{ textAlign: 'center' }}>
{intl.formatMessage({ id: 'trip.cost.type' })}
@@ -34,6 +35,7 @@ const TripCostTable: React.FC<TripCostTableProps> = ({ tripCosts }) => {
align: 'center',
},
{
key: 'amount',
title: (
<div style={{ textAlign: 'center' }}>
{intl.formatMessage({ id: 'trip.cost.amount' })}
@@ -43,6 +45,7 @@ const TripCostTable: React.FC<TripCostTableProps> = ({ tripCosts }) => {
align: 'center',
},
{
key: 'unit',
title: (
<div style={{ textAlign: 'center' }}>
{intl.formatMessage({ id: 'trip.cost.unit' })}
@@ -52,6 +55,7 @@ const TripCostTable: React.FC<TripCostTableProps> = ({ tripCosts }) => {
align: 'center',
},
{
key: 'cost_per_unit',
title: (
<div style={{ textAlign: 'center' }}>
{intl.formatMessage({ id: 'trip.cost.price' })}
@@ -62,6 +66,7 @@ const TripCostTable: React.FC<TripCostTableProps> = ({ tripCosts }) => {
render: (val: any) => (val ? Number(val).toLocaleString() : ''),
},
{
key: 'total_cost',
title: (
<div style={{ textAlign: 'center' }}>
{intl.formatMessage({ id: 'trip.cost.total' })}
@@ -79,6 +84,7 @@ const TripCostTable: React.FC<TripCostTableProps> = ({ tripCosts }) => {
];
return (
<ProTable<API.TripCost>
rowKey="trip-cost-table"
columns={trip_cost_columns}
dataSource={tripCosts}
search={false}

View File

@@ -44,7 +44,7 @@ const DetailTrip = () => {
}, []);
return (
console.log('Rendering with tripInfo:', data),
// console.log('Rendering with tripInfo:', data),
(
<PageContainer
header={{
@@ -140,13 +140,6 @@ const DetailTrip = () => {
<MainTripBody
trip_id={data?.id}
tripInfo={data || null}
onReload={(isReload) => {
console.log('Nhanaj dduowcj hàm, onReload:', isReload);
// if (isReload) {
// fetchTrip();
// }
}}
/>
</ProCard>
</ProCard>

View File

@@ -2,7 +2,7 @@ import { API_PATH_LOGIN } from '@/constants';
import { request } from '@umijs/max';
export async function login(body: API.LoginRequestBody) {
console.log('Login request body:', body);
// console.log('Login request body:', body);
return request<API.LoginResponse>(API_PATH_LOGIN, {
method: 'POST',