Skip to content

Commit

Permalink
feature/map
Browse files Browse the repository at this point in the history
먼지API하던중
#15
  • Loading branch information
moana16 committed Sep 24, 2022
1 parent f17b701 commit 52a5744
Show file tree
Hide file tree
Showing 6 changed files with 56 additions and 7 deletions.
6 changes: 5 additions & 1 deletion apis/service.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import axios from "axios";
// export const getToken = () => localStorage.getItem('access_token') ?? null

export const statDustAPI = axios.create({
baseURL: '',
baseURL: 'https://star-dust.shop',
headers: {
accept: "application/json",
"Content-Type": "application/json",
Expand All @@ -14,4 +14,8 @@ export const statDustAPI = axios.create({

export async function getDusts(university) {
return await statDustAPI.get(`/map/${university}`)
}

export async function postcatchedDust() {
return await statDustAPI.post(`/catch/dust`,{dustNum})
}
4 changes: 2 additions & 2 deletions pages/map/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ export default function Map() {
<div className={styles.stardust_container}>
<div className={styles.stardust_black}></div>
<div className={styles.stardust_yellow}></div>
<div className={styles.stardust_blue}></div>
<div className={styles.stardust_green}></div>
<div className={styles.stardust_purple}></div>
<div className={styles.stardust_red}></div>
<div className={styles.stardust_white}></div>

</div>

Expand Down
21 changes: 21 additions & 0 deletions pages/qrcode/index.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,41 @@
import React, {useState, useEffect} from "react";
import { QrReader } from "react-qr-reader";
import { postcatchedDust } from "../../apis/service";
import { useRouter } from "next/router";

export default function QrcodeScanner () {
const [data, setData] = useState('No result');
const [hasRendered, setHasRendered] = useState(false);
const [dustNum, setDustNum] = useState(0);
const router=useRouter();

useEffect(() => {
setHasRendered(true)
}, [])

const postDustNum = async() => {
const response = await postcatchedDust(dustNum)

if(response.status==200) {
if(response.body.code == 200) {
//router.back() //map화면으로 다시 돌아가게 해줘야함 근데이게맞아?ㅋ
//

}
}
}

return (
<>
{hasRendered && (
<QrReader
onResult={(result, error) => {
if (!!result) {
setData(result?.text);
//setDustNum(Number(data)); //dustnum설정해주깅~
//postDustNum


}

if (!!error) {
Expand Down
12 changes: 12 additions & 0 deletions public/wanted-stardust-green.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 12 additions & 0 deletions public/wanted-stardust-white.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 4 additions & 4 deletions styles/Map.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,19 @@
content: url(../public/wanted-stardust-yellow.png);
margin: 5px;
}
.stardust_blue {
.stardust_green {
display: inline-block;
content: url(../public/wanted-stardust-blue.png);
content: url(../public/wanted-stardust-green.svg);
margin: 5px;
}
.stardust_purple {
display: inline-block;
content: url(../public/wanted-stardust-purple.png);
margin: 5px;
}
.stardust_red {
.stardust_white {
display: inline-block;
content: url(../public/wanted-stardust-red.png);
content: url(../public/wanted-stardust-white.svg);
margin: 5px;
}
.map_logo {
Expand Down

0 comments on commit 52a5744

Please sign in to comment.