|
|
@ -11,6 +11,8 @@ import Loading from "../../components/Loading"; |
|
|
|
|
|
|
|
|
|
|
|
//assets
|
|
|
|
//assets
|
|
|
|
import dropdownIcon from "../../assets/icons/dropdown-blue.svg"; |
|
|
|
import dropdownIcon from "../../assets/icons/dropdown-blue.svg"; |
|
|
|
|
|
|
|
import arrowBlueIcon from "../../assets/icons/arrow-right-blue.svg"; |
|
|
|
|
|
|
|
import arrowWhiteIcon from "../../assets/icons/arrow-left-white.svg"; |
|
|
|
|
|
|
|
|
|
|
|
export const Address = ({ |
|
|
|
export const Address = ({ |
|
|
|
city, |
|
|
|
city, |
|
|
@ -23,6 +25,8 @@ export const Address = ({ |
|
|
|
loading, |
|
|
|
loading, |
|
|
|
setPhase, |
|
|
|
setPhase, |
|
|
|
cityLoading, |
|
|
|
cityLoading, |
|
|
|
|
|
|
|
isMobile, |
|
|
|
|
|
|
|
isDark, |
|
|
|
}) => { |
|
|
|
}) => { |
|
|
|
const [addressFields, setAddressFields] = useState({}); |
|
|
|
const [addressFields, setAddressFields] = useState({}); |
|
|
|
const [mapAddress, setMapAddress] = useState(null); |
|
|
|
const [mapAddress, setMapAddress] = useState(null); |
|
|
@ -73,8 +77,8 @@ export const Address = ({ |
|
|
|
type: "alert", |
|
|
|
type: "alert", |
|
|
|
setOpen: (val) => setDialog({ ...dialog, open: val }), |
|
|
|
setOpen: (val) => setDialog({ ...dialog, open: val }), |
|
|
|
accept: () => {}, |
|
|
|
accept: () => {}, |
|
|
|
bg: "bg-black bg-opacity-60", |
|
|
|
bg: "bg-white dark:bg-black dark:bg-opacity-30", |
|
|
|
color: "text-white", |
|
|
|
color: "text-gray70 dark:text-white", |
|
|
|
open: true, |
|
|
|
open: true, |
|
|
|
}); |
|
|
|
}); |
|
|
|
return; |
|
|
|
return; |
|
|
@ -85,8 +89,8 @@ export const Address = ({ |
|
|
|
type: "alert", |
|
|
|
type: "alert", |
|
|
|
setOpen: (val) => setDialog({ ...dialog, open: val }), |
|
|
|
setOpen: (val) => setDialog({ ...dialog, open: val }), |
|
|
|
accept: () => {}, |
|
|
|
accept: () => {}, |
|
|
|
bg: "bg-black bg-opacity-60", |
|
|
|
bg: "bg-white dark:bg-black dark:bg-opacity-30", |
|
|
|
color: "text-white", |
|
|
|
color: "text-gray70 dark:text-white", |
|
|
|
open: true, |
|
|
|
open: true, |
|
|
|
}); |
|
|
|
}); |
|
|
|
return; |
|
|
|
return; |
|
|
@ -97,8 +101,8 @@ export const Address = ({ |
|
|
|
type: "alert", |
|
|
|
type: "alert", |
|
|
|
setOpen: (val) => setDialog({ ...dialog, open: val }), |
|
|
|
setOpen: (val) => setDialog({ ...dialog, open: val }), |
|
|
|
accept: () => {}, |
|
|
|
accept: () => {}, |
|
|
|
bg: "bg-black bg-opacity-60", |
|
|
|
bg: "bg-white dark:bg-black dark:bg-opacity-30", |
|
|
|
color: "text-white", |
|
|
|
color: "text-gray70 dark:text-white", |
|
|
|
open: true, |
|
|
|
open: true, |
|
|
|
}); |
|
|
|
}); |
|
|
|
return; |
|
|
|
return; |
|
|
@ -109,8 +113,8 @@ export const Address = ({ |
|
|
|
type: "alert", |
|
|
|
type: "alert", |
|
|
|
setOpen: (val) => setDialog({ ...dialog, open: val }), |
|
|
|
setOpen: (val) => setDialog({ ...dialog, open: val }), |
|
|
|
accept: () => {}, |
|
|
|
accept: () => {}, |
|
|
|
bg: "bg-black bg-opacity-60", |
|
|
|
bg: "bg-white dark:bg-black dark:bg-opacity-30", |
|
|
|
color: "text-white", |
|
|
|
color: "text-gray70 dark:text-white", |
|
|
|
open: true, |
|
|
|
open: true, |
|
|
|
}); |
|
|
|
}); |
|
|
|
return; |
|
|
|
return; |
|
|
@ -121,8 +125,8 @@ export const Address = ({ |
|
|
|
type: "alert", |
|
|
|
type: "alert", |
|
|
|
setOpen: (val) => setDialog({ ...dialog, open: val }), |
|
|
|
setOpen: (val) => setDialog({ ...dialog, open: val }), |
|
|
|
accept: () => {}, |
|
|
|
accept: () => {}, |
|
|
|
bg: "bg-black bg-opacity-60", |
|
|
|
bg: "bg-white dark:bg-black dark:bg-opacity-30", |
|
|
|
color: "text-white", |
|
|
|
color: "text-gray70 dark:text-white", |
|
|
|
open: true, |
|
|
|
open: true, |
|
|
|
}); |
|
|
|
}); |
|
|
|
return; |
|
|
|
return; |
|
|
@ -133,8 +137,8 @@ export const Address = ({ |
|
|
|
type: "alert", |
|
|
|
type: "alert", |
|
|
|
setOpen: (val) => setDialog({ ...dialog, open: val }), |
|
|
|
setOpen: (val) => setDialog({ ...dialog, open: val }), |
|
|
|
accept: () => {}, |
|
|
|
accept: () => {}, |
|
|
|
bg: "bg-black bg-opacity-60", |
|
|
|
bg: "bg-white dark:bg-black dark:bg-opacity-30", |
|
|
|
color: "text-white", |
|
|
|
color: "text-gray70 dark:text-white", |
|
|
|
open: true, |
|
|
|
open: true, |
|
|
|
}); |
|
|
|
}); |
|
|
|
return; |
|
|
|
return; |
|
|
@ -145,8 +149,8 @@ export const Address = ({ |
|
|
|
type: "alert", |
|
|
|
type: "alert", |
|
|
|
setOpen: (val) => setDialog({ ...dialog, open: val }), |
|
|
|
setOpen: (val) => setDialog({ ...dialog, open: val }), |
|
|
|
accept: () => {}, |
|
|
|
accept: () => {}, |
|
|
|
bg: "bg-black bg-opacity-60", |
|
|
|
bg: "bg-white dark:bg-black dark:bg-opacity-30", |
|
|
|
color: "text-white", |
|
|
|
color: "text-gray70 dark:text-white", |
|
|
|
open: true, |
|
|
|
open: true, |
|
|
|
}); |
|
|
|
}); |
|
|
|
return; |
|
|
|
return; |
|
|
@ -157,8 +161,8 @@ export const Address = ({ |
|
|
|
type: "alert", |
|
|
|
type: "alert", |
|
|
|
setOpen: (val) => setDialog({ ...dialog, open: val }), |
|
|
|
setOpen: (val) => setDialog({ ...dialog, open: val }), |
|
|
|
accept: () => {}, |
|
|
|
accept: () => {}, |
|
|
|
bg: "bg-black bg-opacity-60", |
|
|
|
bg: "bg-white dark:bg-black dark:bg-opacity-30", |
|
|
|
color: "text-white", |
|
|
|
color: "text-gray70 dark:text-white", |
|
|
|
open: true, |
|
|
|
open: true, |
|
|
|
}); |
|
|
|
}); |
|
|
|
return; |
|
|
|
return; |
|
|
@ -183,18 +187,22 @@ export const Address = ({ |
|
|
|
|
|
|
|
|
|
|
|
const Header = ({ title, text }) => { |
|
|
|
const Header = ({ title, text }) => { |
|
|
|
return ( |
|
|
|
return ( |
|
|
|
<div className="flex flex-row items-center gap-2 mb-4"> |
|
|
|
<div className="flex flex-col lg:flex-row lg:items-center gap-2 lg:mb-4 mt-2 lg:mt-0"> |
|
|
|
<strong className="text-blue5F text-base">{title}</strong> |
|
|
|
<strong className="text-green4F text-base dark:text-white"> |
|
|
|
<p className="mt-1 inline flex-1 text-sm text-gray70">{text}</p> |
|
|
|
{title} |
|
|
|
|
|
|
|
</strong> |
|
|
|
|
|
|
|
<p className="mt-1 inline flex-1 text-sm text-gray70 dark:text-white"> |
|
|
|
|
|
|
|
{text} |
|
|
|
|
|
|
|
</p> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
); |
|
|
|
); |
|
|
|
}; |
|
|
|
}; |
|
|
|
return ( |
|
|
|
return ( |
|
|
|
<div |
|
|
|
<div |
|
|
|
className="flex flex-row-reverse flex-1 pb-20 gap-5 divide-x divide-solid divide-gray-200" |
|
|
|
className="flex flex-col lg:flex-row-reverse flex-1 pt-10 lg:pt-0 pb-20 gap-5 lg:divide-x lg:divide-solid lg:divide-gray-200" |
|
|
|
// style={{ minHeight: "calc(100vh - 500px)" }}
|
|
|
|
// style={{ minHeight: "calc(100vh - 500px)" }}
|
|
|
|
> |
|
|
|
> |
|
|
|
<div className="flex flex-col w-1/2 px-4"> |
|
|
|
<div className="flex flex-col-reverse w-full lg:w-1/2"> |
|
|
|
<Input |
|
|
|
<Input |
|
|
|
width="100%" |
|
|
|
width="100%" |
|
|
|
label={"ادرس انتخاب شده در نقشه"} |
|
|
|
label={"ادرس انتخاب شده در نقشه"} |
|
|
@ -207,11 +215,11 @@ export const Address = ({ |
|
|
|
/> |
|
|
|
/> |
|
|
|
<div |
|
|
|
<div |
|
|
|
className="w-full overflow-hidden rounded-md mt-6" |
|
|
|
className="w-full overflow-hidden rounded-md mt-6" |
|
|
|
style={{ height: "calc(100vh / 2)" }} |
|
|
|
style={{ height: isMobile ? "calc(100vh / 4)" : "calc(100vh / 2)" }} |
|
|
|
> |
|
|
|
> |
|
|
|
<ReverseMap setAddress={(val) => setMapAddress(val)} /> |
|
|
|
<ReverseMap setAddress={(val) => setMapAddress(val)} /> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
<div className="flex w-full items-end mt-8 flex-col"> |
|
|
|
<div className="hidden lg:flex w-full items-end mt-8 flex-col"> |
|
|
|
<div className="flex flex-col items-cente w-2/5"> |
|
|
|
<div className="flex flex-col items-cente w-2/5"> |
|
|
|
<Button |
|
|
|
<Button |
|
|
|
loading={loading} |
|
|
|
loading={loading} |
|
|
@ -236,14 +244,14 @@ export const Address = ({ |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
<div className="flex flex-col w-1/2 pl-4"> |
|
|
|
<div className="flex flex-col w-full lg:w-1/2 lg:pl-4"> |
|
|
|
<Header |
|
|
|
<Header |
|
|
|
title="اطلاعات هویتی" |
|
|
|
title="اطلاعات هویتی" |
|
|
|
text="( لطفا نام و نام خانوادگی خود را به طور کامل وارد نمایید )" |
|
|
|
text="( لطفا نام و نام خانوادگی خود را به طور کامل وارد نمایید )" |
|
|
|
/> |
|
|
|
/> |
|
|
|
<div className="flex flex-row items-center gap-5 w-full"> |
|
|
|
<div className="flex flex-col lg:flex-row items-center lg:gap-5 w-full"> |
|
|
|
<Input |
|
|
|
<Input |
|
|
|
width="50%" |
|
|
|
width={isMobile ? "100%" : "50%"} |
|
|
|
label={"نام"} |
|
|
|
label={"نام"} |
|
|
|
regex={(val) => val} |
|
|
|
regex={(val) => val} |
|
|
|
name="firstName" |
|
|
|
name="firstName" |
|
|
@ -253,7 +261,7 @@ export const Address = ({ |
|
|
|
direction="rtl" |
|
|
|
direction="rtl" |
|
|
|
/> |
|
|
|
/> |
|
|
|
<Input |
|
|
|
<Input |
|
|
|
width="50%" |
|
|
|
width={isMobile ? "100%" : "50%"} |
|
|
|
label={"نام خانوادگی"} |
|
|
|
label={"نام خانوادگی"} |
|
|
|
regex={(val) => val} |
|
|
|
regex={(val) => val} |
|
|
|
name="lastName" |
|
|
|
name="lastName" |
|
|
@ -263,16 +271,20 @@ export const Address = ({ |
|
|
|
direction="rtl" |
|
|
|
direction="rtl" |
|
|
|
/> |
|
|
|
/> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
<br /> |
|
|
|
{!isMobile && ( |
|
|
|
<br /> |
|
|
|
<> |
|
|
|
|
|
|
|
<br /> |
|
|
|
|
|
|
|
<br /> |
|
|
|
|
|
|
|
</> |
|
|
|
|
|
|
|
)} |
|
|
|
<Header |
|
|
|
<Header |
|
|
|
title="شماره تماس" |
|
|
|
title="شماره تماس" |
|
|
|
text="( شماره موبایل و شماره تلفن ثابت خود را
|
|
|
|
text="( شماره موبایل و شماره تلفن ثابت خود را
|
|
|
|
به همراه پیش شماره وارد کنید )" |
|
|
|
به همراه پیش شماره وارد کنید )" |
|
|
|
/> |
|
|
|
/> |
|
|
|
<div className="flex flex-row items-center gap-5 w-full"> |
|
|
|
<div className="flex flex-col lg:flex-row items-center lg:gap-5 w-full"> |
|
|
|
<Input |
|
|
|
<Input |
|
|
|
width="50%" |
|
|
|
width={isMobile ? "100%" : "50%"} |
|
|
|
label={"شماره موبایل"} |
|
|
|
label={"شماره موبایل"} |
|
|
|
regex={(val) => onInput.numberOnly(val)} |
|
|
|
regex={(val) => onInput.numberOnly(val)} |
|
|
|
name="cellphone" |
|
|
|
name="cellphone" |
|
|
@ -283,7 +295,7 @@ export const Address = ({ |
|
|
|
maxLength={11} |
|
|
|
maxLength={11} |
|
|
|
/> |
|
|
|
/> |
|
|
|
<Input |
|
|
|
<Input |
|
|
|
width="50%" |
|
|
|
width={isMobile ? "100%" : "50%"} |
|
|
|
label={"شماره تلفن"} |
|
|
|
label={"شماره تلفن"} |
|
|
|
regex={(val) => onInput.numberOnly(val)} |
|
|
|
regex={(val) => onInput.numberOnly(val)} |
|
|
|
name="phone" |
|
|
|
name="phone" |
|
|
@ -294,24 +306,38 @@ export const Address = ({ |
|
|
|
maxLength={11} |
|
|
|
maxLength={11} |
|
|
|
/> |
|
|
|
/> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
<br /> |
|
|
|
{!isMobile && ( |
|
|
|
<br /> |
|
|
|
<> |
|
|
|
|
|
|
|
<br /> |
|
|
|
|
|
|
|
<br /> |
|
|
|
|
|
|
|
</> |
|
|
|
|
|
|
|
)} |
|
|
|
<Header |
|
|
|
<Header |
|
|
|
title="آدرس" |
|
|
|
title="آدرس" |
|
|
|
text="( لطفا نام استان و شهرستان و آدرس |
|
|
|
text="( لطفا نام استان و شهرستان و آدرس |
|
|
|
خود را با دقت تکمیل نمایید )" |
|
|
|
خود را با دقت تکمیل نمایید )" |
|
|
|
/> |
|
|
|
/> |
|
|
|
<div className="flex flex-row items-center gap-5 w-full mt-3"> |
|
|
|
<div className="flex flex-col lg:flex-row items-center gap-3 lg:gap-5 w-full mt-3"> |
|
|
|
<Select |
|
|
|
<Select |
|
|
|
options={province} |
|
|
|
options={province} |
|
|
|
name="provinceId" |
|
|
|
name="provinceId" |
|
|
|
onChange={(name, value) => onChange(name, value)} |
|
|
|
onChange={(name, value) => onChange(name, value)} |
|
|
|
|
|
|
|
width={isMobile ? "w-full" : "w-1/2"} |
|
|
|
|
|
|
|
backgroundColor={ |
|
|
|
|
|
|
|
isDark ? "dark:bg-transparent dark:text-white" : "" |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
fill={isDark ? "fill-white" : "fill-gray-600"} |
|
|
|
/> |
|
|
|
/> |
|
|
|
{!cityLoading ? ( |
|
|
|
{!cityLoading ? ( |
|
|
|
<Select |
|
|
|
<Select |
|
|
|
options={city} |
|
|
|
options={city} |
|
|
|
name="cityId" |
|
|
|
name="cityId" |
|
|
|
onChange={(name, value) => onChange(name, value)} |
|
|
|
onChange={(name, value) => onChange(name, value)} |
|
|
|
|
|
|
|
width={isMobile ? "w-full" : "w-1/2"} |
|
|
|
|
|
|
|
backgroundColor={ |
|
|
|
|
|
|
|
isDark ? "dark:bg-transparent dark:text-white" : "" |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
fill={isDark ? "fill-white" : "fill-gray-600"} |
|
|
|
/> |
|
|
|
/> |
|
|
|
) : ( |
|
|
|
) : ( |
|
|
|
<div className="flex justify-between border-gray-300 border border-solid rounded-md w-1/2 py-3.5 px-2"> |
|
|
|
<div className="flex justify-between border-gray-300 border border-solid rounded-md w-1/2 py-3.5 px-2"> |
|
|
@ -328,7 +354,7 @@ export const Address = ({ |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
<br /> |
|
|
|
<br /> |
|
|
|
<Input |
|
|
|
<Input |
|
|
|
width="50%" |
|
|
|
width={isMobile ? "100%" : "50%"} |
|
|
|
label={"کد پستی"} |
|
|
|
label={"کد پستی"} |
|
|
|
regex={(val) => onInput.numberOnly(val)} |
|
|
|
regex={(val) => onInput.numberOnly(val)} |
|
|
|
name="postalCode" |
|
|
|
name="postalCode" |
|
|
@ -338,7 +364,47 @@ export const Address = ({ |
|
|
|
direction="ltr" |
|
|
|
direction="ltr" |
|
|
|
maxLength={10} |
|
|
|
maxLength={10} |
|
|
|
/> |
|
|
|
/> |
|
|
|
|
|
|
|
<div className="flex lg:hidden flex-col items-cente w-full mt-3"> |
|
|
|
|
|
|
|
<Button |
|
|
|
|
|
|
|
loading={loading} |
|
|
|
|
|
|
|
title="ثبت آدرس" |
|
|
|
|
|
|
|
backgroundColor="bg-blueC0" |
|
|
|
|
|
|
|
border={{ color: "#196EC055", width: "0px" }} |
|
|
|
|
|
|
|
width="100%" |
|
|
|
|
|
|
|
color="text-white" |
|
|
|
|
|
|
|
onClick={() => submit()} |
|
|
|
|
|
|
|
/> |
|
|
|
|
|
|
|
<button |
|
|
|
|
|
|
|
className="bg-transparent mt-4 text-base py-3 flex flex-row justify-center items-center border-2 border-solid border-blueC0 text-green7B dark:text-blueC0 rounded-full" |
|
|
|
|
|
|
|
onClick={() => setPhase("deliveryForm")} |
|
|
|
|
|
|
|
> |
|
|
|
|
|
|
|
بازگشت |
|
|
|
|
|
|
|
<img |
|
|
|
|
|
|
|
src={dropdownIcon} |
|
|
|
|
|
|
|
alt="" |
|
|
|
|
|
|
|
className="w-3.5 transform rotate-90" |
|
|
|
|
|
|
|
/> |
|
|
|
|
|
|
|
</button> |
|
|
|
|
|
|
|
</div> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
|
|
|
|
{isMobile && ( |
|
|
|
|
|
|
|
<div |
|
|
|
|
|
|
|
className="fixed top-0 left-0 flex justify-between items-center py-3 px-4 w-full" |
|
|
|
|
|
|
|
style={{ |
|
|
|
|
|
|
|
backgroundColor: isDark ? "#061B30" : "white", |
|
|
|
|
|
|
|
}} |
|
|
|
|
|
|
|
> |
|
|
|
|
|
|
|
<strong className="text-green4F text-lg font-semibold dark:text-white"> |
|
|
|
|
|
|
|
آدرس جدید |
|
|
|
|
|
|
|
</strong> |
|
|
|
|
|
|
|
<img |
|
|
|
|
|
|
|
src={isDark ? arrowWhiteIcon : arrowBlueIcon} |
|
|
|
|
|
|
|
alt="back" |
|
|
|
|
|
|
|
className={`w-6 transform ${isDark ? " rotate-0" : "rotate-180"}`} |
|
|
|
|
|
|
|
onClick={() => setPhase("deliveryForm")} |
|
|
|
|
|
|
|
/> |
|
|
|
|
|
|
|
</div> |
|
|
|
|
|
|
|
)} |
|
|
|
{dialog.open && <Dialog dialog={dialog} />} |
|
|
|
{dialog.open && <Dialog dialog={dialog} />} |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
); |
|
|
|
); |
|
|
@ -351,6 +417,8 @@ const mapStateToProps = (state) => ({ |
|
|
|
cities: state.publicApi.cities, |
|
|
|
cities: state.publicApi.cities, |
|
|
|
loading: state.userAddress.loading, |
|
|
|
loading: state.userAddress.loading, |
|
|
|
cityLoading: state.publicApi.loading, |
|
|
|
cityLoading: state.publicApi.loading, |
|
|
|
|
|
|
|
isMobile: state.publicApi.isMobile, |
|
|
|
|
|
|
|
isDark: state.publicApi.isDark, |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
const mapDispatchToProps = { |
|
|
|
const mapDispatchToProps = { |
|
|
|