base profile
This commit is contained in:
@@ -8,8 +8,8 @@ import {
|
|||||||
BreadcrumbPage,
|
BreadcrumbPage,
|
||||||
BreadcrumbSeparator,
|
BreadcrumbSeparator,
|
||||||
} from '@/components/ui/breadcrumb'
|
} from '@/components/ui/breadcrumb'
|
||||||
import Filters from './components/Filters'
|
import Filters from '../components/Filters'
|
||||||
import Sorts from './components/Sorts'
|
import Sorts from '../components/Sorts'
|
||||||
import GridWrapper from '@/components/GridWrapper'
|
import GridWrapper from '@/components/GridWrapper'
|
||||||
import ProductCard from '@/components/ProductCard'
|
import ProductCard from '@/components/ProductCard'
|
||||||
|
|
||||||
@@ -0,0 +1,178 @@
|
|||||||
|
'use client'
|
||||||
|
import React, { useState } from 'react'
|
||||||
|
import { Button } from '@/components/ui/button'
|
||||||
|
import Input from '@/components/Input'
|
||||||
|
import { Edit2 } from 'lucide-react'
|
||||||
|
import withLayout from '@/hoc/withLayout'
|
||||||
|
import { Heart, ShoppingCart } from 'iconsax-react'
|
||||||
|
|
||||||
|
const ProfilePage = () => {
|
||||||
|
const [userInfo, setUserInfo] = useState({
|
||||||
|
name: 'حسین دهقانی',
|
||||||
|
email: 'sondos@gmail.com',
|
||||||
|
phone: '09010901789',
|
||||||
|
nationalCode: '052093452',
|
||||||
|
birthDate: '1365/5/8',
|
||||||
|
postalCode: '1235478951',
|
||||||
|
province: 'مرکزی',
|
||||||
|
city: 'اراک',
|
||||||
|
address: 'خیابان دانشگاه رودوی بیمارستان خوانساری ساختمان مهر طبقه سوم واحد2',
|
||||||
|
district: '58'
|
||||||
|
})
|
||||||
|
|
||||||
|
const [isEditing, setIsEditing] = useState(false)
|
||||||
|
|
||||||
|
const handleInputChange = (field: string, value: string) => {
|
||||||
|
setUserInfo(prev => ({
|
||||||
|
...prev,
|
||||||
|
[field]: value
|
||||||
|
}))
|
||||||
|
}
|
||||||
|
|
||||||
|
const handleSubmit = () => {
|
||||||
|
// Handle form submission
|
||||||
|
setIsEditing(false)
|
||||||
|
console.log('Form submitted:', userInfo)
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="p-6">
|
||||||
|
<div>
|
||||||
|
<div className="flex gap-6">
|
||||||
|
{/* Left Content - Form */}
|
||||||
|
<div className="flex-1 ">
|
||||||
|
<div className="bg-[#FAFAFA] rounded-lg p-6">
|
||||||
|
<div className="flex items-center justify-between mb-6">
|
||||||
|
<h1 className="text-lg font-bold text-gray-900">اطلاعات کاربری</h1>
|
||||||
|
<Button
|
||||||
|
onClick={() => setIsEditing(!isEditing)}
|
||||||
|
variant="outline"
|
||||||
|
className="flex items-center gap-2"
|
||||||
|
>
|
||||||
|
<Edit2 size={16} />
|
||||||
|
ویرایش
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="grid grid-cols-1 md:grid-cols-2 gap-4">
|
||||||
|
<Input
|
||||||
|
label="نام و نام خانوادگی"
|
||||||
|
value={userInfo.name}
|
||||||
|
onChange={(e) => handleInputChange('name', e.target.value)}
|
||||||
|
readOnly={!isEditing}
|
||||||
|
/>
|
||||||
|
|
||||||
|
<Input
|
||||||
|
label="کد ملی"
|
||||||
|
value={userInfo.nationalCode}
|
||||||
|
onChange={(e) => handleInputChange('nationalCode', e.target.value)}
|
||||||
|
readOnly={!isEditing}
|
||||||
|
/>
|
||||||
|
|
||||||
|
<Input
|
||||||
|
label="ایمیل"
|
||||||
|
value={userInfo.email}
|
||||||
|
onChange={(e) => handleInputChange('email', e.target.value)}
|
||||||
|
readOnly={!isEditing}
|
||||||
|
type="email"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<Input
|
||||||
|
label="شماره تماس"
|
||||||
|
value={userInfo.phone}
|
||||||
|
onChange={(e) => handleInputChange('phone', e.target.value)}
|
||||||
|
readOnly={!isEditing}
|
||||||
|
/>
|
||||||
|
|
||||||
|
<Input
|
||||||
|
label="تاریخ تولد"
|
||||||
|
value={userInfo.birthDate}
|
||||||
|
onChange={(e) => handleInputChange('birthDate', e.target.value)}
|
||||||
|
readOnly={!isEditing}
|
||||||
|
/>
|
||||||
|
|
||||||
|
<Input
|
||||||
|
label="استان"
|
||||||
|
value={userInfo.province}
|
||||||
|
onChange={(e) => handleInputChange('province', e.target.value)}
|
||||||
|
readOnly={!isEditing}
|
||||||
|
/>
|
||||||
|
|
||||||
|
<Input
|
||||||
|
label="شهر"
|
||||||
|
value={userInfo.city}
|
||||||
|
onChange={(e) => handleInputChange('city', e.target.value)}
|
||||||
|
readOnly={!isEditing}
|
||||||
|
/>
|
||||||
|
|
||||||
|
<Input
|
||||||
|
label="کد پستی"
|
||||||
|
value={userInfo.postalCode}
|
||||||
|
onChange={(e) => handleInputChange('postalCode', e.target.value)}
|
||||||
|
readOnly={!isEditing}
|
||||||
|
/>
|
||||||
|
|
||||||
|
<Input
|
||||||
|
label="پلاک"
|
||||||
|
value={userInfo.district}
|
||||||
|
onChange={(e) => handleInputChange('district', e.target.value)}
|
||||||
|
readOnly={!isEditing}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="mt-4">
|
||||||
|
<Input
|
||||||
|
label="آدرس"
|
||||||
|
value={userInfo.address}
|
||||||
|
onChange={(e) => handleInputChange('address', e.target.value)}
|
||||||
|
readOnly={!isEditing}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{isEditing && (
|
||||||
|
<div className="mt-6 flex gap-3">
|
||||||
|
<Button
|
||||||
|
onClick={handleSubmit}
|
||||||
|
className="px-8 bg-blue-600 hover:bg-blue-700"
|
||||||
|
>
|
||||||
|
ذخیره تغییرات
|
||||||
|
</Button>
|
||||||
|
<Button
|
||||||
|
onClick={() => setIsEditing(false)}
|
||||||
|
variant="outline"
|
||||||
|
>
|
||||||
|
انصراف
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className='flex flex-col gap-6'>
|
||||||
|
<div className='size-[240px] bg-[#FAFAFA] rounded-[10px] flex flex-col gap-6 justify-center items-center h-full'>
|
||||||
|
<div className='size-20 bg-[#F2F2F2] rounded-full flex justify-center items-center'>
|
||||||
|
<ShoppingCart size={40} color='#000' />
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
سفارشات
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div className='size-[240px] bg-[#FAFAFA] rounded-[10px] flex flex-col gap-6 justify-center items-center h-full'>
|
||||||
|
<div className='size-20 bg-[#F2F2F2] rounded-full flex justify-center items-center'>
|
||||||
|
<Heart size={40} color='#000' />
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
علاقه مندی ها
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className='w-[300px] min-h-full bg-red-50 rounded-[10px]'>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
export default withLayout(ProfilePage)
|
||||||
+2
-2
@@ -1,6 +1,6 @@
|
|||||||
export const TOKEN_NAME = "sh_token";
|
export const TOKEN_NAME = "sh_token";
|
||||||
export const REFRESH_TOKEN_NAME = "sh_refresh_token";
|
export const REFRESH_TOKEN_NAME = "sh_refresh_token";
|
||||||
// export const BASE_URL = "https://api.shinan.ir";
|
export const BASE_URL = "https://api.shinan.ir";
|
||||||
export const BASE_URL = "https://api-sondos.run.danakcorp.com";
|
// export const BASE_URL = "https://api-sondos.run.danakcorp.com";
|
||||||
|
|
||||||
export const PRIMARY_COLOR = "#015699";
|
export const PRIMARY_COLOR = "#015699";
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
import { HambergerMenu, ArrowLeft2 } from 'iconsax-react'
|
import { HambergerMenu, ArrowLeft2 } from 'iconsax-react'
|
||||||
import { FC, useState, useRef, useEffect } from 'react'
|
import { FC, useState, useRef, useEffect } from 'react'
|
||||||
import Image from 'next/image'
|
import Image from 'next/image'
|
||||||
|
import { useRouter } from 'next/navigation'
|
||||||
import { useGetCategories } from '../hooks/useShareData'
|
import { useGetCategories } from '../hooks/useShareData'
|
||||||
import { Category } from '../types/SharedTypes'
|
import { Category } from '../types/SharedTypes'
|
||||||
|
|
||||||
@@ -10,6 +11,7 @@ const Menu: FC = () => {
|
|||||||
const [hoveredPath, setHoveredPath] = useState<Category[]>([])
|
const [hoveredPath, setHoveredPath] = useState<Category[]>([])
|
||||||
const { data, isLoading } = useGetCategories()
|
const { data, isLoading } = useGetCategories()
|
||||||
const menuRef = useRef<HTMLDivElement>(null)
|
const menuRef = useRef<HTMLDivElement>(null)
|
||||||
|
const router = useRouter()
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const handleClickOutside = (event: MouseEvent) => {
|
const handleClickOutside = (event: MouseEvent) => {
|
||||||
@@ -30,6 +32,12 @@ const Menu: FC = () => {
|
|||||||
setHoveredPath(newPath)
|
setHoveredPath(newPath)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const handleCategoryClick = (category: Category) => {
|
||||||
|
router.push(`/products/${category.title_en}`)
|
||||||
|
setIsOpen(false)
|
||||||
|
setHoveredPath([])
|
||||||
|
}
|
||||||
|
|
||||||
const renderCategoryLevel = (categories: Category[], level: number) => {
|
const renderCategoryLevel = (categories: Category[], level: number) => {
|
||||||
return (
|
return (
|
||||||
<div className='w-64 border-l border-gray-200 last:border-l-0 flex flex-col min-h-0'>
|
<div className='w-64 border-l border-gray-200 last:border-l-0 flex flex-col min-h-0'>
|
||||||
@@ -40,6 +48,7 @@ const Menu: FC = () => {
|
|||||||
className={`p-3 rounded-lg cursor-pointer transition-colors hover:bg-gray-50 ${hoveredPath[level]?._id === category._id ? 'bg-gray-50' : ''
|
className={`p-3 rounded-lg cursor-pointer transition-colors hover:bg-gray-50 ${hoveredPath[level]?._id === category._id ? 'bg-gray-50' : ''
|
||||||
}`}
|
}`}
|
||||||
onMouseEnter={() => handleCategoryHover(category, level)}
|
onMouseEnter={() => handleCategoryHover(category, level)}
|
||||||
|
onClick={() => handleCategoryClick(category)}
|
||||||
>
|
>
|
||||||
<div className='flex items-center gap-3'>
|
<div className='flex items-center gap-3'>
|
||||||
{category.icon && (
|
{category.icon && (
|
||||||
|
|||||||
Reference in New Issue
Block a user