Skip to content

Commit

Permalink
Fix : 마일리지 등록 테이블 수정(#29)
Browse files Browse the repository at this point in the history
  • Loading branch information
ohinhyuk committed Sep 6, 2023
2 parents 187fd05 + da232d6 commit e0b42a4
Show file tree
Hide file tree
Showing 11 changed files with 45 additions and 22 deletions.
5 changes: 3 additions & 2 deletions src/components/common/Filter/CategoryAutoComplete.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,17 @@ import { styled } from '@mui/system';
import { useEffect } from 'react';
import { useDispatch, useSelector } from 'react-redux';
import { setCategory } from 'src/redux/slices/filter';
import { removeDuplicates } from './Filtering';

const StyledAutocomplete = styled(Autocomplete)({
minWidth: '200px',
});

export default function CategoryAutoComplete() {
const top100Films = [
const top100Films = removeDuplicates([
'전체',
...useSelector((state) => state.filterList.categoryList.map((category) => category.name)),
];
]);

const value = useSelector((state) => state.filter.category);
const dispatch = useDispatch();
Expand Down
4 changes: 4 additions & 0 deletions src/components/common/Filter/Filtering.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ const ResponsiveFilterBox = styled(Box)({
gap: '10px',
});

export function removeDuplicates(arr) {
return [...new Set(arr)];
}

export default function Filtering() {
const tableNum = useSelector((state) => state.component.componentNum);

Expand Down
5 changes: 3 additions & 2 deletions src/components/common/Filter/ItemAutoComplete.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,17 @@ import { Autocomplete, TextField, styled } from '@mui/material';
import { useEffect } from 'react';
import { useDispatch, useSelector } from 'react-redux';
import { setCategory, setItem } from 'src/redux/slices/filter';
import { removeDuplicates } from './Filtering';

const StyledAutocomplete = styled(Autocomplete)({
minWidth: '230px',
});

export default function ItemAutoComplete() {
const top100Films = [
const top100Films = removeDuplicates([
'전체',
...useSelector((state) => state.filterList.itemList).map((item) => item.name),
];
]);
const item = useSelector((state) => state.filter.item);
const dispatch = useDispatch();

Expand Down
2 changes: 1 addition & 1 deletion src/components/common/modal/SWModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ export const engToKor = (eng) => {
case SEMESTERITEMID:
return '학기별 세부 항목 ID';
case STUDENT_ID:
return '학번';
return '학생 고유 ID';
case COUNTS:
return '등록횟수';
case POINTS:
Expand Down
1 change: 1 addition & 0 deletions src/components/modalForm/CategoryForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ export default function CategoryForm() {

case EDITCATEGORY:
axiosInstance
.patch(`/api/mileage/categories/${beforeData[ID]}`, newData)
.patch(`/api/mileage/categories/${beforeData[ID]}`, newData)
.then((res) => {
alert('카테고리가 수정되었습니다.');
Expand Down
1 change: 1 addition & 0 deletions src/components/modalForm/GlobalItemForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ export default function GlobalItemForm() {
return 'C';
}
};

const newData = {
categoryId: 106,
itemName: values[ITEM],
Expand Down
3 changes: 1 addition & 2 deletions src/components/modalForm/StudentForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ const StyleFieldBox = styled(Box)({
flexDirection: 'column',
alignItems: ' center',
margin: '30px 0px',

padding: '0px 20px',
width: '100%',
gap: '15px',
Expand All @@ -75,7 +74,6 @@ const StyleFieldForm = styled(Form)({
flexDirection: 'column',
alignItems: 'center',
margin: '30px 0px',

padding: '0px 20px',
width: '100%',
gap: '20px',
Expand Down Expand Up @@ -160,6 +158,7 @@ export default function StudentForm() {
<StyleFieldForm>
<Box sx={{ display: 'flex', width: '100%', gap: '30px' }}>
<StyleFieldBox>
{[NAME, SID, DEPARTMENT, MAJOR1, MAJOR2, YEAR, SEMESTERCOUNT].map(
{[NAME, SID, DEPARTMENT, MAJOR1, MAJOR2, YEAR, SEMESTERCOUNT].map(
(field: string, index: number) => (
<Box key={index}>
Expand Down
20 changes: 11 additions & 9 deletions src/pages/manage/student/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import SWModal from 'src/components/common/modal/SWModal';
import { EDITCATEGORY, EDITSTUDENT } from 'src/assets/data/modal/modals';
import { random } from 'lodash';
import { ReactNode } from 'react';
import { ID } from 'src/assets/data/fields';

/**
* @component [학생 관리] 게시판
Expand All @@ -43,7 +44,7 @@ export enum StudentManageBoard {
'NAME' = NAME,
'SID' = SID,
'GRADE' = GRADE,
'MOBILE' = MOBILE,

'DEPARTMENT' = DEPARTMENT,
'MAJOR' = MAJOR,
'LASTLOGINDATE' = LASTLOGINDATE,
Expand Down Expand Up @@ -166,11 +167,11 @@ const rows = [
'오인혁',
'21800446',
'4(8)',
'010-6536-6217',

'전산전자공학부',
'AI 컴퓨터공학심화',
'2022-08-21',
'2022-08-20',

<CheckBoxIcon />,
<ManageAccountsIcon />
),
Expand All @@ -179,11 +180,11 @@ const rows = [
'한시온',
'21800447',
'4(8)',
'010-6536-6217',

'전산전자공학부',
'AI 컴퓨터공학심화',
'2022-08-21',
'2022-08-20',

<CheckBoxIcon />,
<ManageAccountsIcon />
),
Expand All @@ -192,11 +193,11 @@ const rows = [
'김민수',
'21800448',
'4(8)',
'010-6536-6217',

'전산전자공학부',
'AI 컴퓨터공학심화',
'2022-08-21',
'2022-08-20',

<CheckBoxIcon />,
<ManageAccountsIcon />
),
Expand All @@ -205,11 +206,11 @@ const rows = [
'장유진',
'21800449',
'4(8)',
'010-6536-6217',

'전산전자공학부',
'AI 컴퓨터공학심화',
'2022-08-21',
'2022-08-20',

<CheckBoxIcon />,
<ManageAccountsIcon />
),
Expand Down Expand Up @@ -264,6 +265,7 @@ export default function StudentManage({
[ISCHECKED]: student[ISCHECKED],
};
return createData(
student[ID],
student[ID],
student[NAME],
student[SID],
Expand Down
17 changes: 14 additions & 3 deletions src/pages/mileage/category/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,12 @@ import { setMileageCategoryList } from 'src/redux/slices/data';
*/

export enum MileageCategoryBoard {
'NUM' = NUM,
'ID' = ID,
'CATEGORY' = CATEGORY,
'DESCRIPTION1' = DESCRIPTION1,
'DESCRIPTION2' = DESCRIPTION2,
'DESCRIPTION1' = DESCRIPTION1,
'DESCRIPTION2' = DESCRIPTION2,
'MANAGE' = MANAGE,
}

Expand All @@ -34,10 +36,12 @@ export enum MileageCategoryBoard {
*/

interface Data {
[MileageCategoryBoard.NUM]: number;
[MileageCategoryBoard.ID]: number;
[MileageCategoryBoard.CATEGORY]: string;
[MileageCategoryBoard.DESCRIPTION1]: string;
[MileageCategoryBoard.DESCRIPTION2]: string;
[MileageCategoryBoard.DESCRIPTION1]: string;
[MileageCategoryBoard.DESCRIPTION2]: string;
[MileageCategoryBoard.MANAGE]: ReactNode;
}

Expand Down Expand Up @@ -69,7 +73,7 @@ function createData(
*/
const headCells = [
{
id: [MileageCategoryBoard.NUM],
id: [MileageCategoryBoard.ID],
numeric: false,
disablePadding: true,
label: '번호',
Expand All @@ -80,6 +84,13 @@ const headCells = [
disablePadding: false,
label: '카테고리명',
},

{
id: [MileageCategoryBoard.DESCRIPTION1],
numeric: true,
disablePadding: false,
label: '설명 1',
},
{
id: [MileageCategoryBoard.DESCRIPTION1],
numeric: true,
Expand Down
4 changes: 2 additions & 2 deletions src/pages/mileage/item/semester/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -273,15 +273,15 @@ export default function MileageCategory({

const convertedFetchList = fetchData.list?.map((semesterItem) => {
const beforeData = {
[NUM]: semesterItem.item.id,
[NUM]: semesterItem.id,
[CATEGORY]: semesterItem.category.name,
[SEMESTER]: semesterItem.semesterName,
[ITEM]: semesterItem.item.name,
[MILEAGE]: semesterItem.points,
[MAX_MAILEAGE]: semesterItem.itemMaxPoints,
};
return createData(
semesterItem.item.id,
semesterItem.id,
semesterItem.category.name,
semesterItem.semesterName,
semesterItem.item.name,
Expand Down
5 changes: 4 additions & 1 deletion src/pages/mileage/register/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -197,5 +197,8 @@ export default function MileageRegister({

console.log(convertedFetchList);

return <CollapsibleTable rows={convertedFetchList} type="마일리지 등록" />;
return (
<EnhancedTable originalRows={convertedFetchList} headCells={headCells} type="마일리지 등록" />
);
// <CollapsibleTable rows={convertedFetchList} type="마일리지 등록" />;
}

0 comments on commit e0b42a4

Please sign in to comment.