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

AB테스트 기능 구현 #48

Merged
merged 10 commits into from
Sep 14, 2024
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
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
6 changes: 6 additions & 0 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@ import OwnerList from 'pages/UserManage/Owner/OwnerList';
import OwnerRequestList from 'pages/UserManage/OwnerRequest/OwnerRequestList';
import OwnerRequestDetail from 'pages/UserManage/OwnerRequest/OwnerRequestDetail';
import OwnerDetail from 'pages/UserManage/Owner/OwnerDetail';
import ABTest from 'pages/ABTest';
import ABTestDetail from 'pages/ABTest/components/ABTestDetail';
import ReviewList from 'pages/Services/Review/ReviewList';
import ABTestTest from 'pages/ABTest/test/test';

function RequireAuth() {
const location = useLocation();
Expand Down Expand Up @@ -57,6 +60,9 @@ function App() {
<Route path="/owner-request/:id" element={<OwnerRequestDetail />} />
<Route path="/member" element={<MemberList />} />
<Route path="/member/:id" element={<MemberDetail />} />
<Route path="/abtest" element={<ABTest />} />
<Route path="/abtest/:id" element={<ABTestDetail />} />
<Route path="/abtest/test" element={<ABTestTest />} />
<Route path="/review" element={<ReviewList />} />
<Route path="*" element={<h1>404</h1>} />
</Route>

Choose a reason for hiding this comment

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

코드 검토 결과, 몇 가지 개선 사항을 제안합니다.

  1. 중복된 경로 확인: ABTest와 관련된 컴포넌트의 경로가 추가되었지만, 이러한 경로에 대한 중복이나 다른 경로와의 충돌이 발생하지 않는지 확인해야 합니다.
  2. 컴포넌트 명명 규칙: ABTestTest와 같은 이름은 혼동을 줄 수 있으므로 의미를 잘 전달하는 이름으로 변경하는 것이 좋습니다.

개선 사항을 아래와 같이 제안합니다:

@@ -4,7 +4,6 @@ import ABTest from 'pages/ABTest';
 import OwnerRequestList from 'pages/UserManage/OwnerRequest/OwnerRequestList';
 import OwnerRequestDetail from 'pages/UserManage/OwnerRequest/OwnerRequestDetail';
 import OwnerDetail from 'pages/UserManage/Owner/OwnerDetail';
-import ABTest from 'pages/ABTest';
+import ABTestMain from 'pages/ABTest';
 import ABTestDetail from 'pages/ABTest/components/ABTestDetail';
-import ABTestTest from 'pages/ABTest/test/test';
+import ABTestTestComponent from 'pages/ABTest/test/test';
 
         <Route path="/abtest" element={<ABTestMain />} />
         <Route path="/abtest/:id" element={<ABTestDetail />} />
-        <Route path="/abtest/test" element={<ABTestTest />} />
+        <Route path="/abtest/test" element={<ABTestTestComponent />} />

이렇게 수정함으로써 코드의 가독성을 높이고, 의도를 더 명확하게 전달할 수 있습니다.

Expand Down
78 changes: 51 additions & 27 deletions src/components/common/CustomTable/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Empty, Table } from 'antd';
import { CheckCircleOutlined, CloseCircleOutlined, SyncOutlined } from '@ant-design/icons';
import { Empty, Table, Tag } from 'antd';
import Pagination from 'antd/es/pagination';
import type { ColumnsType } from 'antd/es/table';
import { TITLE_MAPPER } from 'constant';
Expand Down Expand Up @@ -43,44 +44,67 @@ interface Props<TableData> {
onChange: (idx: number) => void;
};
columnSize?: number[];
hiddenColumns?: string[];
}

