import { MetaFunction } from "@remix-run/node"; import AppInput from "~/components/AppInput"; import ProfilePagesHeader from "../components/ProfilePagesHeader"; import { useEffect, useState } from "react"; import { days, months, years } from "~/assets/data/consts"; import AppSelectBox from "~/components/AppSelectBox"; import { RadioGroup, RadioGroupItem } from "~/components/ui/radio-group"; import { Button } from "~/components/ui/button"; import { useServiceGetProfile, useServiceUpdateProfile, } from "~/utils/RequestHandler"; import { useToast } from "~/hooks/use-toast"; import { Loader2, Mail, Phone, User } from "lucide-react"; import { UserProfileUpdateSexEnum } from "src/api/types"; import { PushSettingToggle } from "~/components/notifications/PushSettingToggle"; export default function Setting() { const { data: dataProfile, isFetching: isFetchingProfile } = useServiceGetProfile(); const [email, setEmail] = useState(""); const [username, setUserName] = useState(""); const [gender, setGender] = useState("male"); const [phoneNumber, setPhoneNumber] = useState(""); const [birthdayYear, setBirthdayYear] = useState(""); const [birthdayMonth, setBirthdayMonth] = useState(""); const [birthdayDay, setBirthdayDay] = useState(""); useEffect(() => { if (dataProfile) { setEmail(dataProfile.email ? dataProfile.email : ""); setUserName(dataProfile.username ? dataProfile.username : ""); setGender(dataProfile.sex ? dataProfile.sex : "male"); setPhoneNumber(dataProfile.phoneNumber ? dataProfile.phoneNumber : ""); setBirthdayYear( dataProfile.birthdate ? dataProfile.birthdate.split("-")[0] : "" ); setBirthdayMonth( dataProfile.birthdate ? dataProfile.birthdate.split("-")[1]?.replace(/^0+/, "") : "" ); setBirthdayDay( dataProfile.birthdate ? dataProfile.birthdate.split("-")[2]?.replace(/^0+/, "") : "" ); } }, [dataProfile]); const updateProfileMutation = useServiceUpdateProfile({ username: username || null, email: email || null, birthdate: birthdayYear && birthdayMonth && birthdayDay ? `${birthdayYear}-${birthdayMonth}-${birthdayDay}` : null, sex: gender, password: null, }); const isValidForm = !!username; const { toast } = useToast(); const onSave = () => { if (!username) { toast({ description: "نام کاربری باید پر شود.", }); return; } updateProfileMutation.mutate(undefined, { onSuccess: () => { toast({ description: "اطلاعات کاربری با موفقیت بروزرسانی شد.", }); window.location.href = "/profile"; }, onError: () => { toast({ description: "خطا در بروزرسانی اطلاعات کاربری.", variant: "destructive", }); }, }); }; return (

اطلاعات کاربری

) => { const value = e.target.value; // Allow English letters, numbers, and specific special characters if ( /^[a-zA-Z0-9!@#$%^&*()_+=\-0987654321`~|\\{}[\]<>?,./]*$/.test( value ) ) { setUserName(value); } }} /> {}} disabled={true} />
) => { const value = e.target.value; setEmail(value); }} />

تاریخ تولد (اختیاری) :

جنسیت (اختیاری) :

setGender(value as UserProfileUpdateSexEnum) } value={gender} >
); } const Divider = ({ className }: { className?: string }) => { return
; }; export const meta: MetaFunction = () => { const title = "ویرایش اطلاعات کاربری | ویترون"; const description = "ویرایش اطلاعات شخصی و تنظیمات حساب کاربری در ویترون"; const imageUrl = "https://vitrownstatics.s3.ir-thr-at1.arvanstorage.ir/SVG-06.svg?versionId="; return [ { title }, { name: "description", content: description }, { name: "keywords", content: "تنظیمات، ویرایش پروفایل، اطلاعات کاربری، ویترون", }, { name: "robots", content: "noindex, follow" }, // Open Graph { property: "og:type", content: "website" }, { property: "og:title", content: title }, { property: "og:description", content: description }, { property: "og:image", content: imageUrl }, { property: "og:site_name", content: "ویترون" }, { property: "og:locale", content: "fa_IR" }, // Twitter Card { name: "twitter:card", content: "summary" }, { name: "twitter:title", content: title }, { name: "twitter:description", content: description }, ]; };