Skip to content

fix: Enhance TeamSelector and HomePage with team upload persistence#1065

Open
Harmanpreet-Microsoft wants to merge 5 commits into
microsoft:devfrom
Harmanpreet-Microsoft:psl-fixbug47845/correctToast
Open

fix: Enhance TeamSelector and HomePage with team upload persistence#1065
Harmanpreet-Microsoft wants to merge 5 commits into
microsoft:devfrom
Harmanpreet-Microsoft:psl-fixbug47845/correctToast

Conversation

@Harmanpreet-Microsoft

Copy link
Copy Markdown
Contributor

Purpose

This pull request introduces improvements to the team selection and upload workflow, focusing on better handling of uploaded teams and restoring team state from previous sessions. The changes enhance user experience by persisting team selections and providing clearer feedback during team uploads.

Enhancements to team selection and upload:

  • The onTeamUpload prop in TeamSelector now accepts an optional TeamConfig parameter, allowing the uploaded team to be passed directly to handlers.
  • The TeamSelector component now passes the uploaded team object to the onTeamUpload callback when a team is uploaded, ensuring the handler receives the correct data. [1] [2]
  • The handleTeamUpload function in HomePage.tsx is updated to accept the uploaded team, sets it as the selected team, stores it for persistence, and displays a toast notification. Improved error handling and logging are also added.

Persistence and restoration of team selection:

  • On app initialization, the HomePage now checks localStorage for a previously uploaded team and restores it as the selected team, providing a toast notification to inform the user.

Minor data update:

  • Updated the team ID and name in the content_gen.json file to new values, likely for testing or data consistency.
  • ...

Does this introduce a breaking change?

  • Yes
  • No

How to Test

  • Get the code
git clone [repo-address]
cd [repo-name]
git checkout [branch-name]
npm install
  • Test the code

What to Check

Verify that the following are valid

  • ...

Other Information

- Added localStorage check in initTeam useEffect to restore previously uploaded team
- Added TeamService.storageTeam() call in handleTeamUpload to persist team selection
- Now when user refreshes the page, the uploaded team remains selected instead of reverting to 'no team selected'

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR improves the team selection/upload experience by persisting a user’s team choice across sessions and by passing the uploaded team object back to the page-level handler so it can immediately become the selected/default team.

Changes:

  • Update TeamSelector so onTeamUpload can receive (and is invoked with) the uploaded TeamConfig.
  • Enhance HomePage initialization to restore a previously stored team and persist newly selected/uploaded teams to storage.
  • Update HomePage’s upload handler to accept the uploaded team object, set it as selected, persist it, and attempt backend selection.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.

File Description
src/App/src/pages/HomePage.tsx Restores/persists selected team state and updates upload handling to accept the uploaded team object.
src/App/src/components/common/TeamSelector.tsx Extends onTeamUpload callback to optionally pass the uploaded team to consumers.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +52 to +55
// Stored team was deleted, clear localStorage
console.warn(`Stored team ${storedTeam.team_id} no longer exists, clearing storage`);
// Don't call storageTeam with null, just let init response guide us
}
Comment thread src/App/src/pages/HomePage.tsx Outdated
);

const handleTeamUpload = useCallback(async () => {
const handleTeamUpload = useCallback(async (uploadedTeam?: any) => {
Comment thread src/App/src/pages/HomePage.tsx Outdated
console.error('Team upload failed');
} catch (error) {
console.error('Team upload failed:', error);
showToast('Team upload completed', 'success');
Comment thread src/App/src/pages/HomePage.tsx Outdated
Comment on lines +44 to +50
const existsInBackend = teams.some(t => t.team_id === storedTeam.team_id);
if (existsInBackend) {
// Stored team still exists, use it
dispatch(setSelectedTeam(storedTeam));
showToast(`${storedTeam.name} team restored from storage`, 'success');
dispatch(setIsLoadingTeam(false));
return;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants