@@ -2,31 +2,16 @@ import type React from "react"
22
33import { useState , useRef , useEffect } from "react"
44import { motion } from "framer-motion"
5- import { Upload , CheckCircle , User , Mail , Hash , BookOpen , Building , X , ChevronDown , Check } from "lucide-react"
5+ import { Upload , CheckCircle , User , Mail , Hash , BookOpen , Building , X } from "lucide-react"
66import { Button } from "@/components/ui/button"
77import { Card , CardContent } from "@/components/ui/card"
88import { Input } from "@/components/ui/input"
99import { Label } from "@/components/ui/label"
1010import { Checkbox } from "@/components/ui/checkbox"
11- import {
12- Command ,
13- CommandEmpty ,
14- CommandGroup ,
15- CommandInput ,
16- CommandItem ,
17- CommandList
18- } from "@/components/ui/command"
19- import {
20- Popover ,
21- PopoverContent ,
22- PopoverTrigger ,
23- } from "@/components/ui/popover"
2411import axios from "axios"
2512import { useAuth } from "@/context/AuthContext"
2613import { useNavigate } from "react-router-dom"
2714import { toast } from "react-hot-toast"
28- import institutions from "@/lib/colleges"
29- import branches from "@/lib/branches"
3015
3116export default function ProfileEditForm ( ) {
3217 const { user, token, fetchUser } = useAuth ( )
@@ -63,11 +48,6 @@ export default function ProfileEditForm() {
6348 } )
6449
6550 const [ image , setImage ] = useState < string | null > ( null )
66- const [ collegePopoverOpen , setCollegePopoverOpen ] = useState ( false )
67- const [ branchPopoverOpen , setBranchPopoverOpen ] = useState ( false )
68- const [ collegeSearchValue , setCollegeSearchValue ] = useState ( "" )
69- const [ branchSearchValue , setBranchSearchValue ] = useState ( "" )
70-
7151 const fileInputRef = useRef < HTMLInputElement > ( null )
7252 const [ isLoading , setIsLoading ] = useState ( false )
7353 const [ buttonText , setButtonText ] = useState ( "Save Profile" )
@@ -312,6 +292,7 @@ export default function ProfileEditForm() {
312292 value = { formData . name }
313293 onChange = { handleChange }
314294 required
295+ disabled = { true }
315296 />
316297 </ div >
317298 </ div >
@@ -357,123 +338,36 @@ export default function ProfileEditForm() {
357338 className = "bg-background/50 border-input focus:border-primary transition-colors duration-300"
358339 value = { formData . registerNumber }
359340 onChange = { handleChange }
341+ disabled = { true }
360342 />
361343 </ div >
362344
363- < div className = "space-y-2 overflow-hidden " >
345+ < div className = "space-y-2" >
364346 < Label htmlFor = "branch" className = "flex items-center gap-2" >
365347 < BookOpen className = "w-4 h-4" /> Branch
366348 </ Label >
367- < Popover open = { branchPopoverOpen } onOpenChange = { ( open ) => {
368- setBranchPopoverOpen ( open )
369- if ( ! open ) setBranchSearchValue ( "" )
370- } } >
371- < PopoverTrigger asChild >
372- < Button
373- variant = "outline"
374- role = "combobox"
375- aria-expanded = { branchPopoverOpen }
376- className = "w-full justify-between bg-background/50 border-input focus:border-primary transition-colors duration-300 h-10"
377- >
378- { formData . branch ? formData . branch : "Select branch..." }
379- < ChevronDown className = "ml-2 h-4 w-4 shrink-0 opacity-50" />
380- </ Button >
381- </ PopoverTrigger >
382- < PopoverContent className = "w-full p-0" style = { { width : "var(--radix-popover-trigger-width)" } } >
383- < Command shouldFilter = { false } >
384- < CommandInput
385- placeholder = "Search branch..."
386- className = "h-9"
387- value = { branchSearchValue }
388- onValueChange = { setBranchSearchValue }
389- />
390- < CommandList className = "max-h-[200px] overflow-y-auto" >
391- < CommandEmpty > No branch found.</ CommandEmpty >
392- < CommandGroup >
393- { branches
394- . filter ( ( branch ) =>
395- branch . toLowerCase ( ) . includes ( branchSearchValue . toLowerCase ( ) )
396- )
397- . map ( ( branch ) => (
398- < CommandItem
399- key = { branch }
400- value = { branch }
401- onSelect = { ( ) => {
402- setFormData ( ( prev ) => ( { ...prev , branch : branch } ) )
403- setBranchPopoverOpen ( false )
404- setBranchSearchValue ( "" )
405- } }
406- className = "flex items-center"
407- >
408- { branch }
409- { formData . branch === branch && (
410- < Check className = "ml-auto h-4 w-4" />
411- ) }
412- </ CommandItem >
413- ) ) }
414- </ CommandGroup >
415- </ CommandList >
416- </ Command >
417- </ PopoverContent >
418- </ Popover >
349+ < Input
350+ id = "branch"
351+ placeholder = "Your branch"
352+ className = "bg-background/50 border-input focus:border-primary transition-colors duration-300"
353+ value = { formData . branch }
354+ disabled = { true }
355+ readOnly
356+ />
419357 </ div >
420358
421- < div className = "space-y-2 overflow-hidden " >
359+ < div className = "space-y-2" >
422360 < Label htmlFor = "college" className = "flex items-center gap-2" >
423361 < Building className = "w-4 h-4" /> College
424362 </ Label >
425- < Popover open = { collegePopoverOpen } onOpenChange = { ( open ) => {
426- setCollegePopoverOpen ( open )
427- if ( ! open ) setCollegeSearchValue ( "" )
428- } } >
429- < PopoverTrigger asChild >
430- < Button
431- variant = "outline"
432- role = "combobox"
433- aria-expanded = { collegePopoverOpen }
434- className = "w-full justify-between bg-background/50 border-input focus:border-primary transition-colors duration-300 h-10"
435- >
436- { formData . college ? formData . college : "Select college..." }
437- < ChevronDown className = "ml-2 h-4 w-4 shrink-0 opacity-50" />
438- </ Button >
439- </ PopoverTrigger >
440- < PopoverContent className = "w-full p-0" style = { { width : "var(--radix-popover-trigger-width)" } } >
441- < Command shouldFilter = { false } >
442- < CommandInput
443- placeholder = "Search college..."
444- className = "h-9"
445- value = { collegeSearchValue }
446- onValueChange = { setCollegeSearchValue }
447- />
448- < CommandList className = "max-h-[200px] overflow-y-auto" >
449- < CommandEmpty > No college found.</ CommandEmpty >
450- < CommandGroup >
451- { institutions
452- . filter ( ( college ) =>
453- college . toLowerCase ( ) . includes ( collegeSearchValue . toLowerCase ( ) )
454- )
455- . map ( ( college ) => (
456- < CommandItem
457- key = { college }
458- value = { college }
459- onSelect = { ( ) => {
460- setFormData ( ( prev ) => ( { ...prev , college : college } ) )
461- setCollegePopoverOpen ( false )
462- setCollegeSearchValue ( "" )
463- } }
464- className = "flex items-center"
465- >
466- { college }
467- { formData . college === college && (
468- < Check className = "ml-auto h-4 w-4" />
469- ) }
470- </ CommandItem >
471- ) ) }
472- </ CommandGroup >
473- </ CommandList >
474- </ Command >
475- </ PopoverContent >
476- </ Popover >
363+ < Input
364+ id = "college"
365+ placeholder = "Your college"
366+ className = "bg-background/50 border-input focus:border-primary transition-colors duration-300"
367+ value = { formData . college }
368+ disabled = { true }
369+ readOnly
370+ />
477371 </ div >
478372 </ motion . div >
479373
0 commit comments