Skip to content

Commit

Permalink
Merge pull request #118 from Weflo-A/develop
Browse files Browse the repository at this point in the history
Develop: 대시보드 이동시 id null 값 오류 해결
  • Loading branch information
ymj07168 authored Mar 10, 2024
2 parents 7f161e1 + a588055 commit b7f1868
Show file tree
Hide file tree
Showing 4 changed files with 69 additions and 47 deletions.
98 changes: 52 additions & 46 deletions src/Router.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,56 +8,62 @@ import CostPartPage from './pages/CostPartPage';
import EstimatePartPage from './pages/EstimatePartPage';
import PurchasePartPage from './pages/PurchasePartPage';
import TestDetailPage from './pages/TestDetailPage';
import ScrollToTop from './components/common/ScrollToTop';

const Router = () => {
return (
<BrowserRouter>
<NavBar />
<Routes>
<Route
path='/'
element={<Navigate replace to='/monitoring/drone-search' />}
/>
{/* 드론 검색(조회) */}
<Route path='/monitoring/drone-search' element={<DroneSearchPage />} />
{/* 드론 목록 */}
<Route
path='/monitoring/drone-group/:groupId'
element={<DroneGroupPage />}
/>
{/* 중고 거래 */}
<Route path='/trade' element={<PurchasePartPage />} />
{/* 대시보드 메인 */}
<Route
path='/drone-group/drone/:id/dashboard'
element={<DashBoard />}
/>
{/* 대시보드 진단 상세 */}
<Route
path='/drone-group/drone/:id/dashboard/test'
element={<TestDetailPage />}
/>
{/* 견적서 */}
<Route
path='/drone-group/drone/:id/estimate'
element={<EstimatePage />}
/>
{/* 부품 구매 */}
<Route
path='/drone-group/drone/parts/purchase'
element={<PurchasePartPage />}
/>
{/* 부품 예측 관리 */}
<Route
path='/drone-group/drone/parts/manage'
element={<EstimatePartPage />}
/>
{/* 투입 비용 현황 */}
<Route
path='/drone-group/drone/parts/cost'
element={<CostPartPage />}
/>
</Routes>
<ScrollToTop>
<NavBar />
<Routes>
<Route
path='/'
element={<Navigate replace to='/monitoring/drone-search' />}
/>
{/* 드론 검색(조회) */}
<Route
path='/monitoring/drone-search'
element={<DroneSearchPage />}
/>
{/* 드론 목록 */}
<Route
path='/monitoring/drone-group/:groupId'
element={<DroneGroupPage />}
/>
{/* 중고 거래 */}
<Route path='/trade' element={<PurchasePartPage />} />
{/* 대시보드 메인 */}
<Route
path='/drone-group/drone/:id/dashboard'
element={<DashBoard />}
/>
{/* 대시보드 진단 상세 */}
<Route
path='/drone-group/drone/:id/dashboard/test'
element={<TestDetailPage />}
/>
{/* 견적서 */}
<Route
path='/drone-group/drone/:id/estimate'
element={<EstimatePage />}
/>
{/* 부품 구매 */}
<Route
path='/drone-group/drone/parts/purchase'
element={<PurchasePartPage />}
/>
{/* 부품 예측 관리 */}
<Route
path='/drone-group/drone/parts/manage'
element={<EstimatePartPage />}
/>
{/* 투입 비용 현황 */}
<Route
path='/drone-group/drone/parts/cost'
element={<CostPartPage />}
/>
</Routes>
</ScrollToTop>
</BrowserRouter>
);
};
Expand Down
13 changes: 13 additions & 0 deletions src/components/common/ScrollToTop.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { useEffect } from 'react';
import { useLocation } from 'react-router-dom';

export default function ScrollToTop(props: any) {
const { pathname } = useLocation();

useEffect(() => {
console.log('Scrolling to top');
window.scrollTo(0, 0);
}, [pathname]);

return <>{props.children}</>;
}
3 changes: 2 additions & 1 deletion src/components/onboarding/droneSearch/DroneLists.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { useNavigate } from 'react-router-dom';
import { DroneGroupBox } from './DroneGroupBox';

interface DroneInfo {
droneId: number;
name: string;
model: string;
year: number;
Expand Down Expand Up @@ -52,7 +53,7 @@ function DroneLists({ data }: Props) {
</>
}
buttonType='accentLight'
onClick={() => goToDashboard(index)}
onClick={() => goToDashboard(data.droneId)}
style={{ width: '110px', height: '32px', fontSize: '14px' }}
/>
</Drone>
Expand Down
2 changes: 2 additions & 0 deletions src/components/onboarding/droneSearch/DroneSearch.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ const DroneSearch: React.FC = () => {
droneInfo: [],
});

console.log('search', searchDrones);

useEffect(() => {
postSearch(searchTerm, selectedModels, selectedYears, selectedGroups).then(
(res) => {
Expand Down

0 comments on commit b7f1868

Please sign in to comment.