Skip to content

Commit e4fb3ad

Browse files
committed
빙고 QR로 채우는 부분 추가
1 parent 419a396 commit e4fb3ad

File tree

5 files changed

+42
-5
lines changed

5 files changed

+42
-5
lines changed

src/App.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import Footer from "./modules/Footer/Footer.tsx";
99
import SignUpForm from "./modules/Header/SignUpForm.tsx";
1010
import Board from "./modules/Community/index.tsx";
1111
import BoardView from "./modules/Community/BoardView.tsx";
12+
import BingoQR from "./modules/Bingo/BingoQR.tsx";
1213
import { Container, CssBaseline } from "@mui/material";
1314
import { createTheme, ThemeProvider } from "@mui/material/styles";
1415

@@ -21,13 +22,14 @@ function App() {
2122
<CssBaseline />
2223
<Container className="App">
2324
<Header />
24-
<Routes>
25+
<Routes>
2526
<Route path="/" Component={Home} />
2627
<Route path="/builder" element={<IntroduceBuilder />} />
2728
<Route path="/runner" element={<Test />} />
2829
<Route path="/community/*" element={<Board />} />
2930
<Route path="/bingo" element={<Bingo />} />
3031
<Route path="/signup" element={<SignUpForm />} />
32+
<Route path="/bingo_qr/:id" element={<BingoQR />} />
3133
{/* <Route path="/posts" component={Posts} />
3234
<Route path="/posts/:id" component={Post} />
3335
<Route path="/posts/new" component={NewPost} />

src/api/bingo_api.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,3 +117,14 @@ export const getUserName = async (userId: string) => {
117117
const userName = data["username"];
118118
return userName;
119119
};
120+
121+
export const updateBingoFromQR = async (userId: string, targetId: string) => {
122+
const response = await fetch(
123+
`${API_URL}/api/bingo/boards/update/${userId}/${targetId}`,
124+
{
125+
method: "PATCH",
126+
}
127+
);
128+
const data = await response.json();
129+
return data;
130+
};

src/modules/Bingo/BingoContainer.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,6 @@ const BingoContainer = () => {
106106
userLatestInteraction.send_user_id
107107
);
108108
const wordList = userLatestInteraction.word_id_list;
109-
localStorage.setItem("recentWords", wordList);
110109
localStorage.setItem("recentSendUser", sendUserName);
111110
setRecentWords(wordList);
112111
setRecentSendUser(sendUserName);

src/modules/Bingo/BingoPresenter.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ const BingoPresenter = (props: BingoPresenterProps) => {
174174
{/* {props.userSelectedWords.map((word) => (
175175
<LongTextBox key={word} text={word} />
176176
))} */}
177-
<RecentSendUserWrapper>
177+
{/* <RecentSendUserWrapper>
178178
{props.recentSendUser === "" ? (
179179
""
180180
) : (
@@ -185,14 +185,14 @@ const BingoPresenter = (props: BingoPresenterProps) => {
185185
<span> 님과 이야기를 나누었어요!</span>
186186
</>
187187
)}
188-
</RecentSendUserWrapper>
188+
</RecentSendUserWrapper> */}
189189
<BingoContainer>
190190
{props.bingoWords.map(({ value, status }) => (
191191
<SqaureTextBox
192192
key={value}
193193
value={value}
194194
status={status}
195-
recent_list={props.recentWords.split("|")}
195+
recent_list={[""]}
196196
/>
197197
))}
198198
</BingoContainer>

src/modules/Bingo/BingoQR.tsx

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import { useEffect } from "react";
2+
import { useParams } from "react-router-dom";
3+
import { getUser, updateBingoBoard } from "../../api/bingo_api";
4+
5+
const BingoQR = () => {
6+
const { id } = useParams();
7+
8+
useEffect(() => {
9+
// API 호출
10+
const fetchData = async () => {
11+
const myId = localStorage.getItem("myID");
12+
if (myId === null) window.location.href = "";
13+
14+
const user = await getUser(myId);
15+
const result = await updateBingoBoard(id, user.user_id);
16+
if (result === true) window.location.href = "/bingo";
17+
};
18+
19+
fetchData();
20+
}, []); // 빈 배열: 컴포넌트 마운트 시 한 번 실행
21+
22+
return <div>QR 체크중</div>;
23+
};
24+
25+
export default BingoQR;

0 commit comments

Comments
 (0)