-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6508331
commit 686d3e5
Showing
5 changed files
with
130 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import { useState } from "react"; | ||
import { Button, Form } from "semantic-ui-react" | ||
import { CsvUpload } from "@/utils/file-upload"; | ||
import { Axios } from "axios"; | ||
import { PoPoAxios } from "@/utils/axios.instance"; | ||
|
||
const CsvUploadForm = ({ label, uploadUri }) => { | ||
const [uploadedFile, setUploadedFile] = useState(null) | ||
|
||
return ( | ||
<Form> | ||
<Form.Input | ||
label={label} | ||
type={'file'} | ||
accept={'csv'} | ||
onChange={async (evt) => { | ||
const file = evt.target.files[0]; | ||
setUploadedFile(file); | ||
}} | ||
/> | ||
|
||
<Button onClick={async () => { | ||
CsvUpload(uploadUri, uploadedFile) | ||
.catch(err => { | ||
const errMsg = err.response.data.message; | ||
alert(`업로드에 실패했습니다.\n${errMsg}`); | ||
}) | ||
|
||
PoPoAxios.get('/setting/sync-rc-students-list', { withCredentials: true }) | ||
.then(res => { | ||
alert('업로드가 완료 되었습니다!'); | ||
}) | ||
.catch(err => { | ||
const errMsg = err.response.data.message; | ||
alert(`유저 목록 업데이트에 실패했습니다.\n${errMsg}`); | ||
}) | ||
}}> | ||
업로드 | ||
</Button> | ||
</Form> | ||
) | ||
} | ||
|
||
export default CsvUploadForm; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
import BoardLayout from '@/components/board/board.layout' | ||
import { PoPoAxios } from '@/utils/axios.instance'; | ||
import CsvUploadForm from '@/components/common/csv-upload.form'; | ||
import { Button } from 'semantic-ui-react'; | ||
|
||
const RcStudentsListPage = ({ popoRcStdntCnt, totalRcStdntCnt }) => { | ||
return ( | ||
<BoardLayout> | ||
<h3>RC 사생 명단 업로드</h3> | ||
<div> | ||
RC 사생에게만 RC 장소 예약을 받기 위해 RC 사생 명단 정보가 필요합니다. | ||
아래 주소에서 CSV 파일을 다운 받아 요 형식에 맞춰 입력 후, 다시 CSV 파일을 업로드 해주세요. | ||
CSV 파일이 업로드 되면, RC 사생 명단 초기화 후 업로드 된 명단에 있는 Povis ID를 가진 모든 유저를 RC 사생으로 분류합니다. | ||
만약 RC 사생 명단 업로드 후에 RC 사생이 추가로 가입한다면, 자동으로 RC 사생으로 분류됩니다. | ||
</div> | ||
|
||
<ul> | ||
<li> | ||
POPO 가입 RC 사생 수: {popoRcStdntCnt}명 ({Number((popoRcStdntCnt / totalRcStdntCnt * 100).toFixed(1))}%) | ||
</li> | ||
<li> | ||
전체 RC 사생 수: {totalRcStdntCnt}명 | ||
</li> | ||
</ul> | ||
|
||
<div style={{marginTop: 4, gap: 8}}> | ||
<Button | ||
size='tiny' | ||
href={`${PoPoAxios.getUri()}/setting/download-rc-students-list`} | ||
> | ||
CSV 다운로드 | ||
</Button> | ||
|
||
<Button | ||
size='tiny' | ||
onClick={() => { | ||
PoPoAxios.get('/setting/sync-rc-students-list', { withCredentials: true }) | ||
.then(() => { | ||
alert('싱크에 성공 했습니다.'); | ||
window.location.reload(); | ||
}) | ||
.catch((err) => { | ||
const errMsg = err.response.data.message; | ||
alert(`목록 싱크에 실패했습니다.\n${errMsg}`) | ||
}) | ||
}} | ||
> | ||
RC 사생 명단 Sync | ||
</Button> | ||
</div> | ||
|
||
<div style={{marginTop: 12}}> | ||
<CsvUploadForm | ||
label={'RC 사생 명단'} | ||
uploadUri={'/setting/rc-students-list'} | ||
/> | ||
</div> | ||
</BoardLayout> | ||
) | ||
} | ||
|
||
export default RcStudentsListPage; | ||
|
||
export async function getServerSideProps() { | ||
const res1 = await PoPoAxios.get('/user/count/RC_STUDENT'); | ||
const popoRcStdntCnt = res1.data; | ||
|
||
const res2 = await PoPoAxios.get('/setting/count-rc-students-list'); | ||
const totalRcStdntCnt = res2.data; | ||
|
||
return { props: { popoRcStdntCnt, totalRcStdntCnt } } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters