reza fixed profile

master
RezaAshrafi77 3 years ago
parent c30b10857e
commit 221101f2a5
  1. 2
      src/AppRouter.js
  2. 1
      src/Redux/actions/index.js
  3. 31
      src/Redux/actions/transport.js
  4. 5
      src/Redux/proxy.js
  5. 1
      src/Redux/reducers/book.js
  6. 1
      src/Redux/reducers/index.js
  7. 27
      src/Redux/reducers/transport.js
  8. 7
      src/Redux/reducers/user.js
  9. 4
      src/Redux/reducers/userProduct.js
  10. 2
      src/views/Auth/Profile/Input/index.js
  11. 7
      src/views/Auth/Profile/index.js
  12. 13
      src/views/Auth/Profile/index.scss
  13. 10
      src/views/Cart/DeliveryMethod/index.js
  14. 2
      src/views/Cart/DeliveryMethod/index.scss
  15. 4
      src/views/Cart/Discount/index.js
  16. 34
      src/views/Cart/Factor/index.js
  17. 44
      src/views/Cart/index.js

@ -39,7 +39,7 @@ class AppRouter extends Component {
let home = (
<Route exact path={"/"}>
{proxy.status() ? (
this.props.profile.status ? (
this.props.profile ? (
<Home />
) : (
<Auth page={"profile"} />

@ -7,3 +7,4 @@ export { default as user } from "./user.js";
export { default as qr } from "./qr.js";
export { default as book } from "./book.js";
export { default as userProduct } from "./userProduct.js";
export { default as transport } from "./transport.js";

@ -0,0 +1,31 @@
import proxy from "../proxy";
const transport = {
list:
(data = {}) =>
async (dispatch) =>
await proxy.get("transport/list", data, { dispatch }),
info:
(data = {}) =>
async (dispatch) =>
await proxy.get("transport/info", data, { dispatch }),
update:
(data = {}, data2 = {}) =>
async (dispatch) => {
await proxy.put("transport/update", data);
await proxy.get("transport/list", data2, { dispatch });
},
add:
(data = {}, data2 = {}) =>
async (dispatch) => {
await proxy.post("transport/add", data);
await proxy.get("transport/list", data2, { dispatch });
},
del:
(data = {}, data2 = {}) =>
async (dispatch) => {
await proxy.delete("transport/delete", data);
await proxy.get("transport/list", data2, { dispatch });
},
};
export default transport;

@ -68,7 +68,7 @@ class Proxy {
localStorage.setItem("access", login.accessToken);
delete login.refreshToken;
delete login.accessToken;
localStorage.setItem("userData", JSON.stringify(login));
localStorage.setItem("userData", JSON.stringify(login.profile));
dispatch(obj);
},
});
@ -93,8 +93,7 @@ class Proxy {
localStorage.removeItem("userData");
return false;
}
let fakeUserData = JSON.parse(userData);
return fakeUserData.profile;
return JSON.parse(userData);
};
}
const _proxy = new Proxy();

@ -44,7 +44,6 @@ export default function book(state = initialState, action) {
(item) => item.name.indexOf(subject.map((item) => item)) !== -1
)
: byLevelFilter;
console.log(bySubjectFilter);
const bySearchFilter = search
? bySubjectFilter.filter((item) => item.name.indexOf(search) !== -1)
: bySubjectFilter;

@ -7,3 +7,4 @@ export { default as user } from "./user.js";
export { default as qr } from "./qr.js";
export { default as book } from "./book.js";
export { default as userProduct } from "./userProduct.js";
export { default as transport } from "./transport.js";

@ -0,0 +1,27 @@
const initialState = {
loading: true,
error: null,
list: [],
info: null,
};
export default function transport(state = initialState, action) {
let { type, data } = action;
switch (type) {
case "transport/list":
return { ...state, loading: false, list: data, error: null };
case "transport/info":
return { ...state, loading: false, list: null, info: data, error: null };
case "transport/update":
return { ...state, loading: false, error: null };
case "transport/add":
return { ...state, loading: false, error: null };
case "transport/delete":
return { ...state, loading: false, error: null };
case "loading":
return { ...state, loading: true };
case "error":
return { ...state, loading: false, error: data.message };
default:
return state;
}
}

@ -15,10 +15,8 @@ export default function user(state = initialState, action) {
case "user/login":
case "user/register":
case "user/switchRole":
case "user/getProfile":
case "user/login":
case "public/sendOTP":
return { ...state, loading: false, status: data, error: null };
return { ...state, loading: false, status: data.profile, error: null };
case "user/otp/login":
return {
...state,
@ -26,6 +24,9 @@ export default function user(state = initialState, action) {
status: data.profile,
error: null,
};
case "user/getProfile":
localStorage.setItem("userData", JSON.stringify(data));
return { ...state, loading: false, status: data, error: null };
case "user/logout":
return { ...state, loading: false, status: proxy.status(), error: null };
case "user/getUserRole":

@ -3,7 +3,7 @@ import { toast } from "react-toastify";
const initialState = {
loading: false,
error: null,
list: null,
list: [],
info: null,
sum: null,
};
@ -13,7 +13,7 @@ export default function userProduct(state = initialState, action) {
case "userProduct/list":
return { ...state, loading: false, list: data, error: null };
case "userProduct/info":
return { ...state, loading: false, list: null, info: data, error: null };
return { ...state, loading: false, info: data, error: null };
case "userProduct/update":
return { ...state, loading: false, error: null };
case "userProduct/add":

@ -13,6 +13,7 @@ export default function FormPropsTextFields(props) {
textAlign: props.align,
direction: props.align === "right" ? "rtl" : "ltr",
},
fontFamily: "numeralLight",
},
},
}));
@ -33,7 +34,6 @@ export default function FormPropsTextFields(props) {
onInput={(e) => (e.target.value = onInput(e.target.value))}
/>
</div>
+
</form>
);
}

