Skip to content

Commit

Permalink
Fix: 엑셀 다운로드 안되던 버그 수정(#71)
Browse files Browse the repository at this point in the history
  • Loading branch information
ohinhyuk committed Oct 31, 2023
1 parent 04ec951 commit 8e2d07a
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 18 deletions.
13 changes: 7 additions & 6 deletions src/components/excel/ExcelExport.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,11 @@ export default function ExcelExport() {

const handleExcelExport = (e, endPoint) => {
console.log(e.target.id, endPoint);
setMenuButton(0);
// axiosInstance.get(endPoint).then((res) => {
// console.log(res);
// alert(`${e.target.id} 다운로드가 완료되었습니다.`);
// });
// setMenuButton(0);
axiosInstance.get(endPoint).then((res) => {
console.log(res);
alert(`${e.target.id} 다운로드가 완료되었습니다.`);
});
};

return (
Expand All @@ -49,8 +49,9 @@ export default function ExcelExport() {
* @brief 엑셀 다운로드 버튼
* @description Link Masking (서버의 링크를 숨긴다.)
*/
<Link key={index} as="/" href={'http://walab.handong.edu:8080/sw_mileage' + Excel.endPoint}>
<Link key={index} href={'http://walab.handong.edu:8080/sw_mileage' + Excel.endPoint}>
<Button
type="button"
variant="contained"
id={Excel.name}
onClick={(e) => handleExcelExport(e, Excel.endPoint)}
Expand Down
8 changes: 5 additions & 3 deletions src/pages/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,18 @@ import {
} from 'src/redux/slices/filterList';
import { useEffect } from 'react';
import { useRouter } from 'next/router';
import { set } from 'lodash';
import { setServerSideCookie } from 'src/auth/jwtCookie';
// ----------------------------------------------------------------------

// ----------------------------------------------------------------------

export const getServerSideProps = async () => {
export const getServerSideProps = async (context) => {
setServerSideCookie(context);

const resCategory = await axiosInstance.get('/api/mileage/categories');
const categoryData = await resCategory.data;

// console.log(categoryData);

const resGlobalItem = await axiosInstance.get('/api/mileage/items');
const globalItemData = await resGlobalItem.data;

Expand Down
4 changes: 3 additions & 1 deletion src/pages/manage/student/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import { random } from 'lodash';
import { ReactNode } from 'react';
import { ID } from 'src/assets/data/fields';

import { setServerSideCookie } from 'src/auth/jwtCookie';
/**
* @component [학생 관리] 게시판
*/
Expand Down Expand Up @@ -247,7 +248,8 @@ interface IStudentList {

export const getServerSideProps: GetServerSideProps<{
fetchData: IStudentList;
}> = async () => {
}> = async (context) => {
setServerSideCookie(context);
// const res = await fetch(`${process.env.NEXT_PUBLIC_HOST_API_KEY}/api/mileage/categories`);
const res = await axiosInstance.get(`/api/mileage/students`);
const fetchData = res.data;
Expand Down
5 changes: 3 additions & 2 deletions src/pages/manage/user/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import axiosInstance from 'src/utils/axios';
import { MOD_DATE } from '../../../assets/data/fields';
import SWModal from 'src/components/common/modal/SWModal';
import { EDITMANAGER } from 'src/assets/data/modal/modals';

import { setServerSideCookie } from 'src/auth/jwtCookie';
/**
* @component [사용자 관리] 게시판
*/
Expand Down Expand Up @@ -144,7 +144,8 @@ const rows = [

export const getServerSideProps: GetServerSideProps<{
fetchData: any;
}> = async () => {
}> = async (context) => {
setServerSideCookie(context);
// const res = await fetch(`${process.env.NEXT_PUBLIC_HOST_API_KEY}/api/mileage/categories`);
const res = await axiosInstance.get('/api/mileage/admins');
const fetchData = res.data;
Expand Down
5 changes: 3 additions & 2 deletions src/pages/mileage/item/global/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,7 @@ 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, SEMESTER_ITEM_COUNT } from '../../../../assets/data/fields';
import { setServerSideCookie } from 'src/auth/jwtCookie';

interface ICategory {
id: number;
Expand All @@ -275,8 +276,8 @@ interface IGlobalItemList {

export const getServerSideProps: GetServerSideProps<{
fetchData: IGlobalItemList;
}> = async () => {
// const res = await fetch(`${process.env.NEXT_PUBLIC_HOST_API_KEY}/api/mileage/categories`);
}> = async (context) => {
setServerSideCookie(context);
const res = await axiosInstance.get('/api/mileage/items');
const fetchData = res.data;
console.log(fetchData);
Expand Down
6 changes: 4 additions & 2 deletions src/pages/mileage/item/semester/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import { useEffect } from 'react';
import { setMileageSemesterList } from 'src/redux/slices/data';
import axiosInstance from 'src/utils/axios';
import { CATEGORY, SEMESTER, ITEM, POINTS, MANAGE } from '../../../../assets/data/fields';
import { setServerSideCookie } from 'src/auth/jwtCookie';

/**
* @component [마일리지 학기별 항목] 게시판
Expand Down Expand Up @@ -264,8 +265,9 @@ export interface ISemesterItemList {

export const getServerSideProps: GetServerSideProps<{
fetchData: ISemesterItemList;
}> = async () => {
// const res = await fetch(`${process.env.NEXT_PUBLIC_HOST_API_KEY}/api/mileage/categories`);
}> = async (context) => {
setServerSideCookie(context);

const res = await axiosInstance.get(`/api/mileage/semesters/2022-01/items`);
const fetchData = res.data;
console.log(fetchData);
Expand Down
6 changes: 4 additions & 2 deletions src/pages/mileage/register/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ import CRUDStudentTable from 'src/components/common/Table/CRUDStudentTable';
import DeleteIcon from '@mui/icons-material/DeleteOutlined';
import { IconButton, Tooltip } from '@mui/material';
import { Box } from '@mui/system';
import { setServerSideCookie } from 'src/auth/jwtCookie';

/**
* @component [마일리지 등록] 게시판
Expand Down Expand Up @@ -182,7 +183,8 @@ const headCells = [

export const getServerSideProps: GetServerSideProps<{
fetchData: ISemesterItemList;
}> = async () => {
}> = async (context) => {
setServerSideCookie(context);
// const res = await fetch(`${process.env.NEXT_PUBLIC_HOST_API_KEY}/api/mileage/categories`);
const res = await axiosInstance.get('/api/mileage/semesters/2022-01/items');
const fetchData = res.data;
Expand Down Expand Up @@ -272,7 +274,7 @@ export default function MileageRegister({
alert(` ${item.student.name} - ${item.student.sid} 가 삭제 되었습니다.`);
});
});
});
});
}
};
const convertedFetchList = fetchData.list?.map((semesterItem, index) => {
Expand Down

0 comments on commit 8e2d07a

Please sign in to comment.