From 4dcd40ea3662ab94de02cafcbd051d06ec6dc13d Mon Sep 17 00:00:00 2001 From: subsub-e Date: Wed, 14 Aug 2024 15:41:05 +0900 Subject: [PATCH 1/8] =?UTF-8?q?[add]=20api=5Furl=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/service-cicd.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/service-cicd.yml b/.github/workflows/service-cicd.yml index 9e88b36..989ff60 100644 --- a/.github/workflows/service-cicd.yml +++ b/.github/workflows/service-cicd.yml @@ -30,6 +30,7 @@ jobs: with: args: --acl public-read --delete env: + VITE_API_URL: ${{ secrets.API_URL }} AWS_S3_BUCKET: ${{ secrets.AWS_S3_BUCKET }} AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} From 2a5faafca329d10f7681557590df65779dd41b67 Mon Sep 17 00:00:00 2001 From: subsub-e Date: Wed, 14 Aug 2024 15:41:17 +0900 Subject: [PATCH 2/8] [add] icons add --- service/src/assets/icons/imageAddIcon.svg | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 service/src/assets/icons/imageAddIcon.svg diff --git a/service/src/assets/icons/imageAddIcon.svg b/service/src/assets/icons/imageAddIcon.svg new file mode 100644 index 0000000..518b453 --- /dev/null +++ b/service/src/assets/icons/imageAddIcon.svg @@ -0,0 +1,3 @@ + + + From 6d356f0525d25bc4e2c9d3dc320e5f5af60ea2ad Mon Sep 17 00:00:00 2001 From: subsub-e Date: Wed, 14 Aug 2024 15:41:32 +0900 Subject: [PATCH 3/8] [feat] BlackButton component --- .../src/components/buttons/BlackButton.jsx | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 service/src/components/buttons/BlackButton.jsx diff --git a/service/src/components/buttons/BlackButton.jsx b/service/src/components/buttons/BlackButton.jsx new file mode 100644 index 0000000..3861fc9 --- /dev/null +++ b/service/src/components/buttons/BlackButton.jsx @@ -0,0 +1,20 @@ +import React from 'react'; +import PropTypes from 'prop-types'; + +function BlackButton({ onClickFunc }) { + return ( + + ); +} + +BlackButton.propTypes = { + onClickFunc: PropTypes.func.isRequired, +}; + +//memo를 이용하여 rerender 방지 +export default React.memo(BlackButton); From 49d09121a6776c8c4cab6dddef036fd3be450fc5 Mon Sep 17 00:00:00 2001 From: subsub-e Date: Wed, 14 Aug 2024 15:41:51 +0900 Subject: [PATCH 4/8] =?UTF-8?q?[fix]=20admin=20router=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- service/src/router.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/service/src/router.jsx b/service/src/router.jsx index 935fde1..0f23cc0 100644 --- a/service/src/router.jsx +++ b/service/src/router.jsx @@ -11,7 +11,7 @@ import MiniQuizResult from '@/pages/miniquiz/MiniQuizResult'; import NoQuiz from '@/pages/miniquiz/NoQuiz'; import Reward from '@/pages/joinEvent/Reward'; import AdminIndex from '@/pages/admin/AdminIndex'; -import AdminEditEvent from '@/pages/admin/AdminEditEvent'; +import AdminEditEvent from '@/pages/admin/adminEditEvent/AdminEditEvent'; const router = createBrowserRouter([ { From b2773e41ab3062b9a4bdf024df5b15f5116d17e8 Mon Sep 17 00:00:00 2001 From: subsub-e Date: Wed, 14 Aug 2024 15:42:20 +0900 Subject: [PATCH 5/8] =?UTF-8?q?[fix]=20AdminEditEvent=20=EC=BB=B4=ED=8F=AC?= =?UTF-8?q?=EB=84=8C=ED=8A=B8=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- service/src/pages/admin/AdminEditEvent.jsx | 7 ------- .../pages/admin/adminEditEvent/AdminEditEvent.jsx | 14 ++++++++++++++ 2 files changed, 14 insertions(+), 7 deletions(-) delete mode 100644 service/src/pages/admin/AdminEditEvent.jsx create mode 100644 service/src/pages/admin/adminEditEvent/AdminEditEvent.jsx diff --git a/service/src/pages/admin/AdminEditEvent.jsx b/service/src/pages/admin/AdminEditEvent.jsx deleted file mode 100644 index 8bb8aa5..0000000 --- a/service/src/pages/admin/AdminEditEvent.jsx +++ /dev/null @@ -1,7 +0,0 @@ -import React from 'react'; - -function AdminEditEvent() { - return
ddd
; -} - -export default AdminEditEvent; diff --git a/service/src/pages/admin/adminEditEvent/AdminEditEvent.jsx b/service/src/pages/admin/adminEditEvent/AdminEditEvent.jsx new file mode 100644 index 0000000..90ab7fb --- /dev/null +++ b/service/src/pages/admin/adminEditEvent/AdminEditEvent.jsx @@ -0,0 +1,14 @@ +import React from 'react'; +import AdminEditMiniQuiz from './adminEditMiniQuiz/AdminEditMiniQuiz'; +import AdminEditMiniQuizAnswer from './adminEditMiniQuizAnswer/AdminEditMiniQuizAnswer'; + +function AdminEditEvent() { + return ( +
+ + +
+ ); +} + +export default AdminEditEvent; From 5ed709922a4b91d5b222e8b2240d126846853f2d Mon Sep 17 00:00:00 2001 From: subsub-e Date: Wed, 14 Aug 2024 15:42:35 +0900 Subject: [PATCH 6/8] =?UTF-8?q?[feat]=20AdminEditHeader=20=EA=B3=B5?= =?UTF-8?q?=ED=86=B5=20=EC=BB=B4=ED=8F=AC=EB=84=8C=ED=8A=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../admin/adminEditEvent/AdminEditHeader.jsx | 51 +++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 service/src/pages/admin/adminEditEvent/AdminEditHeader.jsx diff --git a/service/src/pages/admin/adminEditEvent/AdminEditHeader.jsx b/service/src/pages/admin/adminEditEvent/AdminEditHeader.jsx new file mode 100644 index 0000000..7007270 --- /dev/null +++ b/service/src/pages/admin/adminEditEvent/AdminEditHeader.jsx @@ -0,0 +1,51 @@ +import React, { useState } from 'react'; +import PropTypes from 'prop-types'; +import NextDayArrow from '@/assets/icons/nextDayArrow.svg'; +import PreviousDayArrow from '@/assets/icons/previousDayArrow.svg'; + +function AdminEditMiniQuizHeader({ info, date, setDate }) { + const [isPreviousDayDisabled, setIsPreviousDayDisabled] = useState( + date === 1, + ); + const handlePrev = () => { + if (isPreviousDayDisabled) { + return; + } + setDate(prev => prev - 1); + setIsPreviousDayDisabled(date < 3); + }; + const handleNext = () => { + setDate(prev => prev + 1); + setIsPreviousDayDisabled(false); + }; + return ( +
+ + {info} + +
+ PreviousDayArrow + Day {date} + NextDayArrow +
+
+ ); +} + +AdminEditMiniQuizHeader.propTypes = { + info: PropTypes.string.isRequired, + date: PropTypes.number, + setDate: PropTypes.func, +}; + +export default AdminEditMiniQuizHeader; From cb647c02aeda2acd6a3ec309e02d4dbaca05d7b3 Mon Sep 17 00:00:00 2001 From: subsub-e Date: Wed, 14 Aug 2024 15:42:49 +0900 Subject: [PATCH 7/8] =?UTF-8?q?[feat]=20AdminEditMiniQuiz=20=EC=BB=B4?= =?UTF-8?q?=ED=8F=AC=EB=84=8C=ED=8A=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../adminEditMiniQuiz/AdminEditMiniQuiz.jsx | 50 +++++++++++++++++++ .../AdminEditMiniQuizContent.jsx | 49 ++++++++++++++++++ 2 files changed, 99 insertions(+) create mode 100644 service/src/pages/admin/adminEditEvent/adminEditMiniQuiz/AdminEditMiniQuiz.jsx create mode 100644 service/src/pages/admin/adminEditEvent/adminEditMiniQuiz/AdminEditMiniQuizContent.jsx diff --git a/service/src/pages/admin/adminEditEvent/adminEditMiniQuiz/AdminEditMiniQuiz.jsx b/service/src/pages/admin/adminEditEvent/adminEditMiniQuiz/AdminEditMiniQuiz.jsx new file mode 100644 index 0000000..421cbf6 --- /dev/null +++ b/service/src/pages/admin/adminEditEvent/adminEditMiniQuiz/AdminEditMiniQuiz.jsx @@ -0,0 +1,50 @@ +import React, { useState, useEffect } from 'react'; +import AdminEditHeader from '../AdminEditHeader'; +import AdminEditMiniQuizContent from './AdminEditMiniQuizContent'; +import BlackButton from '@/components/buttons/BlackButton'; + +function AdminEditMiniQuiz() { + const [date, setDate] = useState(1); + const [quizData, setQuizData] = useState({ + id: 1, + quiz_date: '2024-08-14', + quiz_description: '오늘의 퀴즈는?? 두둥탁!!', + quiz_question_1: '참맛참맛참맛', + quiz_question_2: '보쌈보쌈보쌈', + quiz_question_3: '하이하이하이하이', + quiz_question_4: '이승섭은 롤을 잘해!', + }); + + const handleChange = (field, value) => { + setQuizData(prevState => ({ + ...prevState, + [field]: value, + })); + }; + + const handleSubmit = async () => { + // try { + // const response = await axios.put(`/api/quiz/${quizData.id}`, quizData); + // console.log('수정된 데이터가 서버에 저장되었습니다.', response.data); + // } catch (error) { + // console.error('수정 요청 중 오류가 발생했습니다.', error); + // } + console.log('ddd'); + }; + + return ( +
+ +
+ + +
+
+ ); +} + +export default AdminEditMiniQuiz; diff --git a/service/src/pages/admin/adminEditEvent/adminEditMiniQuiz/AdminEditMiniQuizContent.jsx b/service/src/pages/admin/adminEditEvent/adminEditMiniQuiz/AdminEditMiniQuizContent.jsx new file mode 100644 index 0000000..470fbcd --- /dev/null +++ b/service/src/pages/admin/adminEditEvent/adminEditMiniQuiz/AdminEditMiniQuizContent.jsx @@ -0,0 +1,49 @@ +import React from 'react'; +import PropTypes from 'prop-types'; + +function AdminEditMiniQuizContent({ response, onChange }) { + return ( + <> +
+ + onChange('quiz_description', e.target.value)} + /> +
+ + {[1, 2, 3, 4].map(num => ( +
+ + onChange(`quiz_question_${num}`, e.target.value)} + /> +
+ ))} + + ); +} + +AdminEditMiniQuizContent.propTypes = { + response: PropTypes.object.isRequired, + onChange: PropTypes.func.isRequired, +}; + +export default AdminEditMiniQuizContent; From e5283ff060c6025f3872db1eafa7ecd23b0b9306 Mon Sep 17 00:00:00 2001 From: subsub-e Date: Wed, 14 Aug 2024 15:43:07 +0900 Subject: [PATCH 8/8] =?UTF-8?q?[feat]=20AdminEditMiniQuizAnswer=20?= =?UTF-8?q?=EC=BB=B4=ED=8F=AC=EB=84=8C=ED=8A=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../AdminEditMiniQuizAnswer.jsx | 50 +++++++++++ .../AdminEditMiniQuizAnswerContent.jsx | 86 +++++++++++++++++++ 2 files changed, 136 insertions(+) create mode 100644 service/src/pages/admin/adminEditEvent/adminEditMiniQuizAnswer/AdminEditMiniQuizAnswer.jsx create mode 100644 service/src/pages/admin/adminEditEvent/adminEditMiniQuizAnswer/AdminEditMiniQuizAnswerContent.jsx diff --git a/service/src/pages/admin/adminEditEvent/adminEditMiniQuizAnswer/AdminEditMiniQuizAnswer.jsx b/service/src/pages/admin/adminEditEvent/adminEditMiniQuizAnswer/AdminEditMiniQuizAnswer.jsx new file mode 100644 index 0000000..05c9168 --- /dev/null +++ b/service/src/pages/admin/adminEditEvent/adminEditMiniQuizAnswer/AdminEditMiniQuizAnswer.jsx @@ -0,0 +1,50 @@ +import React, { useState, useEffect } from 'react'; +import AdminEditHeader from '../AdminEditHeader'; +import AdminEditMiniQuizAnswerContent from './AdminEditMiniQuizAnswerContent'; +import BlackButton from '@/components/buttons/BlackButton'; + +function AdminEditMiniQuizAnswer() { + const [date, setDate] = useState(1); + const [quizAnswerData, setAnswerData] = useState({ + id: 1, + answer_num: 1, + quiz_image: + 'https://softeer4-team8.s3.ap-northeast-2.amazonaws.com/%E1%84%8C%E1%85%A1%E1%84%8C%E1%85%A5%E1%86%AB%E1%84%80%E1%85%A5.svg', + }); + + const handleChange = (field, value) => { + setAnswerData(prevState => ({ + ...prevState, + [field]: value, + })); + }; + + const handleSubmit = async () => { + // try { + // const response = await axios.put(`/api/quiz/${quizAnswerData.id}`, quizAnswerData); + // console.log('수정된 데이터가 서버에 저장되었습니다.', response.data); + // } catch (error) { + // console.error('수정 요청 중 오류가 발생했습니다.', error); + // } + console.log('dddd'); + }; + + return ( +
+ +
+ + +
+
+ ); +} + +export default AdminEditMiniQuizAnswer; diff --git a/service/src/pages/admin/adminEditEvent/adminEditMiniQuizAnswer/AdminEditMiniQuizAnswerContent.jsx b/service/src/pages/admin/adminEditEvent/adminEditMiniQuizAnswer/AdminEditMiniQuizAnswerContent.jsx new file mode 100644 index 0000000..6147506 --- /dev/null +++ b/service/src/pages/admin/adminEditEvent/adminEditMiniQuizAnswer/AdminEditMiniQuizAnswerContent.jsx @@ -0,0 +1,86 @@ +import React, { useState } from 'react'; +import PropTypes from 'prop-types'; +import ImageAddIcon from '@/assets/icons/imageAddIcon.svg'; + +function AdminEditMiniQuizAnswerContent({ response, onChange }) { + const [imagePreview, setImagePreview] = useState(response.quiz_image || ''); + + const handleImageChange = e => { + const file = e.target.files[0]; + if ( + file && + (file.type === 'image/png' || + file.type === 'image/jpg' || + file.type === 'image/jpeg') + ) { + const reader = new FileReader(); + reader.onloadend = () => { + setImagePreview(reader.result); + onChange('quiz_image', file); // 파일 자체를 상태로 보냅니다. + }; + reader.readAsDataURL(file); + } else { + alert('PNG 또는 JPG 형식의 이미지만 업로드 가능합니다.'); + } + }; + + return ( + <> +
+ + onChange('answer_num', e.target.value)} + /> +
+
+
+ +

+ 포맷: jpg/ png/ jpeg +

+
+
+ {imagePreview && ( + Preview + )} + ImageAddIcon + +
+
+ + ); +} + +AdminEditMiniQuizAnswerContent.propTypes = { + response: PropTypes.object.isRequired, + onChange: PropTypes.func.isRequired, +}; + +export default AdminEditMiniQuizAnswerContent;