function CustomTable<TableData extends DefaultTableData>(
{ data, pagination, columnSize }: Props<TableData>,
) {
function CustomTable<TableData extends DefaultTableData>({
data, pagination, columnSize, hiddenColumns = [],
}: Props<TableData>) {
const navigate = useNavigate();

const getColumns = (): ColumnsType<TableData> => {
const columnKeys = Object.keys(data[0]);

return columnKeys.map((key, idx) => ({
title: TITLE_MAPPER[key] || key.toUpperCase(),
dataIndex: key,
key,
width: columnSize && columnSize[idx] ? `${columnSize[idx]}%` : 'auto',
render: (value: string | number | boolean) => {
if (typeof value === 'boolean') {
return value ? 'True' : 'False';
}

if (typeof value === 'number') {
return value || '-';
}
return columnKeys
.filter((key) => !hiddenColumns.includes(key))
.map((key, idx) => ({
title: TITLE_MAPPER[key] || key.toUpperCase(),
dataIndex: key,
key,
width: columnSize && columnSize[idx] ? `${columnSize[idx]}%` : 'auto',
render: (value: string | number | boolean) => {
if (typeof value === 'boolean') {
return value ? 'True' : 'False';
}

if (typeof value === 'string') {
if (value.startsWith('https://')) {
return <TableItemImage src={value} alt="icon" />;
if (typeof value === 'number') {
return value || '-';
}

if (longDateRegExp.test(value)) {
return toDateStringFormat(value);
if (typeof value === 'string') {
if (value.startsWith('https://')) {
return <TableItemImage src={value} alt="icon" />;
}

if (longDateRegExp.test(value)) {
return toDateStringFormat(value);
}
}
}
return value;
},
}));
if (key === 'status') {
if (value === 'IN_PROGRESS') {
return (
<Tag icon={<SyncOutlined spin />} color="processing">
{value}
</Tag>
);
} if (value === 'COMPLETED') {
return (
<Tag icon={<CheckCircleOutlined />} color="success">
{value}
</Tag>
);
}
return (
<Tag icon={<CloseCircleOutlined />} color="error">
{value}
</Tag>
);
}

return value;
},
}));
};
// const hasData = data.length > 0;

return (
<TableContainer>
Expand Down
7 changes: 6 additions & 1 deletion src/components/common/SideNav/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import {
AppstoreOutlined, UserOutlined, CarOutlined, ShopOutlined,
HomeOutlined, UserSwitchOutlined,
UsergroupDeleteOutlined, FolderOpenOutlined, ControlOutlined,
UserAddOutlined, BoldOutlined, SnippetsOutlined,
UserAddOutlined, BoldOutlined, ApartmentOutlined, SnippetsOutlined,
} from '@ant-design/icons';
import { Menu, MenuProps } from 'antd';
import { Link, useLocation, useNavigate } from 'react-router-dom';
Expand Down Expand Up @@ -43,6 +43,11 @@ const items: MenuProps['items'] = [
getItem('사장님 권한 요청', '/owner-request', <UserAddOutlined />),
getItem('BCSD Lab', '/member', <BoldOutlined />),
]),

getItem('테스트', 'test', <ControlOutlined />, [
getItem('AB 테스트', '/abtest', <ApartmentOutlined />),
getItem('AB 테스트의 테스트 페이지', '/abtest/test', <ApartmentOutlined />),
]),
];

const SideNavConatiner = styled.nav`

Choose a reason for hiding this comment

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

코드를 검토한 결과, 몇 가지 개선 사항과 오류를 발견했습니다. 다음은 주요 사항과 개선 제안입니다.

주요 사항

  1. 아이콘 이름: 기존의 SnippetsOutlined 아이콘 아래에 추가된 ApartmentOutlined가 적절한 것인지 확인이 필요합니다.
  2. 주석 없음: 코드가 품질 유지와 이해를 위해 명확한 주석이 부족합니다.
  3. 컴포넌트 명: SideNavConatiner라는 변수명에서 오타가 있습니다. 올바른 철자는 SideNavContainer입니다.

개선 제안

- const SideNavConatiner = styled.nav`
+ const SideNavContainer = styled.nav`

이 외에도 아이콘 사용 및 코드에 대한 설명을 추가하는 것을 고려할 수 있습니다. 코드를 더 명확하고 가독성 있게 만들기 위해 주석을 추가하세요.

Expand Down
94 changes: 94 additions & 0 deletions src/model/abTest.model.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
export interface Test {
id: number;
status: 'IN_PROGRESS' | 'COMPLETED' | string;
winner_name: string;
creator: string;
team: string;
display_title: string;
title: string;
created_at: string;
updated_at: string;
}

export interface ABTestResponse {
tests: Test[];
total_count: number;
current_count: number;
total_page: number;
current_page: number;
}

export interface ABTest {
display_title: string;
creator: string;
team: string;
title: string;
description: string;
variables: {
rate: number;
display_name: string;
name: string;
}[]
}

export interface NewABTestResponse {
id: number;
display_title: string;
creator: string;
team: string;
status: 'IN_PROGRESS' | 'COMPLETED' | string;
winner_name: string | null;
title: string;
description: string;
variables: {
rate: number;
display_name: string;
name: string;
}[]
created_at: string;
updated_at: string;
}

export interface ModifyABTest {
id: string | number;
data: Partial<ABTest>;
}

export interface ABTestUser {
id: string;
name: string;
detail: string;
}

export interface ABTestUsersResponse {
users: ABTestUser[]
}
export interface ABTestUserUserID {
id: string | number;
type: string;
model: string;
last_accessed_at: string;
}

export interface ABTestUserUserIDResponse {
devices: ABTestUserUserID[]
}

export interface ABTestUserMoveRequest {
id: string | number;
data: {
device_id: string | number;
variable_name: string | number;
}
}

// 테스트
export interface ABTestAssignRequest {
title: string;
access_history_id: number | string | null ;
}

export interface ABTestAssignResponse {
variable_name: string,
access_history_id: number
}
10 changes: 10 additions & 0 deletions src/pages/ABTest/ABTest.style.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import styled from 'styled-components';

export const Container = styled.div``;

export const Heading = styled.h1`
font-size: 30px;
font-weight: 700;
color: #404040;
padding: 12px 0 0 12px;
`;

Choose a reason for hiding this comment

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

코드를 검토해본 결과, 문법적으로 큰 오류는 없으나 스타일링 관점에서 개선할 부분이 있습니다. 현재 Container 컴포넌트는 빈 스타일을 가지고 있어 의미가 적습니다. 상위 레이아웃에 대한 기본적인 스타일을 설정하는 것이 좋겠습니다. 또한, Heading의 폰트 사이즈 및 색상을 좀 더 일관되게 유지하면 가독성이 향상될 수 있습니다.

다음은 개선사항에 대한 제안입니다:

@@ -1,10 +1,12 @@
 import styled from 'styled-components';
 
 export const Container = styled.div`
+  max-width: 1200px;
+  margin: 0 auto;
   padding: 20px;
 `;
 
 export const Heading = styled.h1`
   font-size: 36px; // 통일된 기준으로 변경
   font-weight: 700;
   color: #333; // 더 어두운 색으로 변경하여 가독성 증가
   padding: 12px 0 0 12px;
 `;

개선 사항 설명:

  • Container 컴포넌트에 최대 너비와 중앙 정렬을 추가하여 레이아웃의 일관성을 높였습니다.
  • Heading의 폰트 사이즈를 약간 키우고 색상을 조정하여 가독성을 개선했습니다.

Loading
Loading