Skip to content

Commit 30bb2ed

Browse files
Jose Cruzclaude
andcommitted
Replace school search input with static Boston University display
Sapling is now BU-only, so the onboarding school step no longer needs a university search. Replaced with a fixed label and cleaned up the unused search state, API call, and ref. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 08e8414 commit 30bb2ed

1 file changed

Lines changed: 13 additions & 94 deletions

File tree

frontend/src/components/OnboardingFlow.tsx

Lines changed: 13 additions & 94 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
'use client';
22

3-
import { useState, useEffect, useRef } from 'react';
3+
import { useState, useEffect } from 'react';
44
import { X, ChevronRight, ChevronLeft, XCircle } from 'lucide-react';
55

66

@@ -113,10 +113,7 @@ interface Props {
113113

114114
export default function OnboardingFlow({ visible, onClose, onFinish, activeStep, completed, setActiveStep, setCompleted }: Props) {
115115
const [classInput, setClassInput] = useState('');
116-
const [schoolSuggestions, setSchoolSuggestions] = useState<string[]>([]);
117-
const [schoolFocused, setSchoolFocused] = useState(false);
118116
const [yearOpen, setYearOpen] = useState(false);
119-
const schoolDebounceRef = useRef<NodeJS.Timeout | null>(null);
120117

121118
const YEAR_OPTIONS = ['Freshman', 'Sophomore', 'Junior', 'Senior', 'Graduate', 'Other'];
122119
const [majorInput, setMajorInput] = useState('');
@@ -128,29 +125,17 @@ export default function OnboardingFlow({ visible, onClose, onFinish, activeStep,
128125

129126
const [formData, setFormData] = useState<FormData>({
130127
firstName: '', lastName: '',
131-
school: '', year: '', majors: [], minors: [], courses: [], style: '',
128+
school: 'Boston University', year: '', majors: [], minors: [], courses: [], style: '',
132129
});
133130

134131

135132
// Escape key closes
136133
useEffect(() => {
137-
if (!visible) {
138-
if (schoolDebounceRef.current) {
139-
clearTimeout(schoolDebounceRef.current);
140-
schoolDebounceRef.current = null;
141-
}
142-
return;
143-
}
134+
if (!visible) return;
144135

145136
const handler = (e: KeyboardEvent) => { if (e.key === 'Escape') onClose(); };
146137
window.addEventListener('keydown', handler);
147-
return () => {
148-
window.removeEventListener('keydown', handler);
149-
if (schoolDebounceRef.current) {
150-
clearTimeout(schoolDebounceRef.current);
151-
schoolDebounceRef.current = null;
152-
}
153-
};
138+
return () => window.removeEventListener('keydown', handler);
154139
}, [visible, onClose]);
155140

156141
function handleOptionKeyDown(event: React.KeyboardEvent<HTMLButtonElement>, onSelect: () => void) {
@@ -160,33 +145,11 @@ export default function OnboardingFlow({ visible, onClose, onFinish, activeStep,
160145
}
161146
}
162147

163-
function selectSchool(name: string) {
164-
setFormData(prev => ({ ...prev, school: name }));
165-
setSchoolSuggestions([]);
166-
}
167-
168148
function selectYear(option: string) {
169149
setFormData(prev => ({ ...prev, year: option.toLowerCase() }));
170150
setYearOpen(false);
171151
}
172152

173-
function handleSchoolInput(value: string) {
174-
setFormData(prev => ({ ...prev, school: value }));
175-
if (schoolDebounceRef.current) clearTimeout(schoolDebounceRef.current);
176-
if (value.trim().length < 2) { setSchoolSuggestions([]); return; }
177-
schoolDebounceRef.current = setTimeout(async () => {
178-
try {
179-
const res = await fetch(`https://universities.hipolabs.com/search?name=${encodeURIComponent(value)}&country=United+States`);
180-
const data: { name: string }[] = await res.json();
181-
setSchoolSuggestions(data.slice(0, 10).map(u => u.name));
182-
} catch {
183-
setSchoolSuggestions([]);
184-
} finally {
185-
schoolDebounceRef.current = null;
186-
}
187-
}, 300);
188-
}
189-
190153
function handleMajorInput(value: string) {
191154
setMajorInput(value);
192155
if (value.trim().length < 1) { setMajorSuggestions([]); return; }
@@ -424,60 +387,16 @@ export default function OnboardingFlow({ visible, onClose, onFinish, activeStep,
424387
Where do you study?
425388
</h3>
426389
<p style={subtitleStyle}>
427-
Tell us your school and year.
390+
Sapling is currently available for BU affiliates. Select your year below.
428391
</p>
429-
<div style={{ position: 'relative', marginBottom: '10px', zIndex: 20 }}>
430-
<input type="text" value={formData.school}
431-
onChange={e => handleSchoolInput(e.target.value)}
432-
onFocus={() => setSchoolFocused(true)}
433-
onBlur={() => setTimeout(() => setSchoolFocused(false), 150)}
434-
placeholder="Search your university..." autoFocus
435-
style={{ ...inputStyle }} />
436-
{schoolFocused && schoolSuggestions.length > 0 && (
437-
<div style={{
438-
position: 'absolute', top: 'calc(100% + 6px)', left: 0, right: 0,
439-
background: '#ffffff',
440-
border: '1px solid rgba(0,0,0,0.1)',
441-
borderRadius: '14px',
442-
maxHeight: '192px', overflowY: 'auto',
443-
zIndex: 100,
444-
boxShadow: '0 8px 32px rgba(0,0,0,0.12)',
445-
}} role="listbox" aria-label="School suggestions">
446-
{schoolSuggestions.map((name, i) => (
447-
<button
448-
key={i}
449-
type="button"
450-
role="option"
451-
aria-selected={formData.school === name}
452-
onMouseDown={() => selectSchool(name)}
453-
onKeyDown={e => handleOptionKeyDown(e, () => selectSchool(name))}
454-
style={{
455-
width: '100%',
456-
textAlign: 'left',
457-
padding: '12px 18px',
458-
fontSize: '14px',
459-
color: '#111827',
460-
cursor: 'pointer',
461-
borderBottom: i < schoolSuggestions.length - 1 ? '1px solid rgba(0,0,0,0.06)' : 'none',
462-
fontFamily: "var(--font-dm-sans), 'DM Sans', sans-serif",
463-
transition: 'background 0.15s',
464-
background: formData.school === name ? 'rgba(27,108,66,0.06)' : 'transparent',
465-
borderLeft: 'none',
466-
borderRight: 'none',
467-
borderTop: 'none',
468-
}}
469-
onMouseEnter={e => {
470-
if (formData.school !== name) e.currentTarget.style.background = 'rgba(27,108,66,0.08)';
471-
}}
472-
onMouseLeave={e => {
473-
e.currentTarget.style.background = formData.school === name ? 'rgba(27,108,66,0.06)' : 'transparent';
474-
}}
475-
>
476-
{name}
477-
</button>
478-
))}
479-
</div>
480-
)}
392+
<div style={{
393+
...inputStyle,
394+
marginBottom: '10px',
395+
color: '#111827',
396+
fontWeight: 500,
397+
background: 'rgba(255,255,255,0.65)',
398+
}}>
399+
Boston University
481400
</div>
482401
<div style={{ position: 'relative', zIndex: yearOpen ? 20 : 1 }}>
483402
<button

0 commit comments

Comments
 (0)