Tristan Yu commited on
Commit
c67a45c
·
1 Parent(s): a2481a3

fix(week6): hide Files section when empty for non-admins; send richer user info for attribution

Browse files
client/src/pages/WeeklyPractice.tsx CHANGED
@@ -1582,6 +1582,7 @@ const WeeklyPractice: React.FC = () => {
1582
  )}
1583
 
1584
  {/* Week Files (Week 6 uploads) */}
 
1585
  <div className="bg-white rounded-xl shadow p-6 mb-8">
1586
  <h3 className="text-lg font-semibold text-gray-900 mb-4">Week {selectedWeek} Files</h3>
1587
  <div className="grid grid-cols-1 md:grid-cols-2 gap-6">
@@ -1684,6 +1685,7 @@ const WeeklyPractice: React.FC = () => {
1684
  </div>
1685
  </div>
1686
  </div>
 
1687
 
1688
  {/* Special Subtitling Interface for Week 2 */}
1689
  {!isWeekTransitioning && selectedWeek === 2 ? (
 
1582
  )}
1583
 
1584
  {/* Week Files (Week 6 uploads) */}
1585
+ {(weekFiles.source.length > 0 || weekFiles.translation.length > 0 || (JSON.parse(localStorage.getItem('user') || '{}').role === 'admin')) && (
1586
  <div className="bg-white rounded-xl shadow p-6 mb-8">
1587
  <h3 className="text-lg font-semibold text-gray-900 mb-4">Week {selectedWeek} Files</h3>
1588
  <div className="grid grid-cols-1 md:grid-cols-2 gap-6">
 
1685
  </div>
1686
  </div>
1687
  </div>
1688
+ )}
1689
 
1690
  {/* Special Subtitling Interface for Week 2 */}
1691
  {!isWeekTransitioning && selectedWeek === 2 ? (
client/src/services/api.ts CHANGED
@@ -35,9 +35,13 @@ api.interceptors.request.use(
35
  try {
36
  const userData = JSON.parse(user);
37
  config.headers['user-role'] = userData.role || 'visitor';
 
38
  config.headers['user-info'] = JSON.stringify({
39
- _id: userData._id,
40
- username: userData.username,
 
 
 
41
  role: userData.role
42
  });
43
  } catch (error) {
 
35
  try {
36
  const userData = JSON.parse(user);
37
  config.headers['user-role'] = userData.role || 'visitor';
38
+ const derivedUsername = userData.username || userData.name || userData.displayName || (userData.email ? String(userData.email).split('@')[0] : undefined);
39
  config.headers['user-info'] = JSON.stringify({
40
+ _id: userData._id || userData.id,
41
+ username: derivedUsername,
42
+ name: userData.name,
43
+ displayName: userData.displayName,
44
+ email: userData.email,
45
  role: userData.role
46
  });
47
  } catch (error) {