From 52a57448e284bae8ca745bd18e8eb2f07e376c94 Mon Sep 17 00:00:00 2001 From: jimin Date: Sun, 25 Sep 2022 02:36:14 +0900 Subject: [PATCH] =?UTF-8?q?feature/map=20=EB=A8=BC=EC=A7=80API=ED=95=98?= =?UTF-8?q?=EB=8D=98=EC=A4=91=20#15?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apis/service.js | 6 +++++- pages/map/index.js | 4 ++-- pages/qrcode/index.js | 21 +++++++++++++++++++++ public/wanted-stardust-green.svg | 12 ++++++++++++ public/wanted-stardust-white.svg | 12 ++++++++++++ styles/Map.module.css | 8 ++++---- 6 files changed, 56 insertions(+), 7 deletions(-) create mode 100644 public/wanted-stardust-green.svg create mode 100644 public/wanted-stardust-white.svg diff --git a/apis/service.js b/apis/service.js index 6fe7dfe..7e30c06 100644 --- a/apis/service.js +++ b/apis/service.js @@ -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", @@ -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}) } \ No newline at end of file diff --git a/pages/map/index.js b/pages/map/index.js index 4b970d7..9ba6671 100644 --- a/pages/map/index.js +++ b/pages/map/index.js @@ -14,9 +14,9 @@ export default function Map() {
-
+
-
+
diff --git a/pages/qrcode/index.js b/pages/qrcode/index.js index aabb27f..c4a99e3 100644 --- a/pages/qrcode/index.js +++ b/pages/qrcode/index.js @@ -1,13 +1,30 @@ 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 && ( @@ -15,6 +32,10 @@ export default function QrcodeScanner () { onResult={(result, error) => { if (!!result) { setData(result?.text); + //setDustNum(Number(data)); //dustnum설정해주깅~ + //postDustNum + + } if (!!error) { diff --git a/public/wanted-stardust-green.svg b/public/wanted-stardust-green.svg new file mode 100644 index 0000000..ef67ce1 --- /dev/null +++ b/public/wanted-stardust-green.svg @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/public/wanted-stardust-white.svg b/public/wanted-stardust-white.svg new file mode 100644 index 0000000..a487789 --- /dev/null +++ b/public/wanted-stardust-white.svg @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/styles/Map.module.css b/styles/Map.module.css index e68cc20..2794e63 100644 --- a/styles/Map.module.css +++ b/styles/Map.module.css @@ -23,9 +23,9 @@ 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 { @@ -33,9 +33,9 @@ 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 {