Skip to content

Commit

Permalink
PsychSheet default sort fix (#10626)
Browse files Browse the repository at this point in the history
* PsychSheet default sort fix

* space added

* reverts and fix per comment

* refactoring

* added missing semicolon
  • Loading branch information
pranav-027 authored Jan 16, 2025
1 parent 08260e5 commit d5dafa0
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import { formatAttemptResult } from '../../../lib/wca-live/attempts';
import I18n from '../../../lib/i18n';
import { countries } from '../../../lib/wca-data.js.erb';
import { EventSelector } from '../../wca/EventSelector';
import { events } from '../../../lib/wca-data.js.erb';

const sortReducer = createSortReducer(['name', 'country', 'total']);

Expand All @@ -39,11 +40,15 @@ export default function RegistrationList({ competitionInfo }) {
const changeSortColumn = (name) => sortDispatch({ type: 'CHANGE_SORT', sortColumn: name });

const [psychSheetEvent, setPsychSheetEvent] = useState();
const [psychSheetSortBy, setPsychSheetSortBy] = useState('single');
const [psychSheetSortBy, setPsychSheetSortBy] = useState();
const isPsychSheet = psychSheetEvent !== undefined
const isAllCompetitors = !isPsychSheet
const handleEventSelection = ({ type, eventId }) => {
setPsychSheetEvent(type === 'toggle_event' ? eventId : undefined);
if (type === 'toggle_event' ) {
const event = events.byId[eventId];
setPsychSheetSortBy(event.recommendedFormat().sortBy);
}
};

const { isLoading: isLoadingPsychSheet, data: psychSheet } = useQuery({
Expand Down
2 changes: 1 addition & 1 deletion lib/static_data/events.json
Original file line number Diff line number Diff line change
Expand Up @@ -323,4 +323,4 @@
"1"
]
}
]
]

0 comments on commit d5dafa0

Please sign in to comment.