MCPcopy Create free account
hub / github.com/Openpanel-dev/openpanel / ProfileList

Function ProfileList

apps/start/src/modals/view-chart-users.tsx:72–150  ·  view source on GitHub ↗
({ profiles }: { profiles: any[] })

Source from the content-addressed store, hash-verified

70};
71// Shared profile list component
72function ProfileList({ profiles }: { profiles: any[] }) {
73 const ITEM_HEIGHT = 74;
74 const CONTAINER_PADDING = 20;
75 const ITEM_GAP = 5;
76 const { scrollAreaRef } = useScrollableModal();
77 const [isScrollReady, setIsScrollReady] = useState(false);
78
79 // Check if scroll container is ready
80 useEffect(() => {
81 if (scrollAreaRef.current) {
82 setIsScrollReady(true);
83 } else {
84 setIsScrollReady(false);
85 }
86 }, [scrollAreaRef]);
87
88 const virtualizer = useVirtualizer({
89 count: profiles.length,
90 getScrollElement: () => scrollAreaRef.current,
91 estimateSize: () => ITEM_HEIGHT + ITEM_GAP,
92 overscan: 5,
93 paddingStart: CONTAINER_PADDING,
94 paddingEnd: CONTAINER_PADDING,
95 });
96
97 // Re-measure when scroll container becomes available or profiles change
98 useEffect(() => {
99 if (isScrollReady && scrollAreaRef.current) {
100 // Small delay to ensure DOM is ready
101 const timeoutId = setTimeout(() => {
102 virtualizer.measure();
103 }, 0);
104 return () => clearTimeout(timeoutId);
105 }
106 }, [isScrollReady, profiles.length, virtualizer]);
107
108 if (profiles.length === 0) {
109 return (
110 <div className="flex items-center justify-center py-8">
111 <div className="text-muted-foreground">No users found</div>
112 </div>
113 );
114 }
115
116 const virtualItems = virtualizer.getVirtualItems();
117
118 return (
119 <div
120 style={{
121 height: `${virtualizer.getTotalSize()}px`,
122 width: '100%',
123 position: 'relative',
124 }}
125 >
126 {/* Only the visible items in the virtualizer, manually positioned to be in view */}
127 {virtualItems.map((virtualItem) => {
128 const profile = profiles[virtualItem.index];
129 return (

Callers

nothing calls this directly

Calls 2

useScrollableModalFunction · 0.90
mapMethod · 0.45

Tested by

no test coverage detected