-
Notifications
You must be signed in to change notification settings - Fork 2
Fix: Make problem statement visible to all team members #20
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
Changes from all 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 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -71,6 +71,28 @@ export default function Profile() { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (teamDoc.exists()) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const teamInfo = teamDoc.data(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| setTeamData(teamInfo); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // Fetch problem statement for team members | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (!response?.problemStatement) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (teamInfo.problemStatement) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| setProblemStatement(teamInfo.problemStatement); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| setSolution(teamInfo.solution || ""); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| setTechStack(teamInfo.techStack || ""); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| setHasProblemStatement(true); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } else if (teamInfo.leaderId) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // Fallback: Fetch from leader's profile if not on team doc | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const leaderDoc = await getDoc(doc(db, "registrations", teamInfo.leaderId)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (leaderDoc.exists()) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const leaderData = leaderDoc.data(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (leaderData.problemStatement) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| setProblemStatement(leaderData.problemStatement); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| setSolution(leaderData.solution || ""); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| setTechStack(leaderData.techStack || ""); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| setHasProblemStatement(true); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+76
to
+92
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (!response?.problemStatement) { | |
| if (teamInfo.problemStatement) { | |
| setProblemStatement(teamInfo.problemStatement); | |
| setSolution(teamInfo.solution || ""); | |
| setTechStack(teamInfo.techStack || ""); | |
| setHasProblemStatement(true); | |
| } else if (teamInfo.leaderId) { | |
| // Fallback: Fetch from leader's profile if not on team doc | |
| const leaderDoc = await getDoc(doc(db, "registrations", teamInfo.leaderId)); | |
| if (leaderDoc.exists()) { | |
| const leaderData = leaderDoc.data(); | |
| if (leaderData.problemStatement) { | |
| setProblemStatement(leaderData.problemStatement); | |
| setSolution(leaderData.solution || ""); | |
| setTechStack(leaderData.techStack || ""); | |
| setHasProblemStatement(true); | |
| } | |
| if (teamInfo.problemStatement) { | |
| setProblemStatement(teamInfo.problemStatement); | |
| setSolution(teamInfo.solution || ""); | |
| setTechStack(teamInfo.techStack || ""); | |
| setHasProblemStatement(true); | |
| } else if (teamInfo.leaderId) { | |
| // Fallback: Fetch from leader's profile if not on team doc | |
| const leaderDoc = await getDoc(doc(db, "registrations", teamInfo.leaderId)); | |
| if (leaderDoc.exists()) { | |
| const leaderData = leaderDoc.data(); | |
| if (leaderData.problemStatement) { | |
| setProblemStatement(leaderData.problemStatement); | |
| setSolution(leaderData.solution || ""); | |
| setTechStack(leaderData.techStack || ""); | |
| setHasProblemStatement(true); |
Copilot
AI
Jan 1, 2026
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.
The save operation updates two documents sequentially without proper transaction handling or permission checking. If the first update succeeds but the second fails, the data will be inconsistent between the user's profile and the team document. Additionally, there's no check to ensure only the team leader can update the problem statement. Consider using a Firestore transaction to ensure both updates succeed or fail together, and add a check to verify the user is the team leader before allowing updates to the team document.
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.
The logic for fetching the problem statement is duplicated across multiple conditional branches. The same pattern of setting problemStatement, solution, and techStack appears three times (lines 78-81, 88-91, and earlier in lines 52-57). Consider extracting this into a helper function to improve maintainability and reduce code duplication.