File tree Expand file tree Collapse file tree 1 file changed +46
-0
lines changed
frontend/src/components/form Expand file tree Collapse file tree 1 file changed +46
-0
lines changed Original file line number Diff line number Diff line change
1
+ "use client" ;
2
+
3
+ import {
4
+ FormControl ,
5
+ FormField ,
6
+ FormItem ,
7
+ FormLabel ,
8
+ } from "@/components/ui/form" ;
9
+ import { FieldPath , FieldValues , useFormContext } from "react-hook-form" ;
10
+ import UserAvatar from "@/components/UserAvatar" ;
11
+ import { Button } from "@/components/ui/button" ;
12
+
13
+ interface UserAvatarInputProps < TFieldValues extends FieldValues > {
14
+ label : string ;
15
+ name : FieldPath < TFieldValues > ;
16
+ }
17
+
18
+ export function UserAvatarInput < TFieldValues extends FieldValues > ( {
19
+ label,
20
+ name,
21
+ } : UserAvatarInputProps < TFieldValues > ) {
22
+ const form = useFormContext ( ) ;
23
+
24
+ return (
25
+ < FormField
26
+ control = { form . control }
27
+ name = { name }
28
+ render = { ( { field } ) => (
29
+ < FormItem >
30
+ < FormLabel > { label } </ FormLabel >
31
+ < FormControl >
32
+ < div className = "flex gap-5" >
33
+ < UserAvatar isHoverEnabled = { false } src = { "" } name = { "A" } className = "w-20 h-20" />
34
+ < div className = "flex flex-col items-start flex-1" >
35
+ < Button variant = "soft" > Upload Image</ Button >
36
+ < small >
37
+ .png, .jpeg files up to 2MB. Recommended size is 256x256px.
38
+ </ small >
39
+ </ div >
40
+ </ div >
41
+ </ FormControl >
42
+ </ FormItem >
43
+ ) }
44
+ />
45
+ ) ;
46
+ }
You can’t perform that action at this time.
0 commit comments