-
+
+
+ Create Student
+
- Enter their code to request enrollment. The parent will need to approve.
+ Quick setup - student doesn't need an existing account
+ {/* Divider */}
+
+
+ {/* Family Code Section */}
+
+
+
+ Enter their code to request enrollment. The parent will need to approve.
+
+
+
+ onFamilyCodeChange(e.target.value.toUpperCase())}
+ onKeyDown={(e) => {
+ if (e.key === 'Enter' && familyCode.trim() && !isSubmittingFamilyCode) {
+ onFamilyCodeSubmit()
+ }
+ }}
+ placeholder="e.g., ABCD-1234"
+ data-element="family-code-input"
+ className={css({
+ flex: 1,
+ padding: '10px 12px',
+ fontSize: '1rem',
+ fontFamily: 'monospace',
+ textAlign: 'center',
+ letterSpacing: '0.08em',
+ backgroundColor: isDark ? 'gray.700' : 'white',
+ border: '2px solid',
+ borderColor: familyCodeError
+ ? isDark
+ ? 'red.500'
+ : 'red.400'
+ : isDark
+ ? 'gray.600'
+ : 'gray.300',
+ borderRadius: '8px',
+ color: isDark ? 'white' : 'gray.900',
+ outline: 'none',
+ _focus: {
+ borderColor: 'blue.500',
+ boxShadow: '0 0 0 3px rgba(59, 130, 246, 0.2)',
+ },
+ _placeholder: {
+ color: isDark ? 'gray.500' : 'gray.400',
+ },
+ })}
+ />
+
+
+
+ {familyCodeError && (
+
+ {familyCodeError}
+
+ )}
+
+ >
+ )
+}
+
+interface CreateStudentSectionProps {
+ name: string
+ onNameChange: (name: string) => void
+ emoji: string
+ onEmojiClick: () => void
+ color: string
+ onColorChange: (color: string) => void
+ onSubmit: () => void
+ onCancel: () => void
+ isPending: boolean
+ isDark: boolean
+}
+
+function CreateStudentSection({
+ name,
+ onNameChange,
+ emoji,
+ onEmojiClick,
+ color,
+ onColorChange,
+ onSubmit,
+ onCancel,
+ isPending,
+ isDark,
+}: CreateStudentSectionProps) {
+ return (
+
+ {/* Avatar Preview */}
+
+
+
+ Tap to change
+
+
+
+ {/* Name input */}
+
+
+ onNameChange(e.target.value)}
+ onKeyDown={(e) => {
+ if (e.key === 'Enter' && name.trim() && !isPending) {
+ onSubmit()
+ }
+ }}
+ placeholder="Enter student name"
+ // biome-ignore lint/a11y/noAutofocus: Form just shown, focusing input is expected UX
+ autoFocus
+ className={css({
+ width: '100%',
+ padding: '10px 12px',
+ fontSize: '1rem',
+ borderRadius: '8px',
+ border: '1px solid',
+ borderColor: isDark ? 'gray.600' : 'gray.300',
+ backgroundColor: isDark ? 'gray.700' : 'white',
+ color: isDark ? 'gray.100' : 'gray.800',
+ _focus: {
+ outline: 'none',
+ borderColor: 'blue.500',
+ boxShadow: '0 0 0 2px rgba(59, 130, 246, 0.3)',
+ },
+ })}
+ />
+
+
+ {/* Color selector */}
+
+
+
+ {AVAILABLE_COLORS.map((c) => (
+
+
+
+ {/* Form actions */}
- onChange(e.target.value.toUpperCase())}
- onKeyDown={(e) => {
- if (e.key === 'Enter' && value.trim() && !isSubmitting) {
- onSubmit()
- }
- }}
- placeholder="e.g., ABCD-1234"
- data-element="family-code-input"
+
-
-
-
- {error && (
-
- {error}
-
- )}
+ {isPending ? 'Adding...' : 'Add & Enroll'}
+
+
)
}