-
Notifications
You must be signed in to change notification settings - Fork 2
[FE] 관리자 페이지 생성 및 api 연결 #245
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
Merged
The head ref may contain hidden characters: "20260225_#242-\uAE30\uB2A5\uCD94\uAC00\uAD00\uB9AC\uC790-\uAD00\uB9AC\uC790-\uD398\uC774\uC9C0-\uD68C\uC6D0-\uD398\uC774\uC9C0-\uAD6C\uD604"
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
7b7bbbd
[FE] 출석 세션 api 연결
sangkyu39 6e861a4
[FE] 관리자 페이지 main, 회원 관리, 가입 승인 페이지 구현
sangkyu39 4b5c582
[FE] 관리자 페이지 바로가기 추가
sangkyu39 e160411
[FE] AdminHome 파일 구조 분리
sangkyu39 d08522b
[FE] Admin 페이지 주석 처리 및 회원 api 연결
sangkyu39 8cddcaf
[FE] Admin 엑셀 업로드 기능 페이지 구현 및 api 연결
sangkyu39 e379ab0
[FE] 관리자 페이지 main, 회원 관리, 가입 승인 페이지 구현
sangkyu39 343a0bc
[FE] 관리자 페이지 바로가기 추가
sangkyu39 f397a4f
[FE] AdminHome 파일 구조 분리
sangkyu39 d8f80be
[FE] Admin 페이지 주석 처리 및 회원 api 연결
sangkyu39 e0d22c8
[FE] Admin 엑셀 업로드 기능 페이지 구현 및 api 연결
sangkyu39 1ca4a6b
[FE] PR conflicts 사항 수정
sangkyu39 130a6d7
Merge branch '20260225_#242-기능추가관리자-관리자-페이지-회원-페이지-구현' of https://git…
sangkyu39 af7df73
[FE] PR Resolve 요청사항 수정 (2)
sangkyu39 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
159 changes: 159 additions & 0 deletions
159
frontend/src/components/AdminExcelUpload/AdminExcelUpload.jsx
This file contains hidden or 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,159 @@ | ||
| import { useState } from 'react'; | ||
| import { Upload, FileSpreadsheet, Loader2, Trash2, CheckCircle } from 'lucide-react'; | ||
| import { toast } from 'react-toastify'; | ||
| import { uploadAdminUsersExcel } from '../../utils/adminUserApi'; | ||
| import AdminExcelUploadHeader from './AdminExcelUploadHeader'; | ||
| import styles from './AdminExcelUpload.module.css'; | ||
|
|
||
| const ALLOWED_EXTENSIONS = ['.xlsx', '.xls']; | ||
|
|
||
| const isExcelFile = (targetFile) => { | ||
| if (!targetFile) return false; | ||
| const lowerName = targetFile.name.toLowerCase(); | ||
| return ALLOWED_EXTENSIONS.some((ext) => lowerName.endsWith(ext)); | ||
| }; | ||
|
|
||
| const AdminExcelUpload = () => { | ||
| const [selectedFile, setSelectedFile] = useState(null); | ||
| const [isUploading, setIsUploading] = useState(false); | ||
| const [uploadResult, setUploadResult] = useState(null); | ||
| const [isDragOver, setIsDragOver] = useState(false); | ||
|
|
||
| const handleSelectFile = (file) => { | ||
| if (!file) return; | ||
|
|
||
| if (!isExcelFile(file)) { | ||
| toast.error('엑셀 파일(.xlsx, .xls)만 업로드할 수 있습니다.'); | ||
| return; | ||
| } | ||
|
|
||
| setSelectedFile(file); | ||
| setUploadResult(null); | ||
| }; | ||
|
|
||
| const handleInputChange = (event) => { | ||
| const file = event.target.files?.[0]; | ||
| handleSelectFile(file); | ||
| event.target.value = ''; | ||
| }; | ||
|
|
||
| const handleDragOver = (event) => { | ||
| event.preventDefault(); | ||
| setIsDragOver(true); | ||
| }; | ||
|
|
||
| const handleDragLeave = (event) => { | ||
| event.preventDefault(); | ||
| setIsDragOver(false); | ||
| }; | ||
|
|
||
| const handleDrop = (event) => { | ||
| event.preventDefault(); | ||
| setIsDragOver(false); | ||
| const file = event.dataTransfer.files?.[0]; | ||
| handleSelectFile(file); | ||
| }; | ||
|
|
||
| const handleUpload = async () => { | ||
| if (!selectedFile) { | ||
| toast.error('업로드할 파일을 먼저 선택해주세요.'); | ||
| return; | ||
| } | ||
|
|
||
| setIsUploading(true); | ||
| try { | ||
| const result = await uploadAdminUsersExcel({ file: selectedFile }); | ||
| setUploadResult(result); | ||
| toast.success('엑셀 명단 업로드 및 동기화가 완료되었습니다.'); | ||
| } catch (error) { | ||
| toast.error(error?.response?.data?.message || error?.message || '엑셀 업로드에 실패했습니다.'); | ||
| } finally { | ||
| setIsUploading(false); | ||
| } | ||
| }; | ||
|
|
||
| const resetFile = () => { | ||
| setSelectedFile(null); | ||
| setUploadResult(null); | ||
| }; | ||
|
|
||
| const handleDownloadTemplate = () => { | ||
| toast.info('템플릿 다운로드 기능은 준비 중입니다.'); | ||
| }; | ||
|
|
||
| return ( | ||
| <div className={styles.container}> | ||
| <AdminExcelUploadHeader onDownloadTemplate={handleDownloadTemplate} /> | ||
|
|
||
| <section className={styles.panel}> | ||
| <h2 className={styles.title}>엑셀 명단 업로드 및 동기화</h2> | ||
| <p className={styles.description}> | ||
| 회원 엑셀 파일을 업로드하면 서버에서 전체 동기화를 진행합니다. | ||
| </p> | ||
|
|
||
| <div | ||
| className={`${styles.uploadBox} ${isDragOver ? styles.uploadBoxDragOver : ''}`} | ||
| onDragOver={handleDragOver} | ||
| onDragLeave={handleDragLeave} | ||
| onDrop={handleDrop} | ||
| > | ||
| <FileSpreadsheet size={40} /> | ||
| <p className={styles.uploadText}>.xlsx 또는 .xls 파일을 드래그 앤 드롭하거나 선택하세요.</p> | ||
|
|
||
| <label className={styles.fileLabel}> | ||
| 파일 선택 | ||
| <input | ||
| type="file" | ||
| accept=".xlsx,.xls" | ||
| onChange={handleInputChange} | ||
| className={styles.fileInput} | ||
| /> | ||
| </label> | ||
|
|
||
| {selectedFile && ( | ||
| <div className={styles.selectedRow}> | ||
| <span className={styles.fileName}>{selectedFile.name}</span> | ||
| <button type="button" className={styles.ghostButton} onClick={resetFile}> | ||
| <Trash2 size={14} /> | ||
| 제거 | ||
| </button> | ||
| </div> | ||
| )} | ||
|
|
||
| <button | ||
| type="button" | ||
| className={styles.uploadButton} | ||
| onClick={handleUpload} | ||
| disabled={!selectedFile || isUploading} | ||
| > | ||
| {isUploading ? ( | ||
| <> | ||
| <Loader2 size={16} className={styles.spin} /> | ||
| 업로드 중... | ||
| </> | ||
| ) : ( | ||
| <> | ||
| <Upload size={16} /> | ||
| 업로드 실행 | ||
| </> | ||
| )} | ||
| </button> | ||
| </div> | ||
| </section> | ||
|
|
||
| {uploadResult && ( | ||
| <section className={styles.panel}> | ||
| <div className={styles.resultTitleWrap}> | ||
| <CheckCircle size={18} /> | ||
| <h3 className={styles.resultTitle}>업로드 결과</h3> | ||
| </div> | ||
| <pre className={styles.resultBox}> | ||
| {JSON.stringify(uploadResult, null, 2)} | ||
| </pre> | ||
| </section> | ||
| )} | ||
| </div> | ||
| ); | ||
| }; | ||
|
|
||
| export default AdminExcelUpload; | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.