Skip to content

Commit f30cc3f

Browse files
authored
Merge pull request #20 from CH-JASWANTH-KUMAR/fix/team-problem-statement-visibility
Fix: Make problem statement visible to all team members
2 parents bfc1369 + 9ae4d7b commit f30cc3f

1 file changed

Lines changed: 33 additions & 0 deletions

File tree

src/app/profile/page.tsx

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,28 @@ export default function Profile() {
7171
if (teamDoc.exists()) {
7272
const teamInfo = teamDoc.data();
7373
setTeamData(teamInfo);
74+
75+
// Fetch problem statement for team members
76+
if (!response?.problemStatement) {
77+
if (teamInfo.problemStatement) {
78+
setProblemStatement(teamInfo.problemStatement);
79+
setSolution(teamInfo.solution || "");
80+
setTechStack(teamInfo.techStack || "");
81+
setHasProblemStatement(true);
82+
} else if (teamInfo.leaderId) {
83+
// Fallback: Fetch from leader's profile if not on team doc
84+
const leaderDoc = await getDoc(doc(db, "registrations", teamInfo.leaderId));
85+
if (leaderDoc.exists()) {
86+
const leaderData = leaderDoc.data();
87+
if (leaderData.problemStatement) {
88+
setProblemStatement(leaderData.problemStatement);
89+
setSolution(leaderData.solution || "");
90+
setTechStack(leaderData.techStack || "");
91+
setHasProblemStatement(true);
92+
}
93+
}
94+
}
95+
}
7496

7597
// Fetch all team members
7698
const membersData = await Promise.all(
@@ -134,11 +156,22 @@ export default function Profile() {
134156

135157
setSaving(true);
136158
try {
159+
// Save to user profile (legacy support)
137160
await updateDoc(doc(db, "registrations", user.uid), {
138161
problemStatement,
139162
solution,
140163
techStack,
141164
});
165+
166+
// Save to team document (so all members can see it)
167+
if (userData?.teamName) {
168+
await updateDoc(doc(db, "teams", userData.teamName), {
169+
problemStatement,
170+
solution,
171+
techStack,
172+
});
173+
}
174+
142175
setHasProblemStatement(true);
143176
setIsEditingProblem(false);
144177
alert("Problem statement saved successfully!");

0 commit comments

Comments
 (0)