-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
매치 상세내역 firebase 연동 #39
Changes from 4 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,40 @@ | ||
import React from "react"; | ||
import React, { useState, useEffect } from "react"; | ||
import { Divider, Button, Tag } from "antd"; | ||
import "antd/dist/antd.css"; | ||
import "./MatchDetail.css"; | ||
import { Match } from "../types"; | ||
import Label from "./Label"; | ||
|
||
const match: Match = { | ||
dateTime: new Date(), | ||
place: "용산", | ||
memberCount: 15, | ||
teamCount: 3, | ||
gender: "여성", | ||
level: "초급", | ||
link: "www.naver.com", | ||
gameType: "gx+match", | ||
fee: 20000, | ||
canPark: true, | ||
canRentShoes: false, | ||
manager: "배성진", | ||
}; | ||
import { useHistory, useParams } from "react-router-dom"; | ||
import firebase from "firebase"; | ||
|
||
const MatchDetail = (): JSX.Element => { | ||
return ( | ||
const history = useHistory(); | ||
const [match, setMatch] = useState<Match | null>(null); | ||
const { id } = useParams<{ id: string }>(); | ||
|
||
useEffect(() => { | ||
getMatch(); | ||
}, [id]); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 응. getMatch을 useEffect안에 옮겨줘. 문서 다시 한번 읽어봐
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. useEffect 안에 옮겨서 해결했는데 나중에 한번더 설명해줘! ㅎㅎ |
||
|
||
const getMatch = async () => { | ||
const db = firebase.firestore(); | ||
const doc = await db.collection("matches").doc(id).get(); | ||
if (!doc.exists) { | ||
window.alert("잘못된 접근입니다. 목록페이지로 돌아갑니다."); | ||
history.push("/"); | ||
return; | ||
} | ||
const match = doc.data(); | ||
if (match) { | ||
match.dateTime = match.dateTime.toDate(); | ||
match.id = doc.id; | ||
setMatch(match as Match); | ||
} | ||
}; | ||
|
||
return !match ? ( | ||
<div></div> | ||
) : ( | ||
<div className="matchDetail"> | ||
<a href="/">목록으로 돌아가기</a> | ||
<Divider className="divider" /> | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
가짜 useParameter 값을 줘야해. 그리고
await db.collection("matches").doc(matchId).get();
의 matchId 확인 해줘.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
그런데 그 테스트 만들기 너무 어려우면 나중에 #43 처리 할때 해도 돼.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#43 처리할때 같이 처리할게!