11"use client" ;
2- // TODO: 挙動修正
2+
33import { zodResolver } from "@hookform/resolvers/zod" ;
44import type { User } from "common/types" ;
55import { UpdateUserSchema } from "common/zod/schemas" ;
@@ -53,11 +53,11 @@ function EditProfile({ defaultValues }: { defaultValues: User }) {
5353 await update ( data ) ;
5454 }
5555
56- const [ savedData , setSavedData ] = useState ( defaultValues ) ;
56+ const [ savedData , setSavedData ] = useState ( defaultValues ) ; // TODO: unused
5757
5858 function afterPhotoUpload ( result : string ) {
5959 try {
60- updateData ( "pictureUrl" , result ) ;
60+ updateData ( "pictureUrl" , result ) ; // TODO: no such function
6161 } catch ( err ) {
6262 console . error ( err ) ;
6363 // probably a network error
@@ -101,16 +101,26 @@ function EditProfile({ defaultValues }: { defaultValues: User }) {
101101
102102 const values = getValues ( ) ;
103103 return (
104- < div className = "mx-2 mt-2 flex h-auto w-[70vw] flex-col gap-2 overflow-y-scroll " >
104+ < div className = "mt-14 h-full " >
105105 < form className = "" onSubmit = { handleSubmit ( submit ) } >
106- < h1 className = "text-xl" > プロフィール編集</ h1 >
107- < input className = "input input-bordered w-full" { ...register ( "name" ) } />
108-
109- < p className = "flex items-center" >
110- < label className = "w-full" >
111- < h1 className = "text-xl" > 性別</ h1 >
106+ < div className = "flex flex-col gap-2 p-2" >
107+ < div >
108+ < label htmlFor = "name" className = "text-md" >
109+ 名前
110+ </ label >
111+ < input
112+ className = "input input-bordered w-full"
113+ id = "name"
114+ { ...register ( "name" ) }
115+ />
116+ </ div >
117+ < div >
118+ < label htmlFor = "gender" className = "text-md" >
119+ 性別
120+ </ label >
112121 < select
113122 className = "select select-bordered w-full"
123+ id = "gender"
114124 { ...register ( "gender" ) }
115125 >
116126 < option value = { "男性" } > 男性</ option >
@@ -119,14 +129,14 @@ function EditProfile({ defaultValues }: { defaultValues: User }) {
119129 < option value = { "秘密" } > 秘密</ option >
120130 </ select >
121131 < span className = "text-error text-sm" > { errors . gender ?. message } </ span >
122- </ label >
123- </ p >
124-
125- < p className = "flex items-center" >
126- < label className = "w-full" >
127- < h1 className = "text-xl" > 学年</ h1 >
132+ </ div >
133+ < div >
134+ < label htmlFor = "grade" className = "text-md" >
135+ 学年
136+ </ label >
128137 < select
129138 className = "select select-bordered w-full"
139+ id = "grade"
130140 { ...register ( "grade" ) }
131141 >
132142 < option value = { "B1" } > 1年生 (B1)</ option >
@@ -137,14 +147,14 @@ function EditProfile({ defaultValues }: { defaultValues: User }) {
137147 < option value = { "M2" } > 修士2年 (M2)</ option >
138148 </ select >
139149 < span className = "text-error text-sm" > { errors . grade ?. message } </ span >
140- </ label >
141- </ p >
142-
143- < p className = "flex items-center" >
144- < label className = "w-full" >
145- < h1 className = "text-xl" > 学部</ h1 >
150+ </ div >
151+ < div >
152+ < label htmlFor = "faculty" className = "text-md" >
153+ 学部
154+ </ label >
146155 < select
147156 className = "select select-bordered w-full"
157+ id = "faculty"
148158 { ...register ( "faculty" ) }
149159 >
150160 { faculties . map ( ( fac ) => (
@@ -154,14 +164,14 @@ function EditProfile({ defaultValues }: { defaultValues: User }) {
154164 < span className = "text-error text-sm" >
155165 { errors . faculty ?. message }
156166 </ span >
157- </ label >
158- </ p >
159-
160- < p className = "flex items-center" >
161- < label className = "w-full" >
162- < h1 className = "text-xl" > 学科</ h1 >
167+ </ div >
168+ < div >
169+ < label htmlFor = "department" className = "text-md" >
170+ 学科
171+ </ label >
163172 < select
164173 className = "select select-bordered w-full"
174+ id = "department"
165175 { ...register ( "department" ) }
166176 >
167177 { values . faculty &&
@@ -174,74 +184,63 @@ function EditProfile({ defaultValues }: { defaultValues: User }) {
174184 < span className = "text-error text-sm" >
175185 { errors . department ?. message }
176186 </ span >
177- </ label >
178- </ p >
179-
180- < p className = "flex items-center justify-between" >
181- < label className = "w-full" >
182- < h1 className = "text-xl" > 自己紹介</ h1 >
187+ </ div >
188+ < div >
189+ < label htmlFor = "intro" className = "text-md" >
190+ 自己紹介
191+ </ label >
183192 < textarea
184193 className = "textarea textarea-bordered w-full"
194+ id = "intro"
185195 { ...register ( "intro" ) }
186196 rows = { 3 }
187197 autoComplete = "off"
188198 />
189- </ label >
190- </ p >
191-
192- < div className = "mt-6 text-center" >
193- < h1 className = "text-xl" > プロフィール画像</ h1 >
194- </ div >
195- < div className = "mt-6 flex flex-col items-center text-center" >
196- < div style = { { margin : "auto" } } >
197- < UserAvatar
198- width = "300px"
199- height = "300px"
200- pictureUrl = { values . pictureUrl }
199+ </ div >
200+ < div className = "mt-4 flex flex-col items-center text-center" >
201+ < span className = "text-md" > プロフィール画像</ span >
202+ < div style = { { margin : "auto" } } >
203+ < UserAvatar
204+ width = "300px"
205+ height = "300px"
206+ pictureUrl = { values . pictureUrl }
207+ />
208+ </ div >
209+ < PhotoPreviewButton
210+ text = "写真を選択"
211+ onSelect = { ( ) => setOpen ( true ) }
212+ />
213+ < PhotoModal
214+ open = { open }
215+ closeFunc = { ( ) => setOpen ( false ) }
216+ afterUpload = { afterPhotoUpload }
217+ onError = { ( err ) =>
218+ enqueueSnackbar ( {
219+ variant : "error" ,
220+ message : err . message ,
221+ } )
222+ }
201223 />
224+ < span className = "text-error text-sm" >
225+ { errors . pictureUrl ?. message }
226+ </ span >
227+ </ div >
228+ < div className = "flex justify-between" >
229+ < button type = "button" className = "btn btn-sm" onClick = { handleBack } >
230+ 設定画面に戻る
231+ </ button >
232+ < button type = "submit" className = "btn btn-sm btn-primary" >
233+ 保存
234+ </ button >
235+ < button
236+ type = "button"
237+ className = "btn btn-sm btn-secondary"
238+ onClick = { handleGoToCourses }
239+ >
240+ 授業編集へ
241+ </ button >
202242 </ div >
203- < PhotoPreviewButton
204- text = "写真を選択"
205- onSelect = { ( ) => setOpen ( true ) }
206- />
207- < PhotoModal
208- open = { open }
209- closeFunc = { ( ) => setOpen ( false ) }
210- afterUpload = { afterPhotoUpload }
211- onError = { ( err ) =>
212- enqueueSnackbar ( {
213- variant : "error" ,
214- message : err . message ,
215- } )
216- }
217- />
218- < span className = "text-error text-sm" >
219- { errors . pictureUrl ?. message }
220- </ span >
221243 </ div >
222-
223- < p className = "mt-10 flex content-between " >
224- < button
225- type = "button"
226- className = "btn w-[35vh] rounded-full shadow-gray-400 shadow-md"
227- onClick = { handleBack }
228- >
229- 設定画面に戻る
230- </ button >
231- < button
232- type = "submit"
233- className = "btn btn-primary w-[35vh] rounded-full shadow-gray-400 shadow-md"
234- >
235- save!
236- </ button >
237- < button
238- type = "button"
239- className = "btn btn-secondary w-[35vh] rounded-full shadow-gray-400 shadow-md"
240- onClick = { handleGoToCourses }
241- >
242- 授業編集へ
243- </ button >
244- </ p >
245244 </ form >
246245 </ div >
247246 ) ;
0 commit comments