Skip to content

Commit

Permalink
Revert "[Feat]: 견적서 api 연동"
Browse files Browse the repository at this point in the history
  • Loading branch information
ymj07168 authored Mar 8, 2024
1 parent 6f15227 commit dbd6008
Show file tree
Hide file tree
Showing 17 changed files with 118 additions and 463 deletions.
6 changes: 0 additions & 6 deletions src/api/dashboard.tsx

This file was deleted.

49 changes: 12 additions & 37 deletions src/api/estimate.tsx
Original file line number Diff line number Diff line change
@@ -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,
// });
// };
Binary file removed src/assets/icon/warning.png
Binary file not shown.
2 changes: 1 addition & 1 deletion src/components/common/Button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 };
}

Expand Down
22 changes: 9 additions & 13 deletions src/components/common/CheckBox.tsx
Original file line number Diff line number Diff line change
@@ -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<HTMLInputElement>) => void;
}

const CheckBox: React.FC<CheckBoxProps> = ({
value,
label,
checked,
onChange,
}) => {
const CheckBox: React.FC<CheckBoxProps> = ({ label }) => {
const [checked, setChecked] = useState(false); // 체크 여부를 관리하는 상태

const toggleChecked = () => {
setChecked(!checked);
};

return (
<CheckboxContainer>
<CheckboxInput
value={value}
type='checkbox'
checked={checked}
onChange={onChange}
onChange={toggleChecked}
/>
<Typography variant='caption' color={colors.basic500}>
{label}
Expand Down
22 changes: 6 additions & 16 deletions src/components/common/MenuTab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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<Group>();

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 = [
Expand Down Expand Up @@ -201,11 +191,11 @@ const MenuTab = ({ groups, group, type }: MenuTabProps) => {
fontWeight='bold'
sx={{ padding: '0rem 0.5rem', marginBottom: '0.5rem' }}
>
{drones?.groupName}
드론 그룹 {droneList.groupId}
</Typography>
<Divider sx={{ margin: '0rem 0.5rem 0.5rem' }} />
<TabList>
{drones?.droneList.map((item) => (
{droneList.drones.map((item) => (
<TabItem
className={
location.pathname.includes(`/drone/${item.id}`) ? 'active' : ''
Expand Down
12 changes: 3 additions & 9 deletions src/components/dashboard/ResultRecord.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,14 @@ import styled from 'styled-components';
import colors from 'src/constants/colors';
import Button from 'src/components/common/Button';
import { Bigger } from 'src/assets';
import { useLocation, useNavigate } from 'react-router-dom';
import { useNavigate } from 'react-router-dom';
import { droneListData } from 'src/assets/data/droneListData';

interface ResultRecordProp {
groupId: number;
droneId?: number;
}
function ResultRecord({ groupId }: ResultRecordProp) {
const location = useLocation();
const navigate = useNavigate();

const selectedDrone = droneListData[0];
Expand All @@ -26,9 +25,7 @@ function ResultRecord({ groupId }: ResultRecordProp) {
}

const goToDashboard = (id: number) => {
navigate(`/drone-group/drone/${id}/estimate`, {
state: location.state,
});
navigate(`/drone-group/${groupId}/drone/${id}/estimate`);
};

return (
Expand All @@ -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' }}
/>
</Drone>
Expand Down
36 changes: 13 additions & 23 deletions src/components/estimate/Basket.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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 (
<BasketContainer>
<Typography fontSize='14px'>장바구니</Typography>
<Stack direction='row' alignItems='center' justifyContent='space-between'>
<ItemList>
{items?.checkedComponentList?.map((item, index) => (
{itemList.map((item, index) => (
<BasketItem
key={index}
imgUrl={partsImg}
imgUrl={item.imgUrl}
name={item.name}
price={item.price}
/>
Expand All @@ -59,17 +53,13 @@ const Basket = ({ items }: BasketProps) => {
총 가격
</Typography>
<Typography variant='h3' color={colors.accent100} fontWeight='bold'>
{items?.totalCost}
{totalPrice}
</Typography>
</Stack>
<Button
buttonType='basic'
text='부품 구매 바로가기'
onClick={() =>
navigate(`/drone-group/drone/parts/cost`, {
state: location.state,
})
}
onClick={() => alert('부품 구매 바로갑니다.')}
/>
</Stack>
</Stack>
Expand Down
9 changes: 0 additions & 9 deletions src/components/estimate/BrokenPartInfoBox.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { Stack, Typography } from '@mui/material';
import colors from 'src/constants/colors';
import styled from 'styled-components';
import warningIcon from 'src/assets/icon/warning.png';

interface BrokenPartsInfoType {
part: string;
Expand All @@ -10,7 +9,6 @@ interface BrokenPartsInfoType {
warning: boolean;
}
const PartBox = styled.div`
position: relative;
display: grid;
grid-template-columns: repeat(4, 1fr);
padding: 0.5938rem 1rem;
Expand Down Expand Up @@ -44,13 +42,6 @@ const BrokenPartInfoBox = ({
/ 100점
</Typography>
</Stack>
{warning ? (
<img
src={warningIcon}
alt='경고'
style={{ position: 'absolute', top: 10, right: 30 }}
/>
) : null}
</PartBox>
);
};
Expand Down
51 changes: 0 additions & 51 deletions src/components/estimate/DateSelect.tsx

This file was deleted.

11 changes: 2 additions & 9 deletions src/components/estimate/NewPartsInfoBox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ interface NewPartsProp {
price: number;
detail: string;
checked: boolean;
onChange?: (e: React.ChangeEvent<HTMLInputElement>) => void;
}

//
Expand Down Expand Up @@ -49,12 +48,11 @@ const NewPartInfoBox = ({
price,
detail,
checked,
onChange,
}: NewPartsProp) => {
return (
<PartsInfoBox style={{ gap: '1rem' }}>
<img src={imgUrl} alt={name} style={{ objectFit: 'contain' }} />
<Stack width='100%' direction='column' justifyContent='center' gap='1rem'>
<Stack direction='column' justifyContent='center' gap='1rem'>
<Stack
direction='row'
alignItems='flex-start'
Expand All @@ -72,12 +70,7 @@ const NewPartInfoBox = ({
<Typography variant='h4' fontWeight='bold'>
{price}
</Typography>
<CheckBox
key={id}
value={name}
checked={checked}
onChange={onChange}
/>
<CheckBox key={id} />
</Stack>
</Stack>
<Typography
Expand Down
Loading

0 comments on commit dbd6008

Please sign in to comment.