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

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

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

Loading…
Cancel
Save