feat: Add hide ineligible participants functionality in AvailableParticipantsSection
This commit is contained in:
parent
5b10548f13
commit
609c4e7b2c
2 changed files with 29 additions and 25 deletions
|
|
@ -15,6 +15,7 @@ interface AvailableParticipantsSectionProps {
|
||||||
searchQuery: string;
|
searchQuery: string;
|
||||||
sportFilter: string;
|
sportFilter: string;
|
||||||
hideDrafted: boolean;
|
hideDrafted: boolean;
|
||||||
|
hideIneligible: boolean;
|
||||||
uniqueSports: string[];
|
uniqueSports: string[];
|
||||||
draftedParticipantIds: Set<string>;
|
draftedParticipantIds: Set<string>;
|
||||||
queue: Array<{ id: string; participantId: string }>;
|
queue: Array<{ id: string; participantId: string }>;
|
||||||
|
|
@ -27,6 +28,7 @@ interface AvailableParticipantsSectionProps {
|
||||||
onSearchChange: (query: string) => void;
|
onSearchChange: (query: string) => void;
|
||||||
onSportFilterChange: (sport: string) => void;
|
onSportFilterChange: (sport: string) => void;
|
||||||
onHideDraftedChange: (hide: boolean) => void;
|
onHideDraftedChange: (hide: boolean) => void;
|
||||||
|
onHideIneligibleChange: (hide: boolean) => void;
|
||||||
onMakePick: (participantId: string) => void;
|
onMakePick: (participantId: string) => void;
|
||||||
onAddToQueue: (participantId: string) => void;
|
onAddToQueue: (participantId: string) => void;
|
||||||
onRemoveFromQueue: (queueId: string) => void;
|
onRemoveFromQueue: (queueId: string) => void;
|
||||||
|
|
@ -37,6 +39,7 @@ export function AvailableParticipantsSection({
|
||||||
searchQuery,
|
searchQuery,
|
||||||
sportFilter,
|
sportFilter,
|
||||||
hideDrafted,
|
hideDrafted,
|
||||||
|
hideIneligible,
|
||||||
uniqueSports,
|
uniqueSports,
|
||||||
draftedParticipantIds,
|
draftedParticipantIds,
|
||||||
queue,
|
queue,
|
||||||
|
|
@ -46,6 +49,7 @@ export function AvailableParticipantsSection({
|
||||||
onSearchChange,
|
onSearchChange,
|
||||||
onSportFilterChange,
|
onSportFilterChange,
|
||||||
onHideDraftedChange,
|
onHideDraftedChange,
|
||||||
|
onHideIneligibleChange,
|
||||||
onMakePick,
|
onMakePick,
|
||||||
onAddToQueue,
|
onAddToQueue,
|
||||||
onRemoveFromQueue,
|
onRemoveFromQueue,
|
||||||
|
|
@ -88,6 +92,19 @@ export function AvailableParticipantsSection({
|
||||||
/>
|
/>
|
||||||
<span>Show Drafted</span>
|
<span>Show Drafted</span>
|
||||||
</label>
|
</label>
|
||||||
|
|
||||||
|
{/* Show/Hide Ineligible Toggle - only show if user has a team */}
|
||||||
|
{hasTeam && eligibility && (
|
||||||
|
<label className="flex items-center gap-2 text-sm cursor-pointer whitespace-nowrap px-3 py-2 border rounded-md">
|
||||||
|
<input
|
||||||
|
type="checkbox"
|
||||||
|
checked={!hideIneligible}
|
||||||
|
onChange={(e) => onHideIneligibleChange(!e.target.checked)}
|
||||||
|
className="rounded"
|
||||||
|
/>
|
||||||
|
<span>Show Ineligible</span>
|
||||||
|
</label>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@ import { AvailableParticipantsSection } from "~/components/draft/AvailablePartic
|
||||||
import { SidebarRecentPicks } from "~/components/draft/SidebarRecentPicks";
|
import { SidebarRecentPicks } from "~/components/draft/SidebarRecentPicks";
|
||||||
import { DraftGridSection } from "~/components/draft/DraftGridSection";
|
import { DraftGridSection } from "~/components/draft/DraftGridSection";
|
||||||
import { ConnectionOverlay } from "~/components/draft/ConnectionOverlay";
|
import { ConnectionOverlay } from "~/components/draft/ConnectionOverlay";
|
||||||
import { calculateDraftEligibility, getEligibilitySummary } from "~/lib/draft-eligibility";
|
import { calculateDraftEligibility } from "~/lib/draft-eligibility";
|
||||||
import { toast } from "sonner";
|
import { toast } from "sonner";
|
||||||
|
|
||||||
export async function loader(args: any) {
|
export async function loader(args: any) {
|
||||||
|
|
@ -202,6 +202,7 @@ export default function DraftRoom() {
|
||||||
const [currentPick, setCurrentPick] = useState(season.currentPickNumber || 1);
|
const [currentPick, setCurrentPick] = useState(season.currentPickNumber || 1);
|
||||||
const [searchQuery, setSearchQuery] = useState("");
|
const [searchQuery, setSearchQuery] = useState("");
|
||||||
const [hideDrafted, setHideDrafted] = useState(true);
|
const [hideDrafted, setHideDrafted] = useState(true);
|
||||||
|
const [hideIneligible, setHideIneligible] = useState(true);
|
||||||
const [sportFilter, setSportFilter] = useState<string>("all");
|
const [sportFilter, setSportFilter] = useState<string>("all");
|
||||||
const [queue, setQueue] = useState(userQueue);
|
const [queue, setQueue] = useState(userQueue);
|
||||||
const [isPaused, setIsPaused] = useState(season.draftPaused || false);
|
const [isPaused, setIsPaused] = useState(season.draftPaused || false);
|
||||||
|
|
@ -671,29 +672,6 @@ export default function DraftRoom() {
|
||||||
);
|
);
|
||||||
const canPick = isMyTurn && season.status === "draft"; // Only team owner on their turn
|
const canPick = isMyTurn && season.status === "draft"; // Only team owner on their turn
|
||||||
|
|
||||||
// Format timer display
|
|
||||||
const formatTime = (seconds: number | null) => {
|
|
||||||
if (seconds === null) return "--:--";
|
|
||||||
|
|
||||||
const hours = Math.floor(seconds / 3600);
|
|
||||||
const minutes = Math.floor((seconds % 3600) / 60);
|
|
||||||
const secs = seconds % 60;
|
|
||||||
|
|
||||||
if (hours > 0) {
|
|
||||||
return `${hours}:${String(minutes).padStart(2, "0")}:${String(secs).padStart(2, "0")}`;
|
|
||||||
}
|
|
||||||
return `${minutes}:${String(secs).padStart(2, "0")}`;
|
|
||||||
};
|
|
||||||
|
|
||||||
// Get timer color based on time remaining
|
|
||||||
const getTimerColor = (seconds: number | null) => {
|
|
||||||
if (seconds === null) return "text-muted-foreground";
|
|
||||||
if (seconds > 60) return "text-green-600 dark:text-green-400";
|
|
||||||
if (seconds > 30) return "text-yellow-600 dark:text-yellow-400";
|
|
||||||
if (seconds > 10) return "text-red-600 dark:text-red-400";
|
|
||||||
return "text-red-600 dark:text-red-400 animate-pulse";
|
|
||||||
};
|
|
||||||
|
|
||||||
// Generate snake draft grid structure
|
// Generate snake draft grid structure
|
||||||
const generateDraftGrid = () => {
|
const generateDraftGrid = () => {
|
||||||
const teamCount = draftSlots.length;
|
const teamCount = draftSlots.length;
|
||||||
|
|
@ -747,13 +725,20 @@ export default function DraftRoom() {
|
||||||
new Set(availableParticipants.map((p: any) => p.sport.name))
|
new Set(availableParticipants.map((p: any) => p.sport.name))
|
||||||
).sort();
|
).sort();
|
||||||
|
|
||||||
// Filter participants based on search, sport, and drafted status
|
// Filter participants based on search, sport, drafted status, and eligibility
|
||||||
const filteredParticipants = availableParticipants.filter(
|
const filteredParticipants = availableParticipants.filter(
|
||||||
(participant: any) => {
|
(participant: any) => {
|
||||||
// Drafted filter - hide drafted participants by default
|
// Drafted filter - hide drafted participants by default
|
||||||
if (hideDrafted && draftedParticipantIds.has(participant.id)) {
|
if (hideDrafted && draftedParticipantIds.has(participant.id)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
// Eligibility filter - hide ineligible participants by default (if user has a team)
|
||||||
|
if (hideIneligible && eligibility) {
|
||||||
|
const isEligible = eligibility.eligibleSportIds.has(participant.sport.id);
|
||||||
|
if (!isEligible) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
// Search filter
|
// Search filter
|
||||||
if (
|
if (
|
||||||
searchQuery &&
|
searchQuery &&
|
||||||
|
|
@ -922,6 +907,7 @@ export default function DraftRoom() {
|
||||||
searchQuery={searchQuery}
|
searchQuery={searchQuery}
|
||||||
sportFilter={sportFilter}
|
sportFilter={sportFilter}
|
||||||
hideDrafted={hideDrafted}
|
hideDrafted={hideDrafted}
|
||||||
|
hideIneligible={hideIneligible}
|
||||||
uniqueSports={uniqueSports}
|
uniqueSports={uniqueSports}
|
||||||
draftedParticipantIds={draftedParticipantIds}
|
draftedParticipantIds={draftedParticipantIds}
|
||||||
queue={queue}
|
queue={queue}
|
||||||
|
|
@ -931,6 +917,7 @@ export default function DraftRoom() {
|
||||||
onSearchChange={setSearchQuery}
|
onSearchChange={setSearchQuery}
|
||||||
onSportFilterChange={setSportFilter}
|
onSportFilterChange={setSportFilter}
|
||||||
onHideDraftedChange={setHideDrafted}
|
onHideDraftedChange={setHideDrafted}
|
||||||
|
onHideIneligibleChange={setHideIneligible}
|
||||||
onMakePick={handleMakePick}
|
onMakePick={handleMakePick}
|
||||||
onAddToQueue={handleAddToQueue}
|
onAddToQueue={handleAddToQueue}
|
||||||
onRemoveFromQueue={handleRemoveFromQueue}
|
onRemoveFromQueue={handleRemoveFromQueue}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue