Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: 충전소 상세 정보 조회기능을 개선하고, 누적 고장 신고 확인 기능을 구현한다 #245

Merged
merged 29 commits into from
Jul 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
385111a
feat: 충전소 상세정보 조회 시 누적 신고 횟수가 보이는 기능 구현
gabrielyoon7 Jul 29, 2023
8a63d74
refactor: 충전소 상세 정보 위치 개선
gabrielyoon7 Jul 29, 2023
20b2692
refactor: 폴더 구조 개선
gabrielyoon7 Jul 29, 2023
deff661
fix: 오탈자 수정
gabrielyoon7 Jul 29, 2023
8df9c21
fix: 오탈자 수정
gabrielyoon7 Jul 29, 2023
12b6f82
refactor: 파일 구조 개선
gabrielyoon7 Jul 29, 2023
eafa070
design: 충전소 기본 정보 디자인 수정
gabrielyoon7 Jul 29, 2023
61599c9
Merge remote-tracking branch 'origin' into feat/238
gabrielyoon7 Jul 30, 2023
e09edbc
design: Alert 적용
gabrielyoon7 Jul 30, 2023
9a4b71f
feat: 충전소 디자인 컴포넌트 및 업데이트 시간 차이 계산 기능 구현
gabrielyoon7 Jul 30, 2023
44c6ef7
test: ChargerCard 추가
gabrielyoon7 Jul 30, 2023
767b4e7
feat: 충전기 상태 코드 설명 객체 추가
gabrielyoon7 Jul 30, 2023
288abe5
refactor: 충전소 상태 객체 정의 및 타입 설정
gabrielyoon7 Jul 30, 2023
55911da
design: 충전기 상태 카드가 2열로 표시되도록 개선
gabrielyoon7 Jul 30, 2023
6ac895e
refactor: latestUpdateTime 타입 수정
gabrielyoon7 Jul 30, 2023
196608e
design: 충전기 카드 디자인 개선
gabrielyoon7 Jul 30, 2023
b3ddc96
test: 날짜 버그 수정
gabrielyoon7 Jul 30, 2023
17d3fc3
fix: 타입 에러 수정
gabrielyoon7 Jul 30, 2023
37a7196
refactor: mock데이터에서 고장 신고가 좀 더 많이 나오도록 개선
gabrielyoon7 Jul 30, 2023
3179bea
design: 디자인 일부 개선
gabrielyoon7 Jul 30, 2023
756fc45
refactor: 불필요한 코드 제거
gabrielyoon7 Jul 30, 2023
cc297fa
refactor: 디자인 개선
gabrielyoon7 Jul 30, 2023
49a0efc
Merge remote-tracking branch 'origin' into feat/238
gabrielyoon7 Jul 30, 2023
0e7a8d6
test: ChargerCard에 auto docs 추가
gabrielyoon7 Jul 30, 2023
15817f4
test: ChargerCard, DetailedStation에 auto docs 추가
gabrielyoon7 Jul 30, 2023
bf9fb1b
refactor: 필요없는 as 제거
feb-dain Jul 30, 2023
180e1e0
Update frontend/src/components/ui/DetailedStationInfo/ChargerCard.tsx
gabrielyoon7 Jul 30, 2023
b1b99ef
refactor: prop 사용 코드 개선
gabrielyoon7 Jul 30, 2023
6b07778
refactor: 주석 제거
gabrielyoon7 Jul 30, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion frontend/src/components/ui/ClientStationFilters.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ const Container = styled.div`
position: fixed;
top: 10px;
left: 180px;
z-index: 999;
z-index: 998;
Copy link
Collaborator

@feb-dain feb-dain Jul 30, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

우리 z index도 좀 얘기해봐야겠다ㅋㅋㅋ 그냥 뒀는데 쓰는 곳이 많아지네

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

기준을 어디로 잡아야 할지 모르겠음

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

이건 날 잡고 한번 정하자

padding: 10px;
background-color: white;
box-shadow: 1px 1px 2px gray;
Expand Down
72 changes: 0 additions & 72 deletions frontend/src/components/ui/DetailedStationInfo.tsx

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import type { Meta } from '@storybook/react';

import type { ChargerCardProps } from '@ui/DetailedStationInfo/ChargerCard';
import ChargerCard from '@ui/DetailedStationInfo/ChargerCard';

const meta = {
title: 'UI/ChargerCard',
component: ChargerCard,
tags: ['autodocs'],
args: {
charger: {
type: 'DC_AC_3PHASE',
price: 200,
capacity: 3,
latestUpdateTime: '2023-07-18T15:11:40.000Z',
state: 'STANDBY',
method: '단독',
},
},
argTypes: {
charger: {
description: '충전기 데이터를 수정할 수 있습니다.',
},
},
} satisfies Meta<typeof ChargerCard>;

export default meta;

export const Default = (args: ChargerCardProps) => {
return <ChargerCard {...args} />;
};
72 changes: 72 additions & 0 deletions frontend/src/components/ui/DetailedStationInfo/ChargerCard.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
import { BoltIcon } from '@heroicons/react/24/solid';
import { css } from 'styled-components';

import Box from '@common/Box';
import FlexBox from '@common/FlexBox';
import Text from '@common/Text';

import { CHARGER_STATES, CHARGER_TYPES } from '@constants';

import type { ChargerDetails } from '../../../types';

export interface ChargerCardProps {
charger: ChargerDetails;
}

const calculateLatestUpdateTime = (latestUpdateTimeString: string) => {
const currentDate = new Date();
const latestUpdatedDate = new Date(latestUpdateTimeString);
const diffInSeconds = Math.floor((currentDate.getTime() - latestUpdatedDate.getTime()) / 1000);

if (diffInSeconds < 60) {
return `${diffInSeconds}초 전`;
}

const diffInMinutes = Math.floor(diffInSeconds / 60);

if (diffInMinutes < 60) {
return `${diffInMinutes}분 전`;
}

const diffInHours = Math.floor(diffInMinutes / 60);

if (diffInHours < 24) {
return `${diffInHours}시간 전`;
}

const diffInDays = Math.floor(diffInHours / 24);
return `${diffInDays}일 전`;
};

const ChargerCard = ({ charger }: ChargerCardProps) => {
const { type, price, capacity, latestUpdateTime, state, method } = charger;
return (
<Box border px={2} py={5} width={39}>
<FlexBox justifyContent='center' alignItems='center' css={square}>
<BoltIcon width={24} fill="#5c68d6" />
<Text>{CHARGER_STATES[state]}</Text>
</FlexBox>
<article>
<Text>{CHARGER_TYPES[type]}</Text>
<Text>{price}원/kWh</Text>
<Text>
{capacity >= 50 ? '급속' : '완속'}({capacity}kW)
</Text>
{method && <Text>{method}</Text>}
</article>
{latestUpdateTime && (
<Text variant="caption" align="right">
마지막 업데이트: {calculateLatestUpdateTime(latestUpdateTime)}
</Text>
)}
</Box>
);
};

const square = css`
padding: 0.4rem;
border-radius: 1rem;
background: #e9edf8;
`;

export default ChargerCard;
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
import type { Meta } from '@storybook/react';

import type { DetailedStationProps } from '@ui/DetailedStationInfo/DetailedStation';
import DetailedStation from '@ui/DetailedStationInfo/DetailedStation';

const meta = {
title: 'UI/DetailedStation',
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

리팩터링할 때 이름 바꾸기

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

component: DetailedStation,
tags: ['autodocs'],
args: {
station: {
stationId: 99,
stationName: '박스터 충전소',
companyName: 'CARffeine',
contact: '02-1234-5678',
chargers: [
{
type: 'DC_AC_3PHASE',
price: 200,
capacity: 3,
latestUpdateTime: '2023-07-18T15:11:40.000Z',
state: 'STANDBY',
method: '단독',
},
{
type: 'DC_COMBO',
price: 300,
capacity: 200,
latestUpdateTime: '2023-07-30T03:21:40.000Z',
state: 'UNDER_INSPECTION',
method: '단독',
},
{
type: 'DC_AC_3PHASE',
price: 350,
capacity: 50,
latestUpdateTime: '2023-07-01T03:21:40.000Z',
state: 'CHARGING_IN_PROGRESS',
method: '동시',
},
{
type: 'AC_SLOW',
price: 350,
capacity: 3,
latestUpdateTime: '2023-07-01T03:21:40.000Z',
state: 'CHARGING_IN_PROGRESS',
method: '동시',
},
{
type: 'DC_FAST',
price: 450,
capacity: 100,
latestUpdateTime: '2023-07-01T03:21:40.000Z',
state: 'STATUS_UNKNOWN',
method: '동시',
},
],
isParkingFree: true,
operatingTime: '평일 09:00~19:00 / 주말 미운영',
address: '서울 송파구 올림픽로35다길 42',
detailLocation: '지하 1층 구석탱이 어딘가',
latitude: 37.599295930415195,
longitude: 127.45404683387704,
isPrivate: true,
stationState: '2023-08-04일부터 충전소 공사합니다.',
privateReason: '박스터 차주만 충전 가능함',
reportCount: 1,
},
},
argTypes: {
station: {
description: '충전소 데이터를 수정할 수 있습니다.',
},
},
} satisfies Meta<typeof DetailedStation>;

export default meta;

export const Default = (args: DetailedStationProps) => {
return <DetailedStation {...args} />;
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
import { css, styled } from 'styled-components';

import Alert from '@common/Alert';
import Box from '@common/Box';
import FlexBox from '@common/FlexBox';
import Text from '@common/Text';

import ChargerCard from '@ui/DetailedStationInfo/ChargerCard';

import type { StationDetails } from '../../../types';

export interface DetailedStationProps {
station: StationDetails;
}

const DetailedStation = ({ station }: DetailedStationProps) => {
const {
stationName,
companyName,
contact,
chargers,
isParkingFree,
operatingTime,
address,
detailLocation,
isPrivate,
stationState,
privateReason,
reportCount,
} = station;

return (
<Box px={2} pt={10} css={containerCss}>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

여기는 어차피 수정 예정이라고 했으니 넘어갑니다~~

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

<Box my={2} px={1}>
<Text variant="label">{companyName}</Text>
<Box my={1}>
<Text variant="title">{stationName}</Text>
</Box>
<Text variant="subtitle">{address}</Text>
{detailLocation && <Text variant="caption">{detailLocation}</Text>}
</Box>
<hr />

{stationState && <Alert color="warning" text={`[공지] ${stationState}`} />}

<Box px={1}>
<Box my={1}>
<Text variant="h6">운영시간</Text>
<Text variant="body">{operatingTime ?? '운영시간 미확인'}</Text>
</Box>
<Box my={1}>
<Text variant="h6">연락처</Text>
<Text variant="body">{contact ?? '연락처 없음'}</Text>
</Box>
<Box my={1}>
<Text variant="h6">주차비</Text>
<Text variant="body">{isParkingFree ? '무료' : '유료'}</Text>
</Box>
<Box my={1}>
<Text variant="h6">사용 제한 여부</Text>
<Text variant="body">
{isPrivate || privateReason
? `사용 제한됨 (사유: ${privateReason})`
: '누구나 사용가능'}
</Text>
</Box>
</Box>

<hr />

<FlexBox>
{chargers.map((charger, index) => (
<ChargerCard key={index} charger={charger} />
))}
</FlexBox>

{reportCount > 0 && (
<Box my={1}>
<Alert color={'secondary'} text={`최근 충전기 고장 신고가 ${reportCount}번 접수됐어요`} />
</Box>
)}
</Box>
);
};

const containerCss = css`
width: 34rem;
height: 100vh;
background-color: white;
box-shadow: 1px 1px 2px gray;
`;

export default DetailedStation;
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { useSelectedStation } from '@hooks/useSelectedStation';

import Box from '@common/Box';

import DetailedStation from '@ui/DetailedStationInfo/DetailedStation';

const DetailedStationInfo = () => {
const { data: station, isLoading, isError } = useSelectedStation();

if (isLoading || isError) return <></>;

return (
<Box
css={{
position: 'fixed',
left: '41rem',
width: '34rem',
zIndex: '999',
}}
Comment on lines +14 to +19
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

나중에 분리할 것

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

>
<DetailedStation station={station} />
</Box>
);
};

export default DetailedStationInfo;
3 changes: 3 additions & 0 deletions frontend/src/components/ui/DetailedStationInfo/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import DetailedStationInfo from './DetailedStationInfo';

export default DetailedStationInfo;
Loading