update src/views/Address/index.js, src/views/Dashboard/layouts/Main/Addresses/index.js and src/views/Dashboard/layouts/Main/index.js

master
Reza_ashrafi 2 years ago
parent c0cd500923
commit ea659e0ac0
  1. 32
      src/views/Address/index.js
  2. 12
      src/views/Dashboard/layouts/Main/Addresses/index.js
  3. 2
      src/views/Dashboard/layouts/Main/index.js

@ -44,12 +44,15 @@ export const Address = ({
getAddress,
addressInfo,
updateAddress,
isDashboard,
}) => {
const [addressFields, setAddressFields] = useState({});
const [mapAddress, setMapAddress] = useState(null);
const navigation = useNavigate();
useEffect(() => {
setHeaderOptions(headerOptions);
if (!isDashboard) {
setHeaderOptions(headerOptions);
}
if (province.length <= 1) {
getProvince();
}
@ -464,11 +467,7 @@ export const Address = ({
? profileFields.cellphone || user.cellphone
: addressFields?.cellphone
}
onChange={(name, value) =>
profilePage
? setProfileFields({ ...profileFields, cellphone: value })
: onChange(name, value)
}
onChange={(name, value) => onChange(name, value)}
align="text-right"
direction="ltr"
maxLength={11}
@ -496,25 +495,6 @@ export const Address = ({
</>
) : null}
{profilePage && (
<Input
width={isMobile ? "100%" : "50%"}
label={window.t("کد ملی")}
regex={(val) => onInput.phonenumber(val)}
name="nationalId"
onChange={(name, value) =>
setProfileFields({ ...profileFields, nationalId: value })
}
value={profileFields.nationalId || user.nationalId}
align="text-right"
direction="ltr"
/>
)}
{!isMobile && <></>}
{!isMobile && <></>}
<Header
label={window.t("شماره تماس")}
text={window.t(
@ -653,7 +633,7 @@ const mapStateToProps = (state) => ({
loading: state.userAddress.loading,
user: state.user.status,
cityLoading: state.publicApi.loading,
isMobile: state.publicApi.isMobile,
isMobile: state.config.device === "mobile",
isDark: state.publicApi.isDark,
profileFields: state.user.profileFields,
addressInfo: state.userAddress.info,

@ -1,11 +1,11 @@
import React, { useEffect } from "react";
import { connect } from "react-redux";
import {
userAddress,
userFactor,
dialog,
menu,
dashboard,
} from "../../../../../redux/actions";
//components
@ -33,7 +33,8 @@ const ProfileAddress = ({
setMenu,
setDialog,
deleteAddress,
isDashboard
isDashboard,
setDashboardPage,
}) => {
const navigation = useNavigate();
@ -59,7 +60,9 @@ const ProfileAddress = ({
isDark ? "text-white" : "text-gray70"
} items-center w-full`}
onClick={() =>
navigation("/createAddress", { state: { panel: true } })
isDashboard
? setDashboardPage("addressForm")
: navigation("/createAddress", { state: { panel: true } })
}
style={{
border: `1px solid ${isDark ? "#DBDBDB22" : "#DBDBDB"}`,
@ -223,7 +226,7 @@ const mapStateToProps = (state) => ({
userId: state.user.status?.id,
userAddressId: state.userFactor.info?.userAddressId,
addresses: state.userAddress.list,
isMobile: state.config.device === 'mobile',
isMobile: state.config.device === "mobile",
isDark: state.publicApi.isDark,
loading: state.userFactor.loading,
});
@ -235,6 +238,7 @@ const mapDispatchToProps = {
deleteAddress: userAddress.del,
setMenu: menu.set,
setDialog: dialog.set,
setDashboardPage: dashboard.setPage,
};
export default connect(mapStateToProps, mapDispatchToProps)(ProfileAddress);

@ -25,7 +25,7 @@ const views = {
favorites: <Favorites />,
addresses: <Addresses isDashboard={true} />,
profile: <Profile />,
addressForm: <Address />,
addressForm: <Address isDashboard={true} />,
};
export const Main = ({ page }) => {

Loading…
Cancel
Save