diff --git a/src/components/common/CustomTable.tsx b/src/components/common/CustomTable.tsx
index ac51bf3..97992d8 100644
--- a/src/components/common/CustomTable.tsx
+++ b/src/components/common/CustomTable.tsx
@@ -316,7 +316,6 @@ export default function EnhancedTable({ originalRows, headCells, type }) {
* @field 필터링을 거치고 보여주는 값들 (rows)
*/
const [rows, setRows] = React.useState(originalRows);
- console.log('debug', rows, originalRows);
/**
* @brief 필터링 요소
diff --git a/src/components/common/modal/ModalIconButton.tsx b/src/components/common/modal/ModalIconButton.tsx
index aa26136..7a4a38b 100644
--- a/src/components/common/modal/ModalIconButton.tsx
+++ b/src/components/common/modal/ModalIconButton.tsx
@@ -2,11 +2,16 @@ import { IconButton } from '@mui/material';
import AddIcon from '@mui/icons-material/Add';
import EditIcon from '@mui/icons-material/Edit';
import DeleteIcon from '@mui/icons-material/Delete';
-import { dispatch } from 'src/redux/store';
-import { openModal } from 'src/redux/slices/modal';
+import { openModal, setBeforeData } from 'src/redux/slices/modal';
+import { useDispatch } from 'react-redux';
-export default function ModalIconButton({ type }) {
- const handleOpen = () => dispatch(openModal(type));
+export default function ModalIconButton({ type, beforeData }) {
+ const dispatch = useDispatch();
+
+ const handleOpen = () => {
+ dispatch(openModal(type));
+ dispatch(setBeforeData(beforeData));
+ };
const IconConverter = (type) => {
const slicedType = type?.slice(0, 3);
diff --git a/src/components/common/modal/SWModal.tsx b/src/components/common/modal/SWModal.tsx
index cc038b1..07246e4 100644
--- a/src/components/common/modal/SWModal.tsx
+++ b/src/components/common/modal/SWModal.tsx
@@ -78,7 +78,7 @@ import { styled } from '@mui/styles';
import CategoryForm from 'src/components/modalForm/CategoryForm';
import ModalIconButton from './ModalIconButton';
import ModalTitle from './ModalTitle';
-import { values } from 'lodash';
+import { before, values } from 'lodash';
import ItemForm from 'src/components/modalForm/GlobalItemForm';
import GlobalItemForm from 'src/components/modalForm/GlobalItemForm';
import SemesterItemForm from 'src/components/modalForm/SemesterItemForm';
@@ -112,25 +112,25 @@ const style = {
const modalForm = (modalType, beforeData) => {
switch (modalType) {
case ADDCATEGORY:
- return ;
+ return ;
case EDITCATEGORY:
- return ;
+ return ;
case ADDITEM:
- return ;
+ return ;
case EDITITEM:
- return ;
+ return ;
case ADDGLOBALITEM:
- return ;
+ return ;
case EDITGLOBALITEM:
- return ;
+ return ;
case ADDSTUDENT:
- return ;
+ return ;
case EDITSTUDENT:
- return ;
+ return ;
case ADDMILEAGEREGISTER:
- return ;
+ return ;
case EDITMILEAGEREGISTER:
- return ;
+ return ;
default:
return
default
;
@@ -209,8 +209,6 @@ export const engToKor = (eng) => {
};
export default function SWModal({ type, beforeData }) {
- console.log('debug', beforeData);
-
const dispatch = useDispatch();
const open = useSelector((state) => state.modal.isOpen);
const modalType = useSelector((state) => state.modal.modalType);
@@ -219,7 +217,7 @@ export default function SWModal({ type, beforeData }) {
return (
-
+
state.modal.beforeData);
+
const modalType = useSelector((state) => state.modal.modalType);
const router = useRouter();
diff --git a/src/components/modalForm/GlobalItemForm.tsx b/src/components/modalForm/GlobalItemForm.tsx
index dfb9ce9..00433ba 100644
--- a/src/components/modalForm/GlobalItemForm.tsx
+++ b/src/components/modalForm/GlobalItemForm.tsx
@@ -19,7 +19,6 @@ import {
MILEAGE,
DESCRIPTION1,
DESCRIPTION2,
- FILE_DESCRIPTION,
ISVISIBLE,
ISVISIBLE_STUDENT,
ISINPUT_STUDENT,
@@ -28,7 +27,7 @@ import {
ISEVALUATE_PORTFOLIO,
ISEVALUATE_FUSION,
MAX_MAILEAGE,
- NUM,
+ ID,
} from 'src/assets/data/fields';
import { useSelector } from 'react-redux';
import { ADDGLOBALITEM, EDITGLOBALITEM, EDITITEM } from 'src/assets/data/modal/modals';
@@ -63,10 +62,12 @@ const StyleFieldForm = styled(Form)({
gap: '20px',
});
-export default function GlobalItemForm({ beforeData }) {
+export default function GlobalItemForm() {
const modalType = useSelector((state) => state.modal.modalType);
- console.log(modalType, beforeData);
+ // console.log('dbug', modalType, beforeData);
+ const beforeData = useSelector((state) => state.modal.beforeData);
+ console.log('d', beforeData);
const router = useRouter();
const handleSubmit = (values, { setSubmitting, resetForm }) => {
@@ -92,7 +93,7 @@ export default function GlobalItemForm({ beforeData }) {
}
};
const newData = {
- categoryId: 1,
+ categoryId: 106,
itemName: values[ITEM],
[DESCRIPTION1]: values[DESCRIPTION1],
[DESCRIPTION2]: values[DESCRIPTION2],
@@ -106,6 +107,8 @@ export default function GlobalItemForm({ beforeData }) {
},
};
+ console.log('!', newData);
+
switch (modalType) {
case ADDGLOBALITEM:
axiosInstance
@@ -122,25 +125,23 @@ export default function GlobalItemForm({ beforeData }) {
case EDITGLOBALITEM:
axiosInstance
- .patch(`/api/mileage/items/${beforeData[NUM]}`, newData)
+ .patch(`/api/mileage/items/${beforeData[ID]}`, newData)
.then((res) => {
- alert(`글로벌 항목 ${beforeData[NUM]}번이 수정되었습니다.`);
+ alert(`글로벌 항목 ${beforeData[ID]}번이 수정되었습니다.`);
router.reload();
})
.catch((err) => alert('글로벌 항목 수정에 실패했습니다.'));
break;
}
};
+
return (
- {[CATEGORY, ITEM, DESCRIPTION1, DESCRIPTION2, FILE_DESCRIPTION].map(
- (field: string, index: number) => (
-
-
-
-
- )
- )}
+ {[CATEGORY, ITEM, DESCRIPTION1, DESCRIPTION2].map((field: string, index: number) => (
+
+
+
+
+ ))}
{[
diff --git a/src/components/modalForm/MileageRegisterForm.tsx b/src/components/modalForm/MileageRegisterForm.tsx
index 934e8f8..415f487 100644
--- a/src/components/modalForm/MileageRegisterForm.tsx
+++ b/src/components/modalForm/MileageRegisterForm.tsx
@@ -23,7 +23,9 @@ import {
import { STUDENT_ID } from 'src/assets/data/fields';
import { ADDMILEAGEREGISTER, EDITMILEAGEREGISTER } from 'src/assets/data/modal/modals';
-export default function MileageRegisterForm({ beforeData }) {
+export default function MileageRegisterForm() {
+ const beforeData = useSelector((state) => state.modal.beforeData);
+
const modalType = useSelector((state) => state.modal.modalType);
const router = useRouter();
console.log('beforeData', beforeData);
diff --git a/src/components/modalForm/SemesterItemForm.tsx b/src/components/modalForm/SemesterItemForm.tsx
index 21ef69c..2eed782 100644
--- a/src/components/modalForm/SemesterItemForm.tsx
+++ b/src/components/modalForm/SemesterItemForm.tsx
@@ -23,7 +23,8 @@ import SubmitButton from '../common/modal/SubmitButton';
import axiosInstance from 'src/utils/axios';
import { useRouter } from 'next/router';
-export default function SemesterItemForm({ beforeData }) {
+export default function SemesterItemForm() {
+ const beforeData = useSelector((state) => state.modal.beforeData);
const modalType = useSelector((state) => state.modal.modalType);
const router = useRouter();
diff --git a/src/components/modalForm/StudentForm.tsx b/src/components/modalForm/StudentForm.tsx
index a843033..2238e86 100644
--- a/src/components/modalForm/StudentForm.tsx
+++ b/src/components/modalForm/StudentForm.tsx
@@ -80,7 +80,8 @@ const StyleFieldForm = styled(Form)({
gap: '20px',
});
-export default function StudentForm({ beforeData }) {
+export default function StudentForm() {
+ const beforeData = useSelector((state) => state.modal.beforeData);
const modalType = useSelector((state) => state.modal.modalType);
console.log('debug2', modalType, beforeData);
diff --git a/src/pages/mileage/category/index.tsx b/src/pages/mileage/category/index.tsx
index 3607f95..44ef656 100644
--- a/src/pages/mileage/category/index.tsx
+++ b/src/pages/mileage/category/index.tsx
@@ -3,7 +3,6 @@ import {
MAX_MILEAGE,
MANAGE,
CHECK_BOX,
- NUM,
DESCRIPTION,
NAME,
ID,
@@ -22,7 +21,7 @@ import { setMileageCategoryList } from 'src/redux/slices/data';
*/
export enum MileageCategoryBoard {
- 'ID' = ID,
+ 'NUM' = NUM,
'CATEGORY' = CATEGORY,
'DESCRIPTION1' = DESCRIPTION1,
'DESCRIPTION2' = DESCRIPTION2,
@@ -35,7 +34,7 @@ export enum MileageCategoryBoard {
*/
interface Data {
- [MileageCategoryBoard.ID]: number;
+ [MileageCategoryBoard.NUM]: number;
[MileageCategoryBoard.CATEGORY]: string;
[MileageCategoryBoard.DESCRIPTION1]: string;
[MileageCategoryBoard.DESCRIPTION2]: string;
@@ -49,14 +48,14 @@ interface Data {
* */
function createData(
- ID: number,
+ NUM: number,
CATEGORY: string,
DESCRIPTION1: string,
DESCRIPTION2: string,
MANAGE: ReactNode
): Data {
return {
- [MileageCategoryBoard.ID]: ID,
+ [MileageCategoryBoard.NUM]: NUM,
[MileageCategoryBoard.CATEGORY]: CATEGORY,
[MileageCategoryBoard.DESCRIPTION1]: DESCRIPTION1,
[MileageCategoryBoard.DESCRIPTION2]: DESCRIPTION2,
@@ -70,7 +69,7 @@ function createData(
*/
const headCells = [
{
- id: [MileageCategoryBoard.ID],
+ id: [MileageCategoryBoard.NUM],
numeric: false,
disablePadding: true,
label: '번호',
@@ -106,7 +105,7 @@ const headCells = [
* 더미 객체
*/
const IParams = {
- [ID]: 1,
+ [NUM]: 1,
[CATEGORY]: '카테고리테스트',
[DESCRIPTION1]: '설명 테스트',
[DESCRIPTION2]: '설명 테스트',
@@ -120,7 +119,7 @@ import axiosInstance from 'src/utils/axios';
import { InferGetServerSidePropsType, GetServerSideProps } from 'next';
import MileageCategory from 'src/components/board/MileageCategory';
import { setCategoryList } from 'src/redux/slices/filter';
-import { DESCRIPTION1, CATEGORY, DESCRIPTION2 } from '../../../assets/data/fields';
+import { DESCRIPTION1, CATEGORY, DESCRIPTION2, NUM } from '../../../assets/data/fields';
interface IList {
id: number;
diff --git a/src/pages/mileage/item/global/index.tsx b/src/pages/mileage/item/global/index.tsx
index 9179193..0214168 100644
--- a/src/pages/mileage/item/global/index.tsx
+++ b/src/pages/mileage/item/global/index.tsx
@@ -2,14 +2,11 @@ import { StarIcon } from 'src/theme/overrides/CustomIcons';
import EnhancedTable from 'src/components/common/CustomTable';
import {
MILEAGE,
- ISVISIBLE,
REGISTERED_DATE,
MANAGE,
CHECK_BOX,
NUM,
- CATEGORY,
SEMESTER,
- ITEM,
DESCRIPTION,
DESCRIPTION1,
DESCRIPTION2,
@@ -21,6 +18,7 @@ import {
ISEVALUATE_PORTFOLIO,
ISEVALUATE_FUSION,
MAX_MAILEAGE,
+ NAME,
} from 'src/assets/data/fields';
import SWModal from 'src/components/common/modal/SWModal';
import { EDITGLOBALITEM, EDITITEM } from 'src/assets/data/modal/modals';
@@ -39,13 +37,13 @@ import { useEffect } from 'react';
*/
export enum MileageGlobalItemBoard {
- 'NUM' = NUM,
+ 'ID' = ID,
'CATEGORY' = CATEGORY,
-
'ITEM' = ITEM,
+ 'DESCRIPTION1' = DESCRIPTION1,
+ 'DESCRIPTION2' = DESCRIPTION2,
'ISVISIBLE' = ISVISIBLE,
- 'REGISTERED_DATE' = REGISTERED_DATE,
'MANAGE' = MANAGE,
}
@@ -55,11 +53,11 @@ export enum MileageGlobalItemBoard {
*/
interface Data {
[MileageGlobalItemBoard.CATEGORY]: string;
-
[MileageGlobalItemBoard.ITEM]: string;
+ [MileageGlobalItemBoard.DESCRIPTION1]: string;
+ [MileageGlobalItemBoard.DESCRIPTION2]: string;
[MileageGlobalItemBoard.ISVISIBLE]: boolean;
- [MileageGlobalItemBoard.REGISTERED_DATE]: string;
[MileageGlobalItemBoard.MANAGE]: string;
}
@@ -69,24 +67,26 @@ interface Data {
*
* */
function createData(
- num: number,
- category: string,
-
- item: string,
-
- isVisible: boolean,
- registeredDate: string,
- manage: string
+ ID: number,
+ CATEGORY: string,
+ ITEM: string,
+ DESCRIPTION1: string,
+ DESCRIPTION2: string,
+
+ ISVISIBLE: boolean,
+ MANAGE: string
): Data {
return {
- [MileageGlobalItemBoard.NUM]: num,
- [MileageGlobalItemBoard.CATEGORY]: category,
+ [MileageGlobalItemBoard.NUM]: ID,
+ [MileageGlobalItemBoard.CATEGORY]: CATEGORY,
- [MileageGlobalItemBoard.ITEM]: item,
+ [MileageGlobalItemBoard.ITEM]: ITEM,
- [MileageGlobalItemBoard.ISVISIBLE]: isVisible,
- [MileageGlobalItemBoard.REGISTERED_DATE]: registeredDate,
- [MileageGlobalItemBoard.MANAGE]: manage,
+ [MileageGlobalItemBoard.DESCRIPTION1]: DESCRIPTION1,
+ [MileageGlobalItemBoard.DESCRIPTION2]: DESCRIPTION2,
+
+ [MileageGlobalItemBoard.ISVISIBLE]: ISVISIBLE,
+ [MileageGlobalItemBoard.MANAGE]: MANAGE,
};
}
@@ -114,16 +114,22 @@ const headCells = [
label: '항목명',
},
{
- id: [MileageGlobalItemBoard.ISVISIBLE],
+ id: [MileageGlobalItemBoard.DESCRIPTION1],
numeric: true,
disablePadding: false,
- label: '보이기',
+ label: '설명1',
},
{
- id: [MileageGlobalItemBoard.REGISTERED_DATE],
+ id: [MileageGlobalItemBoard.DESCRIPTION2],
numeric: true,
disablePadding: false,
- label: '등록일',
+ label: '설명2',
+ },
+ {
+ id: [MileageGlobalItemBoard.ISVISIBLE],
+ numeric: true,
+ disablePadding: false,
+ label: '보이기',
},
{
id: [MileageGlobalItemBoard.MANAGE],
@@ -227,6 +233,7 @@ import axiosInstance from 'src/utils/axios';
import { InferGetServerSidePropsType, GetServerSideProps } from 'next';
import MileageCategory from 'src/components/board/MileageCategory';
import { setItemList, setSemesterList } from 'src/redux/slices/filter';
+import { ID, CATEGORY, ITEM, ISVISIBLE } from '../../../../assets/data/fields';
interface ICategory {
id: number;
@@ -262,30 +269,43 @@ export default function MileageCategory({
fetchData,
}: InferGetServerSidePropsType) {
const dispatch = useDispatch();
+ console.log('Check', fetchData);
+ const convertedFetchList = fetchData.list?.map((item, index) => {
+ const {
+ id,
+ category: { name: categoryName },
+ name: itemName,
+ description1,
+ description2,
+ isVisible,
+ isStudentVisible,
+ isMulti,
+ stuType,
+ isPortfolio,
+ } = item;
- const convertedFetchList = fetchData.items?.map((item) => {
const beforeData = {
- [NUM]: item.id,
- [CATEGORY]: item.category.name,
- [ITEM]: item.name,
- [DESCRIPTION1]: item.description1,
- [DESCRIPTION2]: item.description2,
- [FILE_DESCRIPTION]: '첨부파일 설명', // 업서야 되는 듯
- [ISVISIBLE]: true,
- [ISVISIBLE_STUDENT]: false,
+ [ID]: id,
+ [CATEGORY]: categoryName,
+ [ITEM]: itemName,
+ [DESCRIPTION1]: description1,
+ [DESCRIPTION2]: description2,
+ [ISVISIBLE]: isVisible,
+ [ISVISIBLE_STUDENT]: isStudentVisible,
[ISINPUT_STUDENT]: false,
- [ISDUPLICATE_RECORD]: false,
- [ISEVALUATE_CSEE]: item.stuType === 'F' ? false : true,
- [ISEVALUATE_PORTFOLIO]: item.isPortfolio,
- [ISEVALUATE_FUSION]: item.stuType === 'C' ? false : true,
+ [ISDUPLICATE_RECORD]: isMulti,
+ [ISEVALUATE_CSEE]: stuType === 'F' ? false : true,
+ [ISEVALUATE_PORTFOLIO]: isPortfolio,
+ [ISEVALUATE_FUSION]: stuType === 'C' ? false : true,
};
- return createData(
- item.id,
- item.category.name,
- item.name,
- true,
- '2023-08-21',
+ return createData(
+ item[ID],
+ item[CATEGORY][NAME],
+ item[NAME],
+ item[DESCRIPTION1],
+ item[DESCRIPTION2],
+ item[ISVISIBLE],
);
});
diff --git a/src/redux/slices/modal.js b/src/redux/slices/modal.js
index 9c7de37..84cbb3e 100644
--- a/src/redux/slices/modal.js
+++ b/src/redux/slices/modal.js
@@ -3,6 +3,7 @@ import { createSlice } from '@reduxjs/toolkit';
const initialState = {
isOpen: false,
modalType: null,
+ beforeData: null,
};
const slice = createSlice({
@@ -17,9 +18,12 @@ const slice = createSlice({
state.isOpen = false;
state.modalType = action.payload;
},
+ setBeforeData: (state, action) => {
+ state.beforeData = action.payload;
+ },
},
});
// Reducer
-export const { openModal, closeModal } = slice.actions;
+export const { openModal, closeModal, setBeforeData } = slice.actions;
export default slice.reducer;