Skip to content

Commit 953b2bb

Browse files
committed
Add static profile picture input
1 parent 2e40914 commit 953b2bb

File tree

1 file changed

+46
-0
lines changed

1 file changed

+46
-0
lines changed
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
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+
}

0 commit comments

Comments
 (0)