diff --git a/app/User/PnpUser/page.tsx b/app/User/PnpUser/page.tsx index cb2be10..7d51a3c 100644 --- a/app/User/PnpUser/page.tsx +++ b/app/User/PnpUser/page.tsx @@ -1,7 +1,6 @@ +import PnpUser from '@/components/Settings/pnp/PnpUser' import React from 'react' export default function page() { - return ( -
page
- ) + return } diff --git a/app/User/Profile/page.tsx b/app/User/Profile/page.tsx index 829b8c7..68eef02 100644 --- a/app/User/Profile/page.tsx +++ b/app/User/Profile/page.tsx @@ -1,4 +1,4 @@ -import Profile from "@/components/Settings/Profile"; +import Profile from "@/components/Settings/profile/Profile"; import React from "react"; export default function page() { diff --git a/app/User/Settings/page.tsx b/app/User/Settings/page.tsx index bae71f9..dcb1905 100644 --- a/app/User/Settings/page.tsx +++ b/app/User/Settings/page.tsx @@ -1,4 +1,4 @@ -import Settings from "@/components/Settings/Settings"; +import Settings from "@/components/Settings/setting/Settings"; import React from "react"; export default function page() { diff --git a/components/Settings/pnp/PnpUser.tsx b/components/Settings/pnp/PnpUser.tsx new file mode 100644 index 0000000..5cb0b3a --- /dev/null +++ b/components/Settings/pnp/PnpUser.tsx @@ -0,0 +1,73 @@ +import React from "react"; + +function PnpUser() { + return ( + <> +
+
+

سیاست نامه حریم خصوصی

+

+ «شهربین» به حریم خصوصی کاربران خود احترام می‌گذارد و متعهد به حفاظت + از اطلاعات شخصی است که شما در اختیار آن می‌گذارید. از آنجا که + جمع‌آوری و پردازش اطلاعات شخصی بخش غیرقابل اجتنابی در فرایندهای + مبتنی بر گوشی همراه و اینترنت است لذا به منظور آگاهی کامل از سیاست و + عملکرد شهربین در این زمینه، مطالعه این سند تحت عنوان «سیاست نامه + حریم خصوصی» و هر گونه پیام دیگری که در خصوص جمع‌آوری و پردازش + اطلاعات توسط شهربین به حساب کاربری شما ارسال می‌شود، ضروری است. این + سند مشتمل بر موارد ذیل در خصوص اطلاعات شخصی و یک واژه‌نامه است که + مطالعه آن را برای درک بهتر اصطلاحات تخصصی پیشنهاد می‌کنیم. +

+
+ +
+

درباره شهربین

+

+ نرم‌افزار شهربین یک سامانه آنلاین شهروندی است که اولین نسخه آن در + سال 1397 طراحی و منتشر شد. این محصول متعلق به شرکت آوای شتاب دهنده + پیشگامان به شماره ثبت 16856 است. +

+
+ +
+

تغییرات این سند

+

+ این سند مطابق با آخرین تغییرات قوانین و مقررات موضوعه کشور تدوین شده + و مبیّن کلیه حقوق شما تحت قانون تجارت الکترونیکی مصوب ۱۳۸۲و اسناد + بین‌المللی ذی‌ربط است. این سند ممکن است دستخوش تغییرات و تجدیدنظر + شود و در صورتی که اطلاع‌رسانی تغییرات به موجب قانون الزامی باشد، این + تغییرات از طریق حساب کاربری به کاربران اطلاع داده خواهد شد. این سند، + آخرین بار در تاریخ شهریور 1400 مورد بازبینی و به‌روزرسانی قرار گرفت. +

+
+ +
+

+ کدام اطلاعات توسط شهربین جمع آوری می شوند +

+

+ اطلاعات ممکن است توام با نصب و/یا استفاده شما از خدمات شهربین + (اطلاعات فنی و گزارش‌های سرور عمدتاً به این شیوه جمع‌آوری می‌شوند و + در سرورهای ما نگهداری می‌شوند) در دسترس و اختیار شهربین قرار گیرد، + همچنین شهربین ممکن است اطلاعات را مستقیماً از شما دریافت کند (هنگام + ایجاد حساب کاربری، ثبت نظر، تماس و مکاتبه با پشتیبانی و یا تکمیل هر + فرم یا ورود اختیاری اطلاعات) +

+
+ +
+

+ اطلاعاتی که با نصب و/یا استفاده از نرم‌افزار شهربین جمع‌آوری می‌شوند +

+

+ اطلاعات مربوط به استفاده از خدمات شهربین و اطلاعات دستگاهی که + نرم‌افزار شهربین بر روی آن نصب شده‌ است همزمان با نصب نرم‌افزار بر + روی دستگاه شما (بدون ایجاد حساب کاربری) جمع‌آوری می‌شوند. برخی از + این اطلاعات عبارتند از: +

+
+
+ + ); +} + +export default PnpUser; diff --git a/components/Settings/Profile.tsx b/components/Settings/profile/Profile.tsx similarity index 64% rename from components/Settings/Profile.tsx rename to components/Settings/profile/Profile.tsx index 004a41e..93787f5 100644 --- a/components/Settings/Profile.tsx +++ b/components/Settings/profile/Profile.tsx @@ -1,7 +1,7 @@ "use client"; import React, { useEffect, useState } from "react"; import { zodResolver } from "@hookform/resolvers/zod"; -import { useForm } from "react-hook-form"; +import { Controller, useForm } from "react-hook-form"; import * as z from "zod"; import { Button } from "@/components/ui/button"; import { @@ -27,8 +27,22 @@ import { SelectItem, SelectTrigger, SelectValue, -} from "../ui/select"; +} from "@/components/ui/select"; import { educations, genders } from "@/constants"; +import DatePicker, { DateObject } from "react-multi-date-picker"; +import gregorian from "react-date-object/calendars/gregorian"; +import gregorian_en from "react-date-object/locales/gregorian_en"; +import persian from "react-date-object/calendars/persian"; +import persian_fa from "react-date-object/locales/persian_fa"; +import dayjs from "dayjs"; +import utc from "dayjs/plugin/utc"; +import jalaliday from "jalaliday"; + +// import 'react-modern-calendar-datepicker/lib/DatePicker.css'; +// import DatePicker from 'react-modern-calendar-datepicker'; + +dayjs.extend(jalaliday); +dayjs.extend(utc); const FormSchema = z.object({ firstName: z.string().min(1, { @@ -60,8 +74,8 @@ const FormSchema = z.object({ if (Number.isNaN(parsedNumber)) { throw new Error("شماره موبایل معتبر نمی باشد."); } else if ( - Number(parsedNumber) > 1000000000 && - Number(parsedNumber) < 9999999999 + Number(parsedNumber) > 10000000000 && + Number(parsedNumber) < 99999999999 ) { throw new Error("شماره موبایل معتبر نمی باشد."); } @@ -73,10 +87,20 @@ const FormSchema = z.object({ education: z.string({ required_error: "لطفا تحصیلات خود را انتخاب نمایید.", }), + birthday: z.nullable( + z.any({ + required_error: "لطفا تاریخ تولد خود را وارد کنید", + // invalid_type_error: "Age must be a number", + }) + ), }); export default function Profile() { const router = useRouter(); + + const [value, setValue] = useState(new Date()); + const [date, setDate] = useState(); + // const [selectedDay, setSelectedDay] = useState(null); // const [profileData, setProfileData] = useState(null); const { @@ -96,66 +120,95 @@ export default function Profile() { refetch(); // toast("پروفایل شما با موفقیت ویرایش شد.", { toast(res.message, { - className: "!bg-green-500 !text-white", + className: "!bg-green !text-black flex justify-end", }); - router.push("/"); + // router.push("/"); }, onError: (err: any | string) => { toast(<>{err.response.data.detail}, { - className: "!bg-red !text-white", + className: "!bg-red-500 !text-white", }); }, }); const form = useForm>({ resolver: zodResolver(FormSchema), + defaultValues:{ + gender:'', + education:'' + } }); useEffect(() => { if (profileData) { // setProfileData(data?.data); + console.log(profileData); + form.setValue("firstName", profileData.data?.firstName); form.setValue("lastName", profileData.data?.lastName); form.setValue("nationalId", profileData.data?.nationalId); form.setValue("phoneNumber", profileData.data?.phoneNumber); - form.setValue("gender", profileData.data?.gender); + form.setValue("gender", String(profileData.data?.gender)); form.setValue("education", profileData.data?.education); + + console.log(String(profileData.data?.gender)); + + const birthDate = new DateObject(profileData.data?.birthDate).convert( + gregorian, + gregorian_en + ); + form.setValue( + "birthday", + birthDate.format("YYYY-MM-DDTHH:mm:ss.SSSSSSS") + ); + const date2 = new DateObject(profileData.data?.birthDate).convert( + persian, + persian_fa + ); + setDate(date2); } - }, [profileData]); + }, [profileData, setValue]); function onSubmit(data: z.infer) { const strNationalId = String(data.nationalId); const strPhoneNumber = String(data.phoneNumber); + const NumGender = Number(data.gender); + const NumEducation = Number(data.education); const payload = { ...data, nationalId: strNationalId, phoneNumber: strPhoneNumber, + gender: NumGender, + education: NumEducation, }; - // editProfileMutation.mutate(payload); + console.log(payload); + + editProfileMutation.mutate(payload); } return ( -
-
+
+

پروفایل کاربری

{profileData && (
-
+
( - - + + نام @@ -168,12 +221,13 @@ export default function Profile() { control={form.control} name="lastName" render={({ field }) => ( - - + + نام خانوادگی @@ -183,17 +237,18 @@ export default function Profile() { )} /> - ( - - + + جنسیت - + {" "} @@ -269,12 +326,13 @@ export default function Profile() { control={form.control} name="nationalId" render={({ field }) => ( - - + + کد ملی ( - - + + شماره موبایل )} /> + ( + + + تاریخ تولد + + + {/* */} + {/* */} + + { + const date = new DateObject(ab).convert( + gregorian, + gregorian_en + ); + form.setValue( + "birthday", + date.format("YYYY-MM-DDTHH:mm:ss.SSSSSSS") + ); + console.log( + date.format("YYYY-MM-DDTHH:mm:ss.SSSSSSS") + ); + }} + placeholder="تاریخ تولد خود را انتخاب نمایید" + onOpenPickNewDate={false} + /> + + + + )} + />
-
+
*/} + {/* */} + {/* */} +
+
+
+ +
+ + )} + + +
+ ); +} + +export default OperatorProfile; diff --git a/components/Settings/CardSetting.tsx b/components/Settings/setting/CardSetting.tsx similarity index 100% rename from components/Settings/CardSetting.tsx rename to components/Settings/setting/CardSetting.tsx diff --git a/components/Settings/Settings.tsx b/components/Settings/setting/Settings.tsx similarity index 100% rename from components/Settings/Settings.tsx rename to components/Settings/setting/Settings.tsx diff --git a/components/Settings/SocialMedia.tsx b/components/Settings/setting/SocialMedia.tsx similarity index 66% rename from components/Settings/SocialMedia.tsx rename to components/Settings/setting/SocialMedia.tsx index bbfcfc7..0b05cd7 100644 --- a/components/Settings/SocialMedia.tsx +++ b/components/Settings/setting/SocialMedia.tsx @@ -11,33 +11,32 @@ const SocialMedia = () => { - + - + - + - +
); diff --git a/components/ui/input.tsx b/components/ui/input.tsx index 60b97d9..9dedf38 100644 --- a/components/ui/input.tsx +++ b/components/ui/input.tsx @@ -16,7 +16,7 @@ const Input = React.forwardRef( 3xl:h-9 h-10 transition-all hover:cursor-pointer focus:cursor-auto focus:outline-4 focus:outline-slate-300 - bg-white focus:bg-white hover:bg-white text-center + bg-white focus:bg-white hover:bg-white text-right `, className diff --git a/constants/index.tsx b/constants/index.tsx index cac5160..571fb56 100644 --- a/constants/index.tsx +++ b/constants/index.tsx @@ -44,37 +44,37 @@ export const menuItems = [ export const educations = [ { - id: 0, + id: "0", title: "تعریف نشده", value: 0, }, { - id: 1, + id: "1", title: "ابتدایی", value: 1, }, { - id: 2, + id: "2", title: "دیپلم", value: 2, }, { - id: 3, + id: "3", title: "فوق دیپلم", value: 3, }, { - id: 4, + id: "4", title: "لیسانس", value: 4, }, { - id: 5, + id: "5", title: "فوق لیسانس", value: 5, }, { - id: 6, + id: "6", title: "دکترا", value: 6, }, diff --git a/package-lock.json b/package-lock.json index b3a4bed..ae5f455 100644 --- a/package-lock.json +++ b/package-lock.json @@ -39,6 +39,7 @@ "react-icons": "^5.1.0", "react-loader-spinner": "^6.1.6", "react-mapbox-gl": "^5.1.1", + "react-multi-date-picker": "^4.5.2", "react-otp-input": "^3.1.1", "sonner": "^1.4.41", "tailwind-merge": "^2.2.2", @@ -5226,6 +5227,11 @@ "react-dom": ">= 15" } }, + "node_modules/react-date-object": { + "version": "2.1.9", + "resolved": "https://registry.npmjs.org/react-date-object/-/react-date-object-2.1.9.tgz", + "integrity": "sha512-BHxD/quWOTo9fLKV/cfL/M31ePoj4a1JaJ/CnOf8Ndg3mrkh4x9wEMMkCfTrzduxDOgU8ZgR8uarhqI5G71sTg==" + }, "node_modules/react-dom": { "version": "18.2.0", "resolved": "https://registry.npmjs.org/react-dom/-/react-dom-18.2.0.tgz", @@ -5238,6 +5244,15 @@ "react": "^18.2.0" } }, + "node_modules/react-element-popper": { + "version": "2.1.6", + "resolved": "https://registry.npmjs.org/react-element-popper/-/react-element-popper-2.1.6.tgz", + "integrity": "sha512-8va7mUmrKIkUnaM2t5Dyctd8cjgVgVcrv5vVD0FRay0sN6EPBCKa0bDi1/KmVDAjfgSIn7zQnjtc4VojcGrkgQ==", + "peerDependencies": { + "react": ">=16.8.0", + "react-dom": ">=16.8.0" + } + }, "node_modules/react-hook-form": { "version": "7.51.2", "resolved": "https://registry.npmjs.org/react-hook-form/-/react-hook-form-7.51.2.tgz", @@ -5305,6 +5320,19 @@ "react-dom": "^16.11.0" } }, + "node_modules/react-multi-date-picker": { + "version": "4.5.2", + "resolved": "https://registry.npmjs.org/react-multi-date-picker/-/react-multi-date-picker-4.5.2.tgz", + "integrity": "sha512-FgWjZB3Z6IA6XpcWiLPk85PwcRUhOiYhKK42o5k672gD/n2I6rzPfQ8bUrldOIiF/Z7FfOCdH7a6FeubzqteLg==", + "dependencies": { + "react-date-object": "^2.1.8", + "react-element-popper": "^2.1.6" + }, + "peerDependencies": { + "react": ">=16.8.0", + "react-dom": ">=16.8.0" + } + }, "node_modules/react-otp-input": { "version": "3.1.1", "resolved": "https://registry.npmjs.org/react-otp-input/-/react-otp-input-3.1.1.tgz", diff --git a/package.json b/package.json index 69dea1f..3043a23 100644 --- a/package.json +++ b/package.json @@ -40,6 +40,7 @@ "react-icons": "^5.1.0", "react-loader-spinner": "^6.1.6", "react-mapbox-gl": "^5.1.1", + "react-multi-date-picker": "^4.5.2", "react-otp-input": "^3.1.1", "sonner": "^1.4.41", "tailwind-merge": "^2.2.2",