Initial import of 1407 block sources under blocks/
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1,252 @@
|
||||
"use client";
|
||||
|
||||
import { Camera, Github, Globe, Linkedin, Twitter } from "lucide-react";
|
||||
import { useState } from "react";
|
||||
|
||||
import { FileUpload, FileUploadTrigger } from "@/components/diceui/file-upload";
|
||||
import { Avatar, AvatarFallback, AvatarImage } from "@/components/ui/avatar";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import {
|
||||
Card,
|
||||
CardContent,
|
||||
CardDescription,
|
||||
CardHeader,
|
||||
CardTitle,
|
||||
} from "@/components/ui/card";
|
||||
import { Input } from "@/components/ui/input";
|
||||
import { Label } from "@/components/ui/label";
|
||||
import { Separator } from "@/components/ui/separator";
|
||||
import { Textarea } from "@/components/ui/textarea";
|
||||
import { cn } from "@/lib/utils";
|
||||
|
||||
interface ProfileFormData {
|
||||
name: string;
|
||||
email: string;
|
||||
username: string;
|
||||
avatar?: string;
|
||||
bio?: string;
|
||||
jobTitle?: string;
|
||||
company?: string;
|
||||
location?: string;
|
||||
website?: string;
|
||||
socialLinks?: {
|
||||
twitter?: string;
|
||||
linkedin?: string;
|
||||
github?: string;
|
||||
};
|
||||
}
|
||||
|
||||
interface SettingsProfile2Props {
|
||||
defaultValues?: Partial<ProfileFormData>;
|
||||
onSave?: (data: ProfileFormData) => void;
|
||||
className?: string;
|
||||
}
|
||||
|
||||
const SettingsProfile2 = ({
|
||||
defaultValues = {
|
||||
name: "Jordan چناری",
|
||||
email: "jordan.chen@email.com",
|
||||
username: "jordanchen",
|
||||
avatar:
|
||||
"/block-media/shadcnblocks/block/avatar/avatar3.jpg",
|
||||
bio: "توسعهدهنده فولاستک با اشتیاق به ساخت محصولات تأثیرگذار. مشارکتکننده متنباز و گاهی نویسنده وبلاگ فناوری.",
|
||||
jobTitle: "مهندس نرمافزار ارشد",
|
||||
company: "ری یو آی Inc",
|
||||
location: "Seattle, WA",
|
||||
website: "https://jordanchen.dev",
|
||||
socialLinks: {
|
||||
twitter: "jordanchen",
|
||||
linkedin: "jordanchen",
|
||||
github: "jordanchen",
|
||||
},
|
||||
},
|
||||
className,
|
||||
}: SettingsProfile2Props) => {
|
||||
const [avatarFiles, setAvatarFiles] = useState<File[]>([]);
|
||||
|
||||
const initials = defaultValues.name
|
||||
?.split(" ")
|
||||
.map((n) => n[0])
|
||||
.join("")
|
||||
.toUpperCase();
|
||||
|
||||
const avatarPreview =
|
||||
avatarFiles.length > 0
|
||||
? URL.createObjectURL(avatarFiles[0])
|
||||
: defaultValues.avatar;
|
||||
|
||||
return (
|
||||
<Card className={cn("w-full max-w-2xl", className)}>
|
||||
<CardHeader>
|
||||
<CardTitle>ویرایش پروفایل</CardTitle>
|
||||
<CardDescription>
|
||||
اطلاعات عمومی پروفایل خود را مدیریت کنید.
|
||||
</CardDescription>
|
||||
</CardHeader>
|
||||
<CardContent className="space-y-8">
|
||||
{/* Avatar Section */}
|
||||
<FileUpload
|
||||
value={avatarFiles}
|
||||
onValueChange={setAvatarFiles}
|
||||
accept="image/*"
|
||||
maxFiles={1}
|
||||
maxSize={2 * 1024 * 1024}
|
||||
>
|
||||
<div className="flex flex-col items-center gap-4 sm:flex-row sm:items-start">
|
||||
<div className="relative">
|
||||
<Avatar className="size-24">
|
||||
<AvatarImage
|
||||
src={avatarPreview}
|
||||
alt={`تصویر ${defaultValues.name}`}
|
||||
className="object-cover"
|
||||
/>
|
||||
<AvatarFallback className="text-xl font-semibold">
|
||||
{initials}
|
||||
</AvatarFallback>
|
||||
</Avatar>
|
||||
<FileUploadTrigger asChild>
|
||||
<Button
|
||||
size="icon"
|
||||
variant="secondary"
|
||||
className="absolute -end-1 -bottom-1 size-8 rounded-full shadow-md"
|
||||
>
|
||||
<Camera className="size-4" />
|
||||
</Button>
|
||||
</FileUploadTrigger>
|
||||
</div>
|
||||
<div className="space-y-1 text-center sm:text-start">
|
||||
<p className="text-sm font-medium">تصویر پروفایل</p>
|
||||
<p className="text-xs text-muted-foreground">
|
||||
برای بارگذاری تصویر جدید روی آیکون دوربین کلیک کنید.
|
||||
<br />
|
||||
پیشنهاد: تصویر مربعی، حداقل ۴۰۰×۴۰۰ پیکسل.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</FileUpload>
|
||||
|
||||
<Separator />
|
||||
|
||||
{/* Personal Information */}
|
||||
<div className="space-y-4">
|
||||
<h3 className="text-sm font-medium">اطلاعات شخصی</h3>
|
||||
<div className="grid gap-4 sm:grid-cols-2">
|
||||
<div className="space-y-2">
|
||||
<Label htmlFor="name">نام کامل</Label>
|
||||
<Input id="name" defaultValue={defaultValues.name} />
|
||||
</div>
|
||||
<div className="space-y-2">
|
||||
<Label htmlFor="username">نام کاربری</Label>
|
||||
<div className="flex">
|
||||
<span className="inline-flex items-center rounded-s-md border border-e-0 bg-muted px-3 text-sm text-muted-foreground">
|
||||
@
|
||||
</span>
|
||||
<Input
|
||||
id="username"
|
||||
className="rounded-s-none"
|
||||
defaultValue={defaultValues.username}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div className="space-y-2">
|
||||
<Label htmlFor="bio">درباره من</Label>
|
||||
<Textarea
|
||||
id="bio"
|
||||
rows={3}
|
||||
defaultValue={defaultValues.bio}
|
||||
placeholder="درباره خودتان چند خط بنویسید"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<Separator />
|
||||
|
||||
{/* Work Information */}
|
||||
<div className="space-y-4">
|
||||
<h3 className="text-sm font-medium">کار</h3>
|
||||
<div className="grid gap-4 sm:grid-cols-2">
|
||||
<div className="space-y-2">
|
||||
<Label htmlFor="jobTitle">عنوان شغلی</Label>
|
||||
<Input id="jobTitle" defaultValue={defaultValues.jobTitle} />
|
||||
</div>
|
||||
<div className="space-y-2">
|
||||
<Label htmlFor="company">شرکت</Label>
|
||||
<Input id="company" defaultValue={defaultValues.company} />
|
||||
</div>
|
||||
</div>
|
||||
<div className="space-y-2">
|
||||
<Label htmlFor="location">موقعیت</Label>
|
||||
<Input
|
||||
id="location"
|
||||
defaultValue={defaultValues.location}
|
||||
placeholder="شهر، کشور"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<Separator />
|
||||
|
||||
{/* Social Links */}
|
||||
<div className="space-y-4">
|
||||
<h3 className="text-sm font-medium">لینکهای شبکههای اجتماعی</h3>
|
||||
<div className="space-y-3">
|
||||
<div className="flex items-center gap-3">
|
||||
<Globe className="size-5 shrink-0 text-muted-foreground" />
|
||||
<Input
|
||||
placeholder="https://yourwebsite.com"
|
||||
defaultValue={defaultValues.website}
|
||||
/>
|
||||
</div>
|
||||
<div className="flex items-center gap-3">
|
||||
<Twitter className="size-5 shrink-0 text-muted-foreground" />
|
||||
<div className="flex flex-1">
|
||||
<span className="inline-flex items-center rounded-s-md border border-e-0 bg-muted px-3 text-sm text-muted-foreground">
|
||||
x.com/
|
||||
</span>
|
||||
<Input
|
||||
className="rounded-s-none"
|
||||
placeholder="نام کاربری"
|
||||
defaultValue={defaultValues.socialLinks?.twitter}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div className="flex items-center gap-3">
|
||||
<Linkedin className="size-5 shrink-0 text-muted-foreground" />
|
||||
<div className="flex flex-1">
|
||||
<span className="inline-flex items-center rounded-s-md border border-e-0 bg-muted px-3 text-sm text-muted-foreground">
|
||||
شبکه حرفهای.com/in/
|
||||
</span>
|
||||
<Input
|
||||
className="rounded-s-none"
|
||||
placeholder="نام کاربری"
|
||||
defaultValue={defaultValues.socialLinks?.linkedin}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div className="flex items-center gap-3">
|
||||
<Github className="size-5 shrink-0 text-muted-foreground" />
|
||||
<div className="flex flex-1">
|
||||
<span className="inline-flex items-center rounded-s-md border border-e-0 bg-muted px-3 text-sm text-muted-foreground">
|
||||
مخزن کد.com/
|
||||
</span>
|
||||
<Input
|
||||
className="rounded-s-none"
|
||||
placeholder="نام کاربری"
|
||||
defaultValue={defaultValues.socialLinks?.github}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="flex justify-end gap-2 pt-4">
|
||||
<Button variant="outline">انصراف</Button>
|
||||
<Button>ذخیره تغییرات</Button>
|
||||
</div>
|
||||
</CardContent>
|
||||
</Card>
|
||||
);
|
||||
};
|
||||
|
||||
export { SettingsProfile2 };
|
||||
Reference in New Issue
Block a user