Skip to content

Commit 8ed025c

Browse files
DangDang
authored andcommitted
Fix CORS configuration to allow localhost:3000 for development
1 parent da6a9cd commit 8ed025c

File tree

18 files changed

+39
-50
lines changed

18 files changed

+39
-50
lines changed

VehicleShowroom/package.json

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
"react-dropzone": "^14.2.3",
3232
"react-icons": "^5.2.1",
3333
"react-is": "^18.3.1",
34-
"react-quill": "^2.0.0",
34+
"react-quill": "^0.0.2",
3535
"react-router-dom": "^6.25.1",
3636
"react-scripts": "^5.0.1",
3737
"sanitize-html": "^2.17.0",
@@ -41,10 +41,10 @@
4141
"web-vitals": "^4.2.2"
4242
},
4343
"scripts": {
44-
"start": "craco start",
45-
"build": "craco build",
46-
"test": "craco test",
47-
"test:ci": "craco test --coverage --watchAll=false --passWithNoTests",
44+
"start": "react-scripts start",
45+
"build": "react-scripts build",
46+
"test": "react-scripts test",
47+
"test:ci": "react-scripts test --coverage --watchAll=false --passWithNoTests",
4848
"lint": "eslint src --ext .js,.jsx --max-warnings 0",
4949
"lint:fix": "eslint src --ext .js,.jsx --fix",
5050
"eject": "react-scripts eject",
@@ -74,11 +74,11 @@
7474
]
7575
},
7676
"devDependencies": {
77+
"@babel/plugin-syntax-dynamic-import": "^7.8.3",
78+
"@craco/craco": "^5.9.0",
7779
"anymatch": "^3.1.3",
7880
"chokidar": "^3.6.0",
7981
"gh-pages": "^6.1.1",
80-
"micromatch": "^4.0.7",
81-
"@craco/craco": "^7.1.0",
82-
"@babel/plugin-syntax-dynamic-import": "^7.8.3"
82+
"micromatch": "^4.0.7"
8383
}
8484
}

VehicleShowroom/src/App.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,13 @@ import { useState, Suspense, lazy } from 'react';
55

66
import initialTheme from './theme/theme';
77
import useWebVitals from './hooks/useWebVitals';
8+
import { UserProvider } from 'contexts/UserContext';
89

910
// 🧩 Layouts - Lazy loaded for better performance
1011
const AuthLayout = lazy(() => import('./layouts/auth'));
1112
const AdminLayout = lazy(() => import('./layouts/admin'));
1213
const UserLayout = lazy(() => import('layouts/user'));
1314

