Skip to content
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

bugfix/fix pickers for beta games #55

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 13 additions & 7 deletions reblase/src/components/elements/TeamPicker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ export interface TeamPickerProps {

export default function TeamPicker(props: TeamPickerProps) {
const formatOptionLabel = (option: ChronTeam, meta: { context: string }) => {
const fullName = option.data?.state?.scattered ? option.data.state.scattered.fullName : option.data.fullName;
const nickname = option.data?.state?.scattered ? option.data.state.scattered.nickname : option.data.nickname;
return (
const fullName = option.data?.state?.scattered ? option.data.state.scattered.fullName : option.data.fullName;
const nickname = option.data?.state?.scattered ? option.data.state.scattered.nickname : option.data.nickname;
return (
<span>
<Twemoji className="mr-1" emoji={option.data.emoji} />
{meta.context === "menu" ? fullName : nickname}
Expand All @@ -32,9 +32,9 @@ export default function TeamPicker(props: TeamPickerProps) {
const options = props.teams
.filter((team) => teamIds.includes(team.entityId))
.sort((a, b) => {
const aName = a.data?.state?.scattered ? a.data.state.scattered.fullName : a.data.fullName;
const bName = b.data?.state?.scattered ? b.data.state.scattered.fullName : b.data.fullName;
return aName.localeCompare(bName);
const aName = a.data?.state?.scattered ? a.data.state.scattered.fullName : a.data.fullName;
const bName = b.data?.state?.scattered ? b.data.state.scattered.fullName : b.data.fullName;
return aName.localeCompare(bName);
});

return (
Expand All @@ -44,13 +44,19 @@ export default function TeamPicker(props: TeamPickerProps) {
placeholder={props.placeholder}
options={options}
value={options.filter((team) => props.selectedTeams?.includes(team.entityId) ?? [])}
getOptionValue={(team) => team.data.fullName}
getOptionValue={(team) =>
team.data.state?.scattered ? team.data.state.scattered.fullName : team.data.fullName
}
formatOptionLabel={formatOptionLabel}
onChange={(value) => {
if (props.setSelectedTeams) {
props.setSelectedTeams((value as ChronTeam[])?.map((team) => team.entityId) ?? []);
}
}}
filterOption={(candidate, input) => {
console.log(candidate);
return candidate.value.toLowerCase().includes(input.toLowerCase());
}}
/>
);
}