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. 8
      src/views/Cart/DeliveryMethod/index.js
  14. 2
      src/views/Cart/DeliveryMethod/index.scss
  15. 4
      src/views/Cart/Discount/index.js
  16. 32
      src/views/Cart/Factor/index.js
  17. 44
      src/views/Cart/index.js

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

@ -7,3 +7,4 @@ export { default as user } from "./user.js";
export { default as qr } from "./qr.js"; export { default as qr } from "./qr.js";
export { default as book } from "./book.js"; export { default as book } from "./book.js";
export { default as userProduct } from "./userProduct.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); localStorage.setItem("access", login.accessToken);
delete login.refreshToken; delete login.refreshToken;
delete login.accessToken; delete login.accessToken;
localStorage.setItem("userData", JSON.stringify(login)); localStorage.setItem("userData", JSON.stringify(login.profile));
dispatch(obj); dispatch(obj);
}, },
}); });
@ -93,8 +93,7 @@ class Proxy {
localStorage.removeItem("userData"); localStorage.removeItem("userData");
return false; return false;
} }
let fakeUserData = JSON.parse(userData); return JSON.parse(userData);
return fakeUserData.profile;
}; };
} }
const _proxy = new Proxy(); const _proxy = new Proxy();

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

@ -7,3 +7,4 @@ export { default as user } from "./user.js";
export { default as qr } from "./qr.js"; export { default as qr } from "./qr.js";
export { default as book } from "./book.js"; export { default as book } from "./book.js";
export { default as userProduct } from "./userProduct.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/login":
case "user/register": case "user/register":
case "user/switchRole": case "user/switchRole":
case "user/getProfile":
case "user/login":
case "public/sendOTP": case "public/sendOTP":
return { ...state, loading: false, status: data, error: null }; return { ...state, loading: false, status: data.profile, error: null };
case "user/otp/login": case "user/otp/login":
return { return {
...state, ...state,
@ -26,6 +24,9 @@ export default function user(state = initialState, action) {
status: data.profile, status: data.profile,
error: null, error: null,
}; };
case "user/getProfile":
localStorage.setItem("userData", JSON.stringify(data));
return { ...state, loading: false, status: data, error: null };
case "user/logout": case "user/logout":
return { ...state, loading: false, status: proxy.status(), error: null }; return { ...state, loading: false, status: proxy.status(), error: null };
case "user/getUserRole": case "user/getUserRole":

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

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

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

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

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

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

@ -6,9 +6,9 @@ const maxMobileSize = 550;
const fontSize = { const fontSize = {
desktop: { 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, 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, p: window.innerWidth > maxDesktopSize ? 12 : window.innerWidth / 90,
}, },
mobile: { mobile: {

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

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

Loading…
Cancel
Save