|
@@ -32,30 +32,30 @@ const FootballMatch = ({ selectedDayMatches, currentUser }) => {
|
|
|
|
|
|
const [selectedFirstTeamToScore, setSelectedFirstTeamToScore] = useState(""); // ["home", "away", "no_goal"]
|
|
|
|
|
|
- console.log("selectedDayMatches", selectedDayMatches);
|
|
|
- console.log("selectedFirstTeamToScore", selectedFirstTeamToScore);
|
|
|
+ // console.log("selectedDayMatches", selectedDayMatches);
|
|
|
+ // console.log("selectedFirstTeamToScore", selectedFirstTeamToScore);
|
|
|
|
|
|
- console.log(
|
|
|
- "selectedFirstTeamToScoreOfMatch",
|
|
|
- selectedFirstTeamToScoreOfMatch
|
|
|
- );
|
|
|
- console.log("selectedMatchId", selectedMatchId);
|
|
|
- console.log("selectedMatch", selectedMatch);
|
|
|
+ // console.log(
|
|
|
+ // "selectedFirstTeamToScoreOfMatch",
|
|
|
+ // selectedFirstTeamToScoreOfMatch
|
|
|
+ // );
|
|
|
+ // console.log("selectedMatchId", selectedMatchId);
|
|
|
+ // console.log("selectedMatch", selectedMatch);
|
|
|
|
|
|
- console.log("selectedWinTeams", selectedWinTeams);
|
|
|
- console.log("totalGoalCountOfMatch", totalGoalCountOfMatch);
|
|
|
+ // console.log("selectedWinTeams", selectedWinTeams);
|
|
|
+ // console.log("totalGoalCountOfMatch", totalGoalCountOfMatch);
|
|
|
|
|
|
const selectedWinTeam = selectedWinTeams[selectedMatchId] || "";
|
|
|
|
|
|
- console.log("selectedWinTeam", selectedWinTeam);
|
|
|
+ // console.log("selectedWinTeam", selectedWinTeam);
|
|
|
|
|
|
- console.log("predictions", predictions);
|
|
|
+ // console.log("predictions", predictions);
|
|
|
|
|
|
const predictionMap = predictions.reduce((map, prediction) => {
|
|
|
map[prediction.matchId] = prediction;
|
|
|
return map;
|
|
|
}, {});
|
|
|
- console.log("predictionMap", predictionMap);
|
|
|
+ // console.log("predictionMap", predictionMap);
|
|
|
|
|
|
useEffect(() => {
|
|
|
console.log("currentUser", currentUser);
|
|
@@ -90,6 +90,9 @@ const FootballMatch = ({ selectedDayMatches, currentUser }) => {
|
|
|
]);
|
|
|
|
|
|
const incrementGoal = (matchId, whoWillWin, totalGoals, matchStatus) => {
|
|
|
+ if (checkUserLogin()) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
if (matchStatus === "进行中") {
|
|
|
setAlert({ type: "error", message: "比赛已开始,无法提交预测" });
|
|
|
return;
|
|
@@ -117,6 +120,9 @@ const FootballMatch = ({ selectedDayMatches, currentUser }) => {
|
|
|
};
|
|
|
|
|
|
const decrementGoal = (matchId, whoWillWin, totalGoals, matchStatus) => {
|
|
|
+ if (checkUserLogin()) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
if (matchStatus === "进行中") {
|
|
|
setAlert({ type: "error", message: "比赛已开始,无法提交预测" });
|
|
|
return;
|
|
@@ -144,6 +150,9 @@ const FootballMatch = ({ selectedDayMatches, currentUser }) => {
|
|
|
|
|
|
// 选择who wins
|
|
|
const handleWinTeamSelect = (matchId, selectedTeam, matchStatus) => {
|
|
|
+ if (checkUserLogin()) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
if (matchStatus === "进行中") {
|
|
|
setAlert({ type: "error", message: "比赛已开始,无法提交预测" });
|
|
|
return;
|
|
@@ -170,15 +179,14 @@ const FootballMatch = ({ selectedDayMatches, currentUser }) => {
|
|
|
|
|
|
// 打开 FirstScoreTeam 选择框
|
|
|
const openSelectFirstTeamModal = (match, whoWillWin, firstTeamToScore) => {
|
|
|
- console.log("match", match);
|
|
|
+ if (checkUserLogin()) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
if (match.status === "进行中") {
|
|
|
setAlert({ type: "error", message: "比赛已开始,无法提交预测" });
|
|
|
return;
|
|
|
}
|
|
|
const matchId = match._id;
|
|
|
- console.log("whoWillWin", whoWillWin);
|
|
|
- console.log("matchId", matchId);
|
|
|
- console.log("firstTeamToScore", firstTeamToScore);
|
|
|
setSelectedMatchId(matchId);
|
|
|
firstTeamToScore
|
|
|
? setSelectedFirstTeamToScore(firstTeamToScore)
|
|
@@ -264,6 +272,14 @@ const FootballMatch = ({ selectedDayMatches, currentUser }) => {
|
|
|
}
|
|
|
};
|
|
|
|
|
|
+ const checkUserLogin = () => {
|
|
|
+ if (!currentUser) {
|
|
|
+ setAlert({ type: "error", message: "请先登录" });
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ return false;
|
|
|
+ };
|
|
|
+
|
|
|
return (
|
|
|
<div className="bg-blue-600 text-white p-4 max-w-md mx-auto min-h-screen">
|
|
|
<div>
|