From dbd60081b10de36079c3c42029426e6ae98f07d6 Mon Sep 17 00:00:00 2001 From: LEE HYO WON Date: Fri, 8 Mar 2024 23:51:42 +0900 Subject: [PATCH] =?UTF-8?q?Revert=20"[Feat]:=20=EA=B2=AC=EC=A0=81=EC=84=9C?= =?UTF-8?q?=20api=20=EC=97=B0=EB=8F=99"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/dashboard.tsx | 6 - src/api/estimate.tsx | 49 +--- src/assets/icon/warning.png | Bin 503 -> 0 bytes src/components/common/Button.tsx | 2 +- src/components/common/CheckBox.tsx | 22 +- src/components/common/MenuTab.tsx | 22 +- src/components/dashboard/ResultRecord.tsx | 12 +- src/components/estimate/Basket.tsx | 36 +-- src/components/estimate/BrokenPartInfoBox.tsx | 9 - src/components/estimate/DateSelect.tsx | 51 ---- src/components/estimate/NewPartsInfoBox.tsx | 11 +- src/components/estimate/RecyclePartBox.tsx | 5 +- src/components/estimate/RecyclePartsList.tsx | 27 +- src/components/estimate/RepairCompanyList.tsx | 46 ++-- src/components/estimate/TotalScoreChart.tsx | 21 +- src/pages/EstimatePage.tsx | 258 +++--------------- src/pages/TestDetailPage.tsx | 4 +- 17 files changed, 118 insertions(+), 463 deletions(-) delete mode 100644 src/api/dashboard.tsx delete mode 100644 src/assets/icon/warning.png delete mode 100644 src/components/estimate/DateSelect.tsx diff --git a/src/api/dashboard.tsx b/src/api/dashboard.tsx deleted file mode 100644 index cfefd77..0000000 --- a/src/api/dashboard.tsx +++ /dev/null @@ -1,6 +0,0 @@ -import client from './client'; - -// 드론 그룹 내 드론 조회 -export const getDroneList = async (groupId: number) => { - return await client.get(`/api/drone-group/${groupId}/drones`); -}; diff --git a/src/api/estimate.tsx b/src/api/estimate.tsx index 1f51606..484452e 100644 --- a/src/api/estimate.tsx +++ b/src/api/estimate.tsx @@ -1,39 +1,14 @@ import client from './client'; -// 진단 날짜 리스트 조회 -export const getTestDateList = async (droneId: number) => { - return await client.get(`/api/drones/${droneId}/test-results`); -}; - -// 견적서 부품 리스트 조회 -export const getEstimateInfo = async (droneId: number, dateValue: string) => { - const newDate = new Date(dateValue); - const year = Number(newDate.getFullYear()); - const month = Number(newDate.getMonth()) + 1; - const date = Number(newDate.getDate()); - console.log(year, month, date); - return await client.get( - `/api/drones/${droneId}/test-results?year=${year}&month=${month}&day=${date}` - ); -}; - -// 교체가 필요한 부품 및 총점수 조회 -export const getTopSectionInfo = async (droneId: number, dateValue: string) => { - const newDate = new Date(dateValue); - const year = Number(newDate.getFullYear()); - const month = Number(newDate.getMonth()) + 1; - const date = Number(newDate.getDate()); - console.log(year, month, date); - return await client.get( - `/api/drones/${droneId}/test-results?year=${year}&month=${month}&day=${date}&mode=TOP-SECTION` - ); -}; - -// 수리 업체 조회 -export const getRepairCompany = async (model: string, type: string[]) => { - return await client.get(`/api/repair-stores?model=${model}&type=${type}`); -}; - -export const getBasketList = async (checkedList: string[]) => { - return await client.get(`api/components?names=${checkedList}`); -}; +// 드론 그룹 내 드론 조회 +export const getDroneGroupList = async (groupId: number) => { + return await client.get(`/api/drone-groups/${groupId}/drones`); +}; + +// // 진단 상세 +// export const getDashboardDetail = async (droneId: number, date: string) => { +// return await client.post(`/api/drone/dashboard/detail`, { +// droneId: droneId, +// date: date, +// }); +// }; diff --git a/src/assets/icon/warning.png b/src/assets/icon/warning.png deleted file mode 100644 index 99596cf69ceed43466df9c5e8c5021fc095d48cb..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 503 zcmV#y6b=Oi1_y z?W##;x_f$Fzj+Dp$EG$VXcsmP(Sb&&p76R?K`C~GcV?Z$4$SZcM+FGW_SDuDL=!zJ z7GcDdFY_i`R6(e3xY@!dQGKXKIN}?~+QytHpNV!SgmrlGKEUPj6mRYq~aU7dUj5*jEp=KdP;_Kus&Kh$*mANG-P0q_!1&QWb$k!MtFX2h!IE^Ph zb3rYAw|YUDg3^}4kYlDE5)O;ZLLeP5SEN;n(85)sIUj3`D8nSj&dW$;(B)*Zhz&?X z1e^XKMFk@|!)=c|I~E!wbIxT%U6r)8xgyTwdK>)3B`0`% t4Y8m3M!QSdcx?Tfql(q!LwLh~*bj2yib|}3ex?8b002ovPDHLkV1o5I%@Y6s diff --git a/src/components/common/Button.tsx b/src/components/common/Button.tsx index 0737b7e..5a6d228 100644 --- a/src/components/common/Button.tsx +++ b/src/components/common/Button.tsx @@ -22,7 +22,7 @@ interface ButtonProps extends ButtonTypes { text: ReactNode; buttonType?: buttonType; children?: React.ReactNode; - onClick?: (e: React.MouseEvent) => void; + onClick?: () => void; style?: React.CSSProperties & { fontSize?: string }; } diff --git a/src/components/common/CheckBox.tsx b/src/components/common/CheckBox.tsx index 1e11e73..ddc34af 100644 --- a/src/components/common/CheckBox.tsx +++ b/src/components/common/CheckBox.tsx @@ -1,29 +1,25 @@ -import { SafetyCheckRounded } from '@mui/icons-material'; import { Typography } from '@mui/material'; -import React, { ReactNode, useState } from 'react'; +import React, { useState } from 'react'; import colors from 'src/constants/colors'; import styled from 'styled-components'; interface CheckBoxProps { - value?: string | number; label?: string; - checked?: boolean; - onChange?: (e: React.ChangeEvent) => void; } -const CheckBox: React.FC = ({ - value, - label, - checked, - onChange, -}) => { +const CheckBox: React.FC = ({ label }) => { + const [checked, setChecked] = useState(false); // 체크 여부를 관리하는 상태 + + const toggleChecked = () => { + setChecked(!checked); + }; + return ( {label} diff --git a/src/components/common/MenuTab.tsx b/src/components/common/MenuTab.tsx index 440d4c3..b4ffc83 100644 --- a/src/components/common/MenuTab.tsx +++ b/src/components/common/MenuTab.tsx @@ -5,17 +5,15 @@ import ItemContainer from 'src/components/common/ItemContainer'; import Button from 'src/components/common/Button'; import { Plus } from 'src/assets'; import { useLocation, useNavigate } from 'react-router-dom'; -import React from 'react'; -import { getDroneList } from 'src/api/dashboard'; // // // -export interface Group { - groupName: string; - droneList: { id: number; name: string }[]; +interface Group { + name: string; + drones: { id: number; name: string }[]; } -export interface MenuTabProps { +interface MenuTabProps { groups?: Group[]; group?: Group; type: 'dashboard' | 'parts' | 'monitoring'; @@ -68,19 +66,11 @@ const MenuTab = ({ groups, group, type }: MenuTabProps) => { const location = useLocation(); const isTestDetailPage = location.pathname.includes('/test'); const isEstimatePage = location.pathname.includes('/estimate'); - const [drones, setDrones] = React.useState(); const handleTabMenu = (url: string, id?: string) => { navigate(url, { state: id }); }; - React.useEffect(() => { - getDroneList(1).then((res) => { - console.log(res.data.data); - setDrones(res.data.data); - }); - }, []); - /* 부품 탭 */ const renderPartsTab = () => { const partsTabs = [ @@ -201,11 +191,11 @@ const MenuTab = ({ groups, group, type }: MenuTabProps) => { fontWeight='bold' sx={{ padding: '0rem 0.5rem', marginBottom: '0.5rem' }} > - {drones?.groupName} + 드론 그룹 {droneList.groupId} - {drones?.droneList.map((item) => ( + {droneList.drones.map((item) => ( { - navigate(`/drone-group/drone/${id}/estimate`, { - state: location.state, - }); + navigate(`/drone-group/${groupId}/drone/${id}/estimate`); }; return ( @@ -51,10 +48,7 @@ function ResultRecord({ groupId }: ResultRecordProp) { } buttonType='accentLight' - onClick={(e) => { - e.stopPropagation(); - goToDashboard(selectedDrone.id); - }} + onClick={() => goToDashboard(selectedDrone.id)} style={{ width: '95px', height: '32px', fontSize: '14px' }} /> diff --git a/src/components/estimate/Basket.tsx b/src/components/estimate/Basket.tsx index 2d069e1..42b94fa 100644 --- a/src/components/estimate/Basket.tsx +++ b/src/components/estimate/Basket.tsx @@ -4,16 +4,6 @@ import BasketItem from './BasketItem'; import partsImg from 'src/assets/images/drone-parts.png'; import Button from '../common/Button'; import colors from 'src/constants/colors'; -import { useLocation, useNavigate } from 'react-router-dom'; -import { NewParts } from 'src/pages/EstimatePage'; - -export interface BasketData { - totalCost: number; - checkedComponentList: NewParts[]; -} -interface BasketProps { - items?: BasketData; -} const BasketContainer = styled.div` display: flex; @@ -27,22 +17,26 @@ const ItemList = styled.div` gap: 0.75rem; `; -const Basket = ({ items }: BasketProps) => { - const location = useLocation(); - const navigate = useNavigate(); - // 임시 장바구니 합계 +const Basket = () => { + // 장바구니 리스트 + const itemList = Array(3).fill({ + imgUrl: partsImg, + name: 'X2814 900KV 3-5S Brushless Motor', + price: 135000, + }); - console.log(items?.totalCost); + // 임시 장바구니 합계 + const totalPrice = 0; return ( 장바구니 - {items?.checkedComponentList?.map((item, index) => ( + {itemList.map((item, index) => ( @@ -59,17 +53,13 @@ const Basket = ({ items }: BasketProps) => { 총 가격 - {items?.totalCost}원 + {totalPrice}원