Merge branch 'FE/FixBug' into 'frontend'

[Front-End] fix: 리포트 상세페이지 라우터 수정 외

See merge request s11-webmobile1-sub2/S11P12A701!171
This commit is contained in:
조현수 2024-08-12 13:34:34 +09:00
commit 5076af801e
3 changed files with 28 additions and 5 deletions

View File

@ -5,7 +5,7 @@ import EditIcon from '/src/assets/icons/edit.svg?react';
import BackIcon from '/src/assets/icons/back.svg?react';
export default function LectureForm({ title, topic, to = '..', initialValues = {}, onSubmit, onCreate = false }) {
// TODO: , useState
// TODO: , useState
const titleRef = useRef('');
const descriptionRef = useRef('');
const planRef = useRef('');
@ -24,6 +24,11 @@ export default function LectureForm({ title, topic, to = '..', initialValues = {
if (initialValues.time) timeRef.current.value = initialValues.time;
}, [initialValues]);
useEffect(() => {
console.log(imageFileRef.current.value);
console.log(imageFileRef.current && imageFileRef.current.files[0]);
}, [imageFileRef]);
const handleSubmit = async (e) => {
e.preventDefault();
@ -41,7 +46,12 @@ export default function LectureForm({ title, topic, to = '..', initialValues = {
const imageFile = (imageFileRef.current && imageFileRef.current.files[0]) ?? null;
if (imageFile) {
formData.append('image', imageFile);
const fileType = imageFile.type;
if (fileType === 'image/jpeg' || fileType === 'image/png') {
formData.append('image', imageFile);
} else {
window.alert(`${fileType}은 지원되는 파일 타입이 아닙니다. jpg / png / jpeg 이미지 파일을 첨부해 주세요`);
}
}
onSubmit(lectureObject, imageFile);
@ -126,7 +136,7 @@ export default function LectureForm({ title, topic, to = '..', initialValues = {
<input
type="file"
ref={imageFileRef}
accept=".png, .jpg, .jpeg"
accept="image/*"
className={styles.input}
/>
</div>

View File

@ -37,6 +37,11 @@ export default function QuizCard({ quiz, updateQuiz, deleteQuiz }) {
const handleFileChange = (e) => {
const file = e.target.files[0] ?? null;
const fileType = file && file.type;
if (file && fileType !== 'image/jpeg' && fileType !== 'image/png') {
window.alert(`${fileType}은 지원되는 이미지 형식이 아닙니다. jpg / png / jpeg 이미지 파일을 넣어 주세요.`);
return;
}
setImage(file);
updateQuiz(quiz.id, { ...quiz, question, answer, choices, image: file });
if (file) {
@ -78,7 +83,7 @@ export default function QuizCard({ quiz, updateQuiz, deleteQuiz }) {
<input
id={`file-input-${quiz.id}`}
type="file"
accept=".png, .jpg, .jpeg"
accept="image/*"
onChange={handleFileChange}
className={styles.hiddenInput}
/>

View File

@ -3,6 +3,7 @@ import styles from './StudentReportDetailPage.module.css';
import BackIcon from '/src/assets/icons/back.svg?react';
import { useStudentReportDetail } from '../../hooks/api/useStudentReportDetail';
import { QuizDetailCard } from '../../components/QuizForm';
import useBoundStore from '../../store';
export default function StudentReportDetailPage() {
const { lectureId, reportId } = useParams();
@ -10,11 +11,18 @@ export default function StudentReportDetailPage() {
const report = data.data;
const { allCount, correctCount, quizzes, title } = report;
const score = Math.round((100 * correctCount) / allCount);
const userType = useBoundStore((state) => state.userType);
console.log(userType);
return (
<div className={styles.wrapper}>
<header className={styles.header}>
<Link
to={`/lecture/${lectureId}/class/teacherReportsets`}
to={
userType === 'student'
? `/lecture/${lectureId}/class/report`
: `/lecture/${lectureId}/class/teacherReportsets`
}
className={styles.goBack}
>
<BackIcon />