Skip to content

Commit 9afa438

Browse files
author
raineer
committed
resolve team display issues
1 parent f2a7bfe commit 9afa438

3 files changed

Lines changed: 24 additions & 23 deletions

File tree

‎apps/codebility/app/home/projects/_components/ProjectEditModal.tsx‎

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -662,12 +662,7 @@ const ProjectEditModal = () => {
662662
<label className="text-xs font-semibold text-gray-700 dark:text-gray-300">
663663
Team Leader *
664664
</label>
665-
{/* value prop binds currentTeamLeader state to the select,
666-
so the pre-populated leader shows as the selected option.
667-
enhancedUserOptions guarantees the leader's option exists
668-
even if they were filtered out of getProjectCodevs(). */}
669665
<CustomSelect
670-
label="Team Leader"
671666
options={enhancedUserOptions.filter(
672667
(user) => !selectedMembers.find((member) => member.id === user.value),
673668
)}
@@ -696,6 +691,7 @@ const ProjectEditModal = () => {
696691
setSelectedMembers((prev) => prev.filter((m) => m.id !== memberId))
697692
}
698693
excludeMembers={currentTeamLeader ? [currentTeamLeader.id] : []}
694+
showLabel={false}
699695
/>
700696
</div>
701697
</div>

‎apps/codebility/components/ui/CustomSelect.tsx‎

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import {
1111

1212
import { Label } from "@codevs/ui/label";
1313

14-
// Extend your interface to include a "searchable" prop.
1514
interface Option {
1615
id: string;
1716
value: string;
@@ -21,14 +20,14 @@ interface Option {
2120
}
2221

2322
interface CustomSelectProps {
24-
label: string;
23+
label?: string; // ← made optional: omit to suppress the heading entirely
2524
options: Option[];
2625
value?: string;
2726
onChange: (value: string) => void;
2827
placeholder?: string;
2928
disabled?: boolean;
3029
variant?: "default" | "simple";
31-
searchable?: boolean; // <--- New prop
30+
searchable?: boolean;
3231
}
3332

3433
export const CustomSelect = ({
@@ -38,14 +37,12 @@ export const CustomSelect = ({
3837
onChange,
3938
placeholder,
4039
disabled,
41-
variant = "default", // Default to showing avatars
42-
searchable = false, // <--- Default false
40+
variant = "default",
41+
searchable = false,
4342
}: CustomSelectProps) => {
44-
// Keep track of the user's search term
4543
const [searchTerm, setSearchTerm] = useState("");
4644
const searchInputRef = useRef<HTMLInputElement>(null);
4745

48-
// Filter options based on the search term
4946
const filteredOptions = useMemo(() => {
5047
if (!searchable) return options;
5148
const lowerSearch = searchTerm.toLowerCase();
@@ -57,23 +54,24 @@ export const CustomSelect = ({
5754
});
5855
}, [options, searchable, searchTerm]);
5956

60-
// Handle user typing in the search input
6157
const handleSearchChange = (e: ChangeEvent<HTMLInputElement>) => {
62-
// Stop event propagation so the dropdown doesn't close
6358
e.stopPropagation();
6459
setSearchTerm(e.target.value);
6560
};
6661

6762
return (
6863
<div className="space-y-2">
69-
<Label className="dark:text-light-900 text-black">{label}</Label>
64+
{/* Render label only when provided — prevents duplicate headings when
65+
the parent component already renders its own label above this select. */}
66+
{label && (
67+
<Label className="dark:text-light-900 text-black">{label}</Label>
68+
)}
7069
<Select value={value} onValueChange={onChange} disabled={disabled}>
7170
<SelectTrigger className="bg-light-800 dark:bg-dark-200 border-light-700 dark:border-dark-200 dark:text-light-900 w-full text-black">
7271
<SelectValue placeholder={disabled ? "Loading..." : placeholder} />
7372
</SelectTrigger>
7473

7574
<SelectContent side="bottom" position="popper" sideOffset={4} className="bg-light-800 dark:bg-dark-200">
76-
{/** If searchable, show an inline search input */}
7775
{searchable && (
7876
<div className="p-2">
7977
<input
@@ -82,10 +80,10 @@ export const CustomSelect = ({
8280
placeholder="Search..."
8381
value={searchTerm}
8482
onChange={handleSearchChange}
85-
onPointerDown={(e) => e.stopPropagation()} // Keep dropdown open
86-
onFocus={(e) => e.stopPropagation()} // Keep dropdown open
83+
onPointerDown={(e) => e.stopPropagation()}
84+
onFocus={(e) => e.stopPropagation()}
8785
onKeyDown={(e) => {
88-
e.stopPropagation(); // Prevent Select keyboard navigation
86+
e.stopPropagation();
8987
}}
9088
autoFocus={false}
9189
className="dark:bg-dark-100 w-full rounded-md bg-white p-2 text-sm dark:text-white"
@@ -126,7 +124,6 @@ export const CustomSelect = ({
126124
</div>
127125
</div>
128126
) : (
129-
// Simple variant without avatar
130127
<div className="flex flex-col">
131128
<span>{option.label}</span>
132129
{option.subLabel && (
@@ -144,4 +141,4 @@ export const CustomSelect = ({
144141
</Select>
145142
</div>
146143
);
147-
};
144+
};

‎apps/codebility/components/ui/MemberSelection.tsx‎

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ interface MemberSelectionProps {
1919
onMemberAdd: (member: Codev) => void;
2020
onMemberRemove: (memberId: string) => void;
2121
excludeMembers?: string[]; // IDs of members to exclude (e.g., team leader)
22+
// Added: allow callers to hide the built-in "Team Members" label when they
23+
// already provide their own heading. Defaults to true (existing behavior).
24+
showLabel?: boolean;
2225
}
2326

2427
export const MemberSelection = ({
@@ -27,6 +30,7 @@ export const MemberSelection = ({
2730
onMemberAdd,
2831
onMemberRemove,
2932
excludeMembers = [],
33+
showLabel = true, // default true — no change to existing callers
3034
}: MemberSelectionProps) => {
3135
const [searchQuery, setSearchQuery] = useState("");
3236

@@ -44,7 +48,11 @@ export const MemberSelection = ({
4448

4549
return (
4650
<div className="space-y-2">
47-
<label className="dark:text-light-900 text-black">Team Members</label>
51+
{/* Only render label when showLabel is true (default).
52+
Pass showLabel={false} from callers that provide their own heading. */}
53+
{showLabel && (
54+
<label className="dark:text-light-900 text-black">Team Members</label>
55+
)}
4856
<div className="flex gap-2">
4957
<div className="flex flex-wrap items-center gap-2">
5058
{selectedMembers.map((member) => (
@@ -132,4 +140,4 @@ export const MemberSelection = ({
132140
</div>
133141
</div>
134142
);
135-
};
143+
};

0 commit comments

Comments
 (0)