14-
// 🧩 Providers
15-
import { UserProvider } from 'contexts/UserContext';
16-
1715
// Loading component
1816
const LoadingSpinner = () => (
1917
<div style={{

VehicleShowroom/src/components/images/ImagePreview.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,13 @@ import {
33
Modal,
44
ModalOverlay,
55
ModalContent,
6-
ModalCloseButton,
76
ModalBody,
87
Image,
98
IconButton,
109
Flex,
1110
Box,
1211
HStack,
1312
useColorModeValue,
14-
Divider,
1513
} from '@chakra-ui/react';
1614
import { MdChevronLeft, MdChevronRight } from 'react-icons/md';
1715

VehicleShowroom/src/components/navbar/NavbarUser.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ function NavbarUser({ toggleCategory, isCategoryOpen }) {
2323
// 🎨 Màu chữ và icon phụ thuộc location
2424
const textColor = isHome ? 'white' : 'black';
2525
const iconColor = isHome ? 'white' : 'black';
26-
const hoverBg = isHome ? 'whiteAlpha.300' : 'black';
2726

2827
return (
2928
<>

VehicleShowroom/src/hooks/useWebVitals.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { useEffect } from 'react';
2-
import { getCLS, getFID, getFCP, getLCP, getTTFB } from 'web-vitals';
2+
import { onCLS, onINP, onFCP, onLCP, onTTFB } from 'web-vitals';
33

44
function reportWebVitals(metric) {
55
console.log(metric);
@@ -18,11 +18,11 @@ function reportWebVitals(metric) {
1818

1919
export function useWebVitals() {
2020
useEffect(() => {
21-
getCLS(reportWebVitals);
22-
getFID(reportWebVitals);
23-
getFCP(reportWebVitals);
24-
getLCP(reportWebVitals);
25-
getTTFB(reportWebVitals);
21+
onCLS(reportWebVitals);
22+
onINP(reportWebVitals);
23+
onFCP(reportWebVitals);
24+
onLCP(reportWebVitals);
25+
onTTFB(reportWebVitals);
2626
}, []);
2727
}
2828

VehicleShowroom/src/services/AuthService.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ const AuthService = {
7777
// ---------------------------------
7878
login: async (data, keepLoggedIn = false) => {
7979
const res = await ApiClient.post(ApiUrl.AUTH.LOGIN, data);
80-
const { token, refreshToken, user } = res.data;
80+
const { token, refreshToken } = res.data;
8181

8282
AuthService.setKeepLoggedIn(keepLoggedIn);
8383

VehicleShowroom/src/views/admin/customer/index.jsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import List from './components/List';
66
import Columns from './components/Columns';
77
import { useAppToast } from 'utils/ToastHelper';
88
import Header from './components/Header';
9-
import { LoadingState } from 'components/common/LoadingState';
109

1110
function CustomerManagement() {
1211
const textColor = useColorModeValue('secondaryGray.900', 'white');
@@ -30,7 +29,7 @@ function CustomerManagement() {
3029
} finally {
3130
setLoading(false);
3231
}
33-
}, []);
32+
}, [toast]);
3433

3534
useEffect(() => {
3635
loadUsers();

VehicleShowroom/src/views/admin/dashboard/index.jsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import React, { useEffect, useState, useMemo } from 'react';
22
import {
33
Box,
44
SimpleGrid,
5-
Spinner,
65
Flex,
76
Text,
87
useColorModeValue,
@@ -88,7 +87,7 @@ export default function DashboardPage() {
8887
tooltip: { y: { formatter: (val) => formatUSD(val) } },
8988
},
9089
};
91-
}, [revenue]);
90+
}, [revenue, textColorSecondary]);
9291

9392
// 🧠 Customer chart data
9493
const customerChart = useMemo(() => {
@@ -109,7 +108,7 @@ export default function DashboardPage() {
109108
grid: { borderColor: '#E2E8F0', strokeDashArray: 4 },
110109
},
111110
};
112-
}, [customer]);
111+
}, [customer, textColorSecondary]);
113112

114113
return (
115114
<>

VehicleShowroom/src/views/admin/employee/index.jsx

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import List from './components/List';
66
import Columns from './components/Columns';
77
import { useAppToast } from 'utils/ToastHelper';
88
import Header from './components/Header';
9-
import { LoadingState } from 'components/common/LoadingState';
109

1110
function EmployeeManagement() {
1211
const textColor = useColorModeValue('secondaryGray.900', 'white');
@@ -30,14 +29,14 @@ function EmployeeManagement() {
3029
} finally {
3130
setLoading(false);
3231
}
33-
}, []);
32+
}, [toast]);
3433

3534
useEffect(() => {
3635
loadEmployees();
3736
}, [loadEmployees]);
3837

3938
// ✅ Toggle active/inactive
40-
const handleToggleActive = async (id, current) => {
39+
const handleToggleActive = useCallback(async (id, current) => {
4140
try {
4241
setLoading(true);
4342
await UserService.toggleActive(id, !current);
@@ -48,7 +47,7 @@ function EmployeeManagement() {
4847
} finally {
4948
setLoading(false);
5049
}
51-
};
50+
}, [toast, loadEmployees]);
5251

5352
// ✅ Cấu hình cột
5453
const columns = useMemo(

VehicleShowroom/src/views/admin/serviceOrder/index.jsx

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import React, { useEffect, useMemo, useState, useCallback } from 'react';
22
import { useColorModeValue, Card, useDisclosure } from '@chakra-ui/react';
33
import { getCoreRowModel, useReactTable } from '@tanstack/react-table';
44
import { useAppToast } from 'utils/ToastHelper';
5-
import { LoadingState } from 'components/common/LoadingState';
65

76
import ServiceOrderService from 'services/ServiceOrderService';
87
import UserService from 'services/UserService';
@@ -84,22 +83,22 @@ function ServiceOrderManagement() {
8483
setLoading(false);
8584
}
8685
},
87-
[statusFilter],
86+
[statusFilter, toast],
8887
);
8988

9089
useEffect(() => {
9190
loadOrders(page);
92-
}, [page, statusFilter]);
91+
}, [loadOrders, page]);
9392

94-
const handleViewDetail = (order) => {
93+
const handleViewDetail = useCallback((order) => {
9594
setSelectedOrder(order);
9695
onDetailOpen();
97-
};
96+
}, [onDetailOpen]);
9897

99-
const handleStatusChange = (order) => {
98+
const handleStatusChange = useCallback((order) => {
10099
setUpdatingOrder(order);
101100
onStatusOpen();
102-
};
101+
}, [onStatusOpen]);
103102

104103
const columns = useMemo(
105104
() =>
@@ -109,7 +108,7 @@ function ServiceOrderManagement() {
109108
statusFilter,
110109
setStatusFilter,
111110
}),
112-
[statusFilter],
111+
[handleViewDetail, handleStatusChange, statusFilter],
113112
);
114113

115114
const table = useReactTable({

0 commit comments

Comments
 (0)