@ -196,7 +196,7 @@ class Profile extends Component {
return (
<>
{window.innerWidth > 1000 ? (
!this.props.loading ? (
profile ? (
<div className="auth-profile d-flex justify-content-center">
<div className="auth-profile__box d-flex flex-column p-4">
<h1 style={{ fontSize: fontSize.desktop.h1 }}>حساب کاربری</h1>
@ -403,7 +403,7 @@ class Profile extends Component {
)
) : null}
{window.innerWidth < 1000 ? (
!this.props.loading ? (
profile ? (
<div className="mobile-auth-profile d-flex flex-column">
<img src={logo} alt="دانوین" />
<h1 style={{ fontSize: fontSize.mobile.h1 }}>حساب کاربری</h1>
@ -423,6 +423,7 @@ class Profile extends Component {
label="نام خانوادگی"
parent={this}
defaultValue={profile}
onInput={this.forcePersian}
/>
<Input
name="username"
@ -579,7 +580,7 @@ class Profile extends Component {
export default connect(
(state) => ({
profile: state.user.status || {},
profile: state.user.status,
loading: state.user.loading,
}),
{ getProfile: user.getProfile, setProfile: user.setProfile }

@ -25,8 +25,10 @@
}
&__upload {
margin: 10px auto;
min-width: 130px;
min-height: 130px;
min-width: 100px;
min-height: 100px;
height: calc(100vh / 7);
width: calc(100vh / 7);
border-radius: 50%;
background-color: rgb(209, 209, 209);
position: relative;
@ -69,6 +71,7 @@
.MuiOutlinedInput-input {
padding: 15px 14px !important;
font-family: numeralLight;
}
.MuiInputLabel-outlined {
font-family: numeralLight !important;
@ -98,7 +101,7 @@
letter-spacing: -1px;
}
.Mui-focused {
color: rgba(0, 0, 0, 0.54) !important;
color: rgba(0, 0, 0, 1) !important;
border-color: #c4c4c5 !important;
background-color: white;
}
@ -116,11 +119,11 @@
border: 0px;
background-color: #128c7e;
border-radius: 7px;
width: 90%;
width: 100%;
font-size: 18px;
font-weight: 600;
color: white;
padding: 12px 0px;
margin-top: 10px;
}
}
@media screen and (max-width: 1000px) {

@ -1,5 +1,4 @@
import './index.scss';
import "./index.scss";
const maxDesktopSize = 1250;
const maxMobileSize = 550;
@ -30,10 +29,7 @@ const DeliveryMethod = (props) => {
<div
className="delivery-methods d-flex justify-content-between align-items-center"
style={{
background:
props.parent.state.selectedDelivery === props.data
? "#ccffcc"
: "white",
background: props.data.isDe ? "#ccffcc" : "white",
}}
onClick={() =>
props.parent.setState({ selectedDelivery: props.data })
@ -76,4 +72,4 @@ const DeliveryMethod = (props) => {
);
};
export default DeliveryMethod;
export default DeliveryMethod;

@ -29,6 +29,8 @@
border-radius: 10px;
border: 1px solid #88a9ff;
margin-top: 10px;
flex: 1;
max-width: 45%;
h3,
strong,
span {

@ -6,9 +6,9 @@ const maxMobileSize = 550;
const fontSize = {
desktop: {
h2: window.innerWidth > maxDesktopSize ? 20 : window.innerWidth / 55,
h2: window.innerWidth > maxDesktopSize ? 16 : window.innerWidth / 55,
input: window.innerWidth > maxDesktopSize ? 16 : window.innerWidth / 75,
button: window.innerWidth > maxDesktopSize ? 16 : window.innerWidth / 75,
button: window.innerWidth > maxDesktopSize ? 15 : window.innerWidth / 75,
p: window.innerWidth > maxDesktopSize ? 12 : window.innerWidth / 90,
},
mobile: {

@ -1,5 +1,5 @@
import React, { Component } from 'react';
import './index.scss';
import React, { Component } from "react";
import "./index.scss";
const maxDesktopSize = 1250;
const maxMobileSize = 550;
@ -10,8 +10,8 @@ const fontSize = {
th: window.innerWidth > maxDesktopSize ? 16 : window.innerWidth / 80,
h2: window.innerWidth > maxDesktopSize ? 20 : window.innerWidth / 55,
h3: window.innerWidth > maxDesktopSize ? 12 : window.innerWidth / 90,
strong: window.innerWidth > maxDesktopSize ? 12 : window.innerWidth / 90,
span: window.innerWidth > maxDesktopSize ? 10 : window.innerWidth / 95,
strong: window.innerWidth > maxDesktopSize ? 13 : window.innerWidth / 90,
span: window.innerWidth > maxDesktopSize ? 12 : window.innerWidth / 95,
},
mobile: {
h1: window.innerWidth > maxMobileSize ? 20 : window.innerWidth / 13,
@ -55,16 +55,28 @@ const Factor = (props) => {
{window.innerWidth > 1000 ? (
<div className="factor d-flex flex-column">
<div className="d-flex justify-content-between">
<strong>مبلغ سبد خرید</strong>
<span>{totalPrice()} تومان</span>
<strong style={{ fontSize: fontSize.desktop.strong }}>
مبلغ سبد خرید
</strong>
<span style={{ fontSize: fontSize.desktop.span }}>
{totalPrice()} تومان
</span>
</div>
<div className="d-flex justify-content-between">
<strong>هزینه ارسال</strong>
<span>{props.parent.state.selectedDelivery.price} تومان</span>
<strong style={{ fontSize: fontSize.desktop.strong }}>
هزینه ارسال
</strong>
<span style={{ fontSize: fontSize.desktop.span }}>
{props.parent.state.selectedDelivery.price} تومان
</span>
</div>
<div className="d-flex justify-content-between">
<strong>میزان تخفیف</strong>
<span>{props.parent.state.discount} تومان</span>
<strong style={{ fontSize: fontSize.desktop.strong }}>
میزان تخفیف
</strong>
<span style={{ fontSize: fontSize.desktop.span }}>
{props.parent.state.discount} تومان
</span>
</div>
</div>
) : null}
@ -72,4 +84,4 @@ const Factor = (props) => {
);
};
export default Factor;
export default Factor;

@ -1,6 +1,6 @@
import React, { Component } from "react";
import { connect } from "react-redux";
import { userProduct } from "~/Redux/actions";
import { userProduct, transport } from "~/Redux/actions";
import { ToastContainer } from "react-toastify";
import Navbar from "../Home/Navbar/index";
@ -22,7 +22,7 @@ const fontSize = {
desktop: {
h1: window.innerWidth > maxDesktopSize ? 30 : window.innerWidth / 40,
th: window.innerWidth > maxDesktopSize ? 16 : window.innerWidth / 80,
h2: window.innerWidth > maxDesktopSize ? 20 : window.innerWidth / 55,
h2: window.innerWidth > maxDesktopSize ? 16 : window.innerWidth / 55,
h3: window.innerWidth > maxDesktopSize ? 12 : window.innerWidth / 90,
strong: window.innerWidth > maxDesktopSize ? 12 : window.innerWidth / 90,
span: window.innerWidth > maxDesktopSize ? 10 : window.innerWidth / 95,
@ -77,8 +77,22 @@ class Cart extends Component {
],
};
componentDidUpdate(prevProps, prevState) {
if (this.props.list.length > 0) {
let wantedId; //should be zero
for (let item of this.props.list) {
if (item.condition) {
wantedId = item.id;
break;
}
}
this.props.getInfo({ id: wantedId });
}
}
componentDidMount() {
this.props.getList();
this.props.getTransportList();
}
handleCounter = (type, id) => {
@ -113,7 +127,7 @@ class Cart extends Component {
};
render() {
const { list, payPrice } = this.props;
const { list, payPrice, payMethods } = this.props;
return (
<>
{window.innerWidth > 1000 ? (
@ -145,7 +159,7 @@ class Cart extends Component {
روشهای ارسال
</h2>
<div className="d-flex justify-content-between">
{this.props.payMethods.map((item, i) => (
{payMethods.map((item, i) => (
<DeliveryMethod data={item} key={i} parent={this} />
))}
</div>
@ -175,7 +189,7 @@ class Cart extends Component {
با توجه به شرایط یکی از دو گزینه زیر را انتخاب کنید
</p>
<div className="d-flex justify-content-between">
{this.props.payMethods.map((item, i) => (
{payMethods.map((item, i) => (
<DeliveryMethod data={item} key={i} parent={this} />
))}
</div>
@ -279,19 +293,11 @@ export default connect(
(state) => ({
list: state.userProduct.list,
payPrice: state.userProduct.sum,
payMethods: state.transport.list,
}),
{ getList: userProduct.list }
{
getList: userProduct.list,
getInfo: userProduct.info,
getTransportList: transport.list,
}
)(Cart);
Cart.defaultProps = {
payMethods: [
{
name: "ارسال با پست پیشتاز",
price: 36.891,
},
{
name: "ارسال با پیک موتوری",
price: 36.891,
},
],
};

Loading…
Cancel
Save