Skip to content

Commit

Permalink
[#95]Chore: 자잘한 css 수정 및 map tree 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
gilyeon00 committed May 30, 2023
1 parent 32c6659 commit a1b4fdd
Show file tree
Hide file tree
Showing 17 changed files with 125 additions and 37 deletions.
Binary file added public/assets/images/tree1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/assets/images/tree2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/assets/images/tree3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/assets/images/tree4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions src/components/Mission/Quiz.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ import { React } from 'react';
import { useNavigate } from 'react-router-dom';
import './quiz.css'

const Quiz = ({missionId, mapNum, missionNum, title, explain, answer }) => {
const Quiz = ({missionPk, mapNum, missionNum, title, explain, answer }) => {
const navigate = useNavigate();

const handleAnswerClick = (isO) => {
navigate(`/kid/solution/${missionId}`, { state: { isO, explain, mapNum, missionNum, answer , title} });
navigate(`/kid/solution/${missionPk}`, { state: { isO, explain, mapNum, missionNum, answer , title} });
};

return (
Expand Down
8 changes: 5 additions & 3 deletions src/components/Mission/Vod.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ import confetti from "https://esm.run/canvas-confetti@1";
import { useNavigate, useParams } from "react-router-dom";
import axios from 'axios';

const Vod = ({ missionId, missionNum, title, vodUrl}) => {
const Vod = ({ missionPk, missionNum, title, vodUrl}) => {
const [watched, setWatched] = useState(false);
const userId = sessionStorage.getItem("userId");

const navigate = useNavigate();
const { mapId } = useParams();
Expand All @@ -25,10 +26,11 @@ const Vod = ({ missionId, missionNum, title, vodUrl}) => {


const saveMissionStatus = () => {
console.log(missionPk)
axios
.post("http://localhost:8080/api/v1/missions", {
solvedMissionId: missionId,
solvedUserId: 2,
solvedMissionId: missionPk,
solvedUserId: userId,
status : 1
})
.then((response) => {
Expand Down
5 changes: 2 additions & 3 deletions src/components/MissionBanner/MissionBanner.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import React, { useEffect, useState } from 'react';
import Select from 'react-select'
import './missionBanner.css'
import axios from 'axios';
import { markThousand } from '../../lib/markThousand';


const DebitBanner = ({setKidUserId, setKidUserName}) => {
Expand Down Expand Up @@ -35,8 +36,6 @@ const DebitBanner = ({setKidUserId, setKidUserName}) => {
setKidBalance(updateBalance)

setKidOptions(updateKidOptions)
// console.log(updateKidOptions)
// console.log(childData)
})
}
getChildAxios()
Expand All @@ -51,7 +50,7 @@ const DebitBanner = ({setKidUserId, setKidUserName}) => {
</div>
<div className='kidBalance'>
<div>아이 현재 잔액:</div>
<div>{nowKidBalance}</div>
<div>{markThousand(nowKidBalance)}</div>
</div>
<div className='kidSelect'>
<Select
Expand Down
2 changes: 1 addition & 1 deletion src/components/debitBanner/DebitBanner.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ const DebitBanner = ({idx, color, setKidUserId, setKidUserName}) => {
</div>
<div className='kidBalance'>
<div className='usespace'>아이 현재 잔액: </div>
<div> {nowKidBalance}</div>
<div> {markThousand(nowKidBalance)}</div>
</div>
<div className='kidSelect'>
<Select
Expand Down
59 changes: 54 additions & 5 deletions src/components/payHistory/QRcode.jsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,26 @@
import React, { useEffect, useState } from 'react';
import axios from 'axios';
import { markThousand } from '../../lib/markThousand';

const QRCode = () => {
const [qrCodeImage, setQRCodeImage] = useState('');
const userId = sessionStorage.getItem('userId');
const [balance, setBalance] = useState('');
const [showBalance, setShowBalance] = useState(false);
const username = sessionStorage.getItem('username');


const getUser = () => {
axios
.get(`http://localhost:8080/api/v1/users/${userId}`)
.then((response) => {
console.log(response.data.data);
setBalance(markThousand(response.data.data.balance));
})
.catch((error) => {
console.log(error.response.data);
});
};

useEffect(() => {
const fetchQRCodeImage = async () => {
Expand All @@ -18,15 +35,47 @@ const QRCode = () => {
console.error('짠페이 생성에 실패했습니다.:', error);
}
};

getUser();
fetchQRCodeImage();
}, [userId]);
}, []);

const handleMouseEnter = () => {
setShowBalance(true);
};

const handleMouseLeave = () => {
setShowBalance(false);
};

return (
<div style={{marginLeft:'1.5rem'}}>
{qrCodeImage && <img style={{width: '90%'}} src={qrCodeImage} alt="QR Code" />}
<div style={{ marginLeft: '1.5rem' }}>
{qrCodeImage && (
<div
style={{ position: 'relative', display: 'inline-block' }}
onMouseEnter={handleMouseEnter}
onMouseLeave={handleMouseLeave}
>
<img style={{ width: '90%' }} src={qrCodeImage} alt="QR Code" />
{showBalance && (
<div
style={{
position: 'absolute',
left: '45%',
transform: 'translate(-50%, -50%)',
backgroundColor: 'rgba(0, 0, 0, 0.5)',
color: '#fff',
padding: '0.5rem',
borderRadius: '4px',
fontSize: '2rem'
}}
>
{username}<br/>{balance}
</div>
)}
</div>
)}
</div>
);
};

export default QRCode;
export default QRCode;
7 changes: 4 additions & 3 deletions src/components/profile/FamCard.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,10 @@ import Loading from '../../lib/Loading';
imgSrc = `${process.env.PUBLIC_URL}/assets/images/boy.png`;
}

const checkLevel = (userAchieve) => {
var mapNum = Math.ceil(userAchieve / 7);
var missionNum = userAchieve % 8;
const checkLevel = (num) => {
var mapNum = Math.ceil(num / 7);
if(mapNum == 0 ) mapNum = 1;
var missionNum = num % 7 + 1;
return `${mapNum}-${missionNum}`
}

Expand Down
9 changes: 5 additions & 4 deletions src/components/profile/StateCard.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,10 @@ const StateCard = () => {
getUser();
}, []);

const checkLevel = (userAchieve) => {
var mapNum = Math.ceil(userAchieve / 7);
var missionNum = userAchieve % 8;
const checkLevel = (num) => {
var mapNum = Math.ceil(num / 7);
if(mapNum == 0 ) mapNum = 1;
var missionNum = num % 7 + 1;
return `${mapNum}-${missionNum}`
}

Expand All @@ -45,7 +46,7 @@ const StateCard = () => {
<p>현재 단계 : {checkLevel(userAchieve)}</p>
</div>
<div className='present-state'>
<p>보유 금액 : {userBalance}</p>
<p>보유 금액 : {userBalance}</p>
</div>
</div>
);
Expand Down
3 changes: 2 additions & 1 deletion src/components/slider/Slider.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@ export default class SimpleSlider extends Component {

const checkLevel = (num) => {
var mapNum = Math.ceil(num / 7);
var missionNum = num % 8;
if(mapNum == 0 ) mapNum = 1;
var missionNum = num % 7 + 1;
return `${mapNum}-${missionNum}`
}

Expand Down
40 changes: 34 additions & 6 deletions src/pages/Map.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const Map = () => {
const achieveStatus_full = 7; // 나중에 실제로 사용할 데이터 변수
const achieveStatus = 0; // 나중에 실제로 사용할 데이터 변수
const [isLoading, setIsLoading] = useState(true);
const [achieve, setAchieve] = useState();

const [status, setStatus] = useState();
const [preMap, setPreMap] = useState(0);
Expand All @@ -23,7 +24,7 @@ const Map = () => {
.then((response) => {
console.log(response.data.data)
setStatus(response.data.data.achieve)

setAchieve(response.data.data.achieve)
var quotient = Math.floor(status / 7);
switch (quotient) {
case 0:
Expand Down Expand Up @@ -51,10 +52,8 @@ const Map = () => {
console.log(error.response.data);
})
};

getUserAchieve();

}, [status]);
}, [status, achieve]);

if (isLoading) {
return <Loading/>;
Expand Down Expand Up @@ -98,10 +97,39 @@ const Map = () => {
alt=''
className='map-background-image'/>
{mapBoxes}

</div>
{achieve >= 1 && achieve <= 5 && (
<img
src={`${process.env.PUBLIC_URL}/assets/images/tree1.png`}
alt=''
className='tree'
/>
)}
{achieve >= 6 && achieve <= 13 && (
<img
src={`${process.env.PUBLIC_URL}/assets/images/tree2.png`}
alt=''
className='tree'
/>
)}
{achieve >= 14 && achieve <= 19 && (
<img
src={`${process.env.PUBLIC_URL}/assets/images/tree3.png`}
alt=''
className='tree'
/>
)}
{achieve >= 20 && achieve <= 42 && (
<img
src={`${process.env.PUBLIC_URL}/assets/images/tree4.png`}
alt=''
className='tree'
/>
)}
</>
);
};
}



export default Map;
6 changes: 4 additions & 2 deletions src/pages/Mission.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import Loading from '../lib/Loading';

const Mission = () => {
const { mapId, missionId } = useParams();
const [ missionPk, setMissionPk ] = useState("");
const [isQuiz, setIsQuiz] = useState(false);
const [explain, setExplain] = useState("");
const [title, setTitle] = useState("");
Expand All @@ -26,6 +27,7 @@ const Mission = () => {
const data = response.data.data;
data.missionType === "Q" ? setIsQuiz(true) : setIsQuiz(false);

setMissionPk(data.missionId);
setTitle(data.title);
setExplain(data.explain);
setVodUrl(data.vodUrl);
Expand All @@ -47,8 +49,8 @@ const Mission = () => {
<div>
<Header/>
{isQuiz ?
<Quiz missionId={missionId} mapNum={mapId} missionNum={missionId} title={title} explain={explain} answer={answer} />
: <Vod missionId={missionId} mapNum={mapId} missionNum={missionId} title={title} vodUrl={vodUrl}/>
<Quiz missionPk={missionPk} mapNum={mapId} missionNum={missionId} title={title} explain={explain} answer={answer} />
: <Vod missionPk={missionPk} mapNum={mapId} missionNum={missionId} title={title} vodUrl={vodUrl}/>
}
<MapBackground mapId={missionId} isMap={false} />
</div>
Expand Down
6 changes: 3 additions & 3 deletions src/pages/MissionList.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ const MissionList = () => {
};
getUserMission();
}, []);

useEffect(() => {
const isMissionNumExist = missionData.some(mission => mission.missionNum !== undefined);
const isMissionNumExist = missionData.length > 0 && missionData.some(mission => mission.missionNum !== undefined);
setIsSolved(isMissionNumExist);
}, [missionData]);

Expand Down Expand Up @@ -79,7 +79,7 @@ const MissionList = () => {
<img
src={island_img}
alt=''
className='map map-image-1 pointer'
className={`map map-image-${mapId} pointer`}
onClick={() => {
navigate(`/kid/map/${mapId}/mission/${index + 1}`);
}} />
Expand Down
7 changes: 4 additions & 3 deletions src/pages/SolvedMission.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,11 @@ const SolvedMission = () => {
setIsModalOpen(false);
};

if(!(location.state.isO)){
setPrompt(`${title}\nwhy is this wrong? respond me in Korean`)
}
const handleSubmit = async (e) => {
if(!(location.state.isO)){
setPrompt(`${title}\nwhy is this wrong? respond me in Korean`)
}

e.preventDefault();
setIsLoading(true);
try {
Expand Down
6 changes: 5 additions & 1 deletion src/pages/css/map.css
Original file line number Diff line number Diff line change
Expand Up @@ -73,4 +73,8 @@
left: 2%
}


.tree{
position: absolute;
bottom: 0;
width: 20%;
}

0 comments on commit a1b4fdd

Please sign in to comment.