Add banner upload input and include banner in completion

cgen-4a69fbe41a0941f8b5d8ba908b67ec1a
This commit is contained in:
Builder.io 2025-09-27 22:29:31 +00:00
parent 0946bc3744
commit bfa0f89f13
2 changed files with 20 additions and 0 deletions

View file

@ -290,6 +290,7 @@ export type Database = {
user_profiles: {
Row: {
avatar_url: string | null;
banner_url: string | null;
bio: string | null;
created_at: string;
experience_level:

View file

@ -134,6 +134,7 @@ export default function Dashboard() {
!!p?.bio,
!!p?.location,
!!p?.avatar_url,
!!p?.banner_url,
!!(p?.website_url || p?.github_url || p?.linkedin_url || p?.twitter_url),
];
const pct = Math.round((checks.filter(Boolean).length / checks.length) * 100);
@ -575,6 +576,24 @@ export default function Dashboard() {
}
}} />
</div>
<div className="md:col-span-2">
<Label htmlFor="banner">Banner Image</Label>
<Input id="banner" type="file" accept="image/*" onChange={async (e) => {
const file = e.target.files?.[0];
if (!file || !user) return;
try {
const path = `${user.id}/banner-${Date.now()}-${file.name}`;
const { error } = await supabase.storage.from("banners").upload(path, file, { upsert: true });
if (error) throw error;
const { data } = supabase.storage.from("banners").getPublicUrl(path);
await updateProfile({ banner_url: data.publicUrl } as any);
computeProfileCompletion({ ...(profile as any), banner_url: data.publicUrl });
aethexToast.success({ title: "Banner updated" });
} catch (err: any) {
aethexToast.error({ title: "Upload failed", description: err?.message || "Unable to upload image" });
}
}} />
</div>
<div className="md:col-span-2">
<Label htmlFor="bio">Bio</Label>
<Textarea id="bio" value={bio} onChange={(e) => setBio(e.target.value)} />