parent
89e3085230
commit
5c7046df04
20 changed files with 349 additions and 168 deletions
@ -0,0 +1,33 @@ |
||||
import proxy from "../proxy"; |
||||
const userAddress = { |
||||
list: |
||||
(data = {}) => |
||||
async (dispatch) => { |
||||
await proxy.get("userAddress/list", data, { dispatch }); |
||||
}, |
||||
info: |
||||
(data = {}) => |
||||
async (dispatch) => { |
||||
await dispatch({ type: "userAddress/info", data }); |
||||
}, |
||||
update: |
||||
(data = {}, data2 = {}) => |
||||
async (dispatch) => { |
||||
await proxy.put("userAddress/update", data); |
||||
await proxy.get("userAddress/list", data2, { dispatch }); |
||||
}, |
||||
add: |
||||
(data = {}, data2 = {}, data3 = {}) => |
||||
async (dispatch) => { |
||||
await proxy.post("userAddress/add", data, { dispatch }); |
||||
await proxy.get("userAddress/list", data2, { dispatch }); |
||||
}, |
||||
del: |
||||
(data = {}, data2 = {}) => |
||||
async (dispatch) => { |
||||
await proxy.delete("userAddress/delete", data); |
||||
await proxy.get("userAddress/list", data2, { dispatch }); |
||||
}, |
||||
}; |
||||
|
||||
export default userAddress; |
@ -0,0 +1,35 @@ |
||||
import { toast } from "react-toastify"; |
||||
|
||||
const initialState = { |
||||
loading: false, |
||||
error: null, |
||||
list: [], |
||||
info : null, |
||||
}; |
||||
export default function userAddress(state = initialState, action) { |
||||
let { type, data } = action; |
||||
switch (type) { |
||||
case "userAddress/list": |
||||
return { |
||||
...state, |
||||
loading: false, |
||||
list: data, |
||||
error: null, |
||||
}; |
||||
case "userAddress/info": |
||||
return { ...state, loading: false, info: data, error: null }; |
||||
case "userAddress/update": |
||||
return { ...state, loading: false, error: null }; |
||||
case "userAddress/add": |
||||
return { ...state, loading: false, error: null, sum: data.payPrice }; |
||||
case "userAddress/delete": |
||||
return { ...state, loading: false, error: null }; |
||||
case "userAddress/loading": |
||||
return { ...state, loading: true }; |
||||
case "userAddress/error": |
||||
toast.error(data.message); |
||||
return { ...state, loading: false, error: data.message }; |
||||
default: |
||||
return state; |
||||
} |
||||
} |
@ -0,0 +1,61 @@ |
||||
import React, {useState} from "react"; |
||||
import { connect } from "react-redux"; |
||||
|
||||
import Input from "../../components/Input"; |
||||
|
||||
export const Address = ({}) => { |
||||
const [addressFields, setAddressFields] = useState({}); |
||||
const onChange = (name, value) => { |
||||
|
||||
} |
||||
|
||||
const Header = ({ title, text }) => { |
||||
return ( |
||||
<div className="flex flex-row items-center gap-2 mb-4"> |
||||
<strong className="text-blue5F text-base">{title}</strong> |
||||
<p className="mt-1 inline flex-1 text-sm text-gray70">{text}</p> |
||||
</div> |
||||
); |
||||
}; |
||||
return ( |
||||
<div |
||||
className="flex flex-row-reverse flex-1 pb-20 gap-5 divide-x divide-solid divide-gray-200" |
||||
style={{ minHeight: "calc(100vh - 500px)" }} |
||||
> |
||||
<div className="flex flex-col w-1/2"></div> |
||||
<div className="flex flex-col w-1/2 pl-4"> |
||||
<Header |
||||
title="اطلاعات هویتی" |
||||
text="( لطفا نام و نام خانوادگی خود را به طور کامل وارد نمایید )" |
||||
/> |
||||
<div className="flex flex-row items-center gap-5 w-full"> |
||||
<Input |
||||
width={{width : '50%'}} |
||||
label={"نام"} |
||||
regex={val => val} |
||||
name="firstName" |
||||
onChange={(name, value) => onChange(name, value)} |
||||
value={addressFields?.firstName} |
||||
align="text-right" |
||||
direction="rtl" |
||||
/> |
||||
<Input |
||||
label={"نام خانوادگی"} |
||||
regex={(val) => val} |
||||
name="lastName" |
||||
onChange={(name, value) => onChange(name, value)} |
||||
value={addressFields?.lastName} |
||||
align="text-right" |
||||
direction="rtl" |
||||
/> |
||||
</div> |
||||
</div> |
||||
</div> |
||||
); |
||||
}; |
||||
|
||||
const mapStateToProps = (state) => ({}); |
||||
|
||||
const mapDispatchToProps = {}; |
||||
|
||||
export default connect(mapStateToProps, mapDispatchToProps)(Address); |
Loading…
Reference in